Created
March 20, 2017 06:49
-
-
Save Interfere/6127f26242da28d38514068c9d0632c5 to your computer and use it in GitHub Desktop.
Token declaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class tok { | |
unknown = 0, | |
eof, | |
identifier, | |
oper_binary_unspaced, // "x+y" | |
oper_binary_spaced, // "x + y" | |
oper_postfix, | |
oper_prefix, | |
... | |
NUM_TOKENS | |
}; | |
/// Token - This structure provides full information | |
/// about a lexed token. | |
class Token { | |
/// Kind - The actual flavor of token this is. | |
tok Kind; | |
/// Text - The actual string covered by the token | |
/// in the source buffer. | |
StringRef Text; | |
public: | |
Token() : Kind(tok::NUM_TOKENS) {} | |
/// \brief Set the token to the specified kind and source range. | |
void setToken(tok K, StringRef T) { | |
Kind = K; | |
Text = T; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment