9 #ifndef MLIR_LIB_PARSER_TOKEN_H 10 #define MLIR_LIB_PARSER_TOKEN_H 13 #include "llvm/ADT/StringRef.h" 14 #include "llvm/Support/SMLoc.h" 22 #define TOK_MARKER(NAME) NAME, 23 #define TOK_IDENTIFIER(NAME) NAME, 24 #define TOK_LITERAL(NAME) NAME, 25 #define TOK_PUNCTUATION(NAME, SPELLING) NAME, 26 #define TOK_OPERATOR(NAME, SPELLING) NAME, 27 #define TOK_KEYWORD(SPELLING) kw_##SPELLING, 28 #include "TokenKinds.def" 31 Token(
Kind kind, StringRef spelling) : kind(kind), spelling(spelling) {}
38 bool is(
Kind K)
const {
return kind == K; }
43 template <
typename... T>
47 return isAny(k2, k3, others...);
53 template <
typename... T>
bool isNot(
Kind k1,
Kind k2, T... others)
const {
54 return !
isAny(k1, k2, others...);
87 llvm::SMLoc
getLoc()
const;
107 #endif // MLIR_LIB_PARSER_TOKEN_H Definition: InferTypeOpInterface.cpp:20
bool isAny(Kind k1, Kind k2, Kind k3, T... others) const
Return true if this token is one of the specified kinds.
Definition: Token.h:44
bool isNot(Kind k) const
Definition: Token.h:50
bool isKeyword() const
Return true if this is one of the keyword token kinds (e.g. kw_if).
Definition: Token.cpp:146
bool is(Kind K) const
Definition: Token.h:38
bool isAny(Kind k1, Kind k2) const
Definition: Token.h:40
Optional< unsigned > getIntTypeBitwidth() const
For an inttype token, return its bitwidth.
Definition: Token.cpp:59
llvm::SMLoc getEndLoc() const
Definition: Token.cpp:21
Token(Kind kind, StringRef spelling)
Definition: Token.h:31
std::string getStringValue() const
Definition: Token.cpp:70
Kind
Definition: Token.h:21
Kind getKind() const
Definition: Token.h:37
Optional< unsigned > getUnsignedIntegerValue() const
Definition: Token.cpp:29
StringRef getSpelling() const
Definition: Token.h:34
static StringRef getTokenSpelling(Kind kind)
Definition: Token.cpp:128
llvm::SMLoc getLoc() const
Definition: Token.cpp:19
bool isNot(Kind k1, Kind k2, T... others) const
Return true if this token isn't one of the specified kinds.
Definition: Token.h:53
Optional< uint64_t > getUInt64IntegerValue() const
Definition: Token.cpp:40
Optional< double > getFloatingPointValue() const
Definition: Token.cpp:51
llvm::SMRange getLocRange() const
Definition: Token.cpp:25
Optional< unsigned > getHashIdentifierNumber() const
Definition: Token.cpp:117
This represents a token in the MLIR syntax.
Definition: Token.h:19