-
-/// AsmToken - Target independent representation for an assembler token.
-struct AsmToken {
- enum TokenKind {
- // Markers
- Eof, Error,
-
- // String values.
- Identifier,
- Register,
- String,
-
- // Integer values.
- Integer,
-
- // No-value.
- EndOfStatement,
- Colon,
- Plus, Minus, Tilde,
- Slash, // '/'
- LParen, RParen,
- Star, Comma, Dollar, Equal, EqualEqual,
-
- Pipe, PipePipe, Caret,
- Amp, AmpAmp, Exclaim, ExclaimEqual, Percent,
- Less, LessEqual, LessLess, LessGreater,
- Greater, GreaterEqual, GreaterGreater
- };
-
- TokenKind Kind;
-
- /// A reference to the entire token contents; this is always a pointer into
- /// a memory buffer owned by the source manager.
- StringRef Str;
-
- int64_t IntVal;
-
-public:
- AsmToken() {}
- AsmToken(TokenKind _Kind, const StringRef &_Str, int64_t _IntVal = 0)
- : Kind(_Kind), Str(_Str), IntVal(_IntVal) {}
-
- TokenKind getKind() const { return Kind; }
- bool is(TokenKind K) const { return Kind == K; }
- bool isNot(TokenKind K) const { return Kind != K; }
-
- SMLoc getLoc() const;
-
- StringRef getString() const { return Str; }
-
- // FIXME: Don't compute this in advance, it makes every token larger, and is
- // also not generally what we want (it is nicer for recovery etc. to lex 123br
- // as a single token, then diagnose as an invalid number).
- int64_t getIntVal() const {
- assert(Kind == Integer && "This token isn't an integer");
- return IntVal;
- }
-};