My Project
|
This represents a token in the MLIR syntax. More...
#include <Token.h>
Public Types | |
enum | Kind { TOK_IDENTIFIER, TOK_IDENTIFIER, TOK_IDENTIFIER } |
Public Member Functions | |
Token (Kind kind, StringRef spelling) | |
StringRef | getSpelling () const |
Kind | getKind () const |
bool | is (Kind K) const |
bool | isAny (Kind k1, Kind k2) const |
template<typename... T> | |
bool | isAny (Kind k1, Kind k2, Kind k3, T... others) const |
Return true if this token is one of the specified kinds. More... | |
bool | isNot (Kind k) const |
template<typename... T> | |
bool | isNot (Kind k1, Kind k2, T... others) const |
Return true if this token isn't one of the specified kinds. More... | |
bool | isKeyword () const |
Return true if this is one of the keyword token kinds (e.g. kw_if). More... | |
Optional< unsigned > | getUnsignedIntegerValue () const |
Optional< uint64_t > | getUInt64IntegerValue () const |
Optional< double > | getFloatingPointValue () const |
Optional< unsigned > | getIntTypeBitwidth () const |
For an inttype token, return its bitwidth. More... | |
Optional< unsigned > | getHashIdentifierNumber () const |
std::string | getStringValue () const |
llvm::SMLoc | getLoc () const |
llvm::SMLoc | getEndLoc () const |
llvm::SMRange | getLocRange () const |
Static Public Member Functions | |
static StringRef | getTokenSpelling (Kind kind) |
This represents a token in the MLIR syntax.
enum mlir::Token::Kind |
|
inline |
SMLoc Token::getEndLoc | ( | ) | const |
Optional< double > Token::getFloatingPointValue | ( | ) | const |
For a floatliteral token, return its value as a double. Returns None in the case of underflow or overflow.
For a floatliteral, return its value as a double. Return None if the value underflows or overflows.
Optional< unsigned > Token::getHashIdentifierNumber | ( | ) | const |
Given a hash_identifier token like #123, try to parse the number out of the identifier, returning None if it is a named identifier like #x or if the integer doesn't fit.
Optional< unsigned > Token::getIntTypeBitwidth | ( | ) | const |
For an inttype token, return its bitwidth.
|
inline |
SMLoc Token::getLoc | ( | ) | const |
SMRange Token::getLocRange | ( | ) | const |
|
inline |
std::string Token::getStringValue | ( | ) | const |
Given a token containing a string literal, return its value, including removing the quote characters and unescaping the contents of the string.
Given a token containing a string literal, return its value, including removing the quote characters and unescaping the contents of the string. The lexer has already verified that this token is valid.
|
static |
Given a punctuation or keyword token kind, return the spelling of the token as a string. Warning: This will abort on markers, identifiers and literal tokens since they have no fixed spelling.
Optional< uint64_t > Token::getUInt64IntegerValue | ( | ) | const |
For an integer token, return its value as an uint64_t. If it doesn't fit, return None.
For an integer token, return its value as a uint64_t. If it doesn't fit, return None.
Optional< unsigned > Token::getUnsignedIntegerValue | ( | ) | const |
For an integer token, return its value as an unsigned. If it doesn't fit, return None.
|
inline |
|
inline |
Return true if this token is one of the specified kinds.
bool Token::isKeyword | ( | ) | const |
Return true if this is one of the keyword token kinds (e.g. kw_if).
|
inline |
Return true if this token isn't one of the specified kinds.