Skip to content

Instantly share code, notes, and snippets.

@Interfere
Created March 20, 2017 06:49
Show Gist options
  • Save Interfere/6127f26242da28d38514068c9d0632c5 to your computer and use it in GitHub Desktop.
Save Interfere/6127f26242da28d38514068c9d0632c5 to your computer and use it in GitHub Desktop.
Token declaration
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