diff options
Diffstat (limited to 'source/slang/token.h')
| -rw-r--r-- | source/slang/token.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source/slang/token.h b/source/slang/token.h new file mode 100644 index 000000000..00a55feb1 --- /dev/null +++ b/source/slang/token.h @@ -0,0 +1,50 @@ +// token.h +#ifndef SLANG_TOKEN_H_INCLUDED +#define SLANG_TOKEN_H_INCLUDED + +#include "../core/basic.h" + +#include "source-loc.h" + +namespace Slang { +namespace Compiler { + +using namespace CoreLib::Basic; + +enum class TokenType +{ +#define TOKEN(NAME, DESC) NAME, +#include "token-defs.h" +}; + +char const* TokenTypeToString(TokenType type); + +enum TokenFlag : unsigned int +{ + AtStartOfLine = 1 << 0, + AfterWhitespace = 1 << 1, +}; +typedef unsigned int TokenFlags; + +class Token +{ +public: + TokenType Type = TokenType::Unknown; + String Content; + CodePosition Position; + TokenFlags flags = 0; + Token() = default; + Token(TokenType type, const String & content, int line, int col, int pos, String fileName, TokenFlags flags = 0) + : flags(flags) + { + Type = type; + Content = content; + Position = CodePosition(line, col, pos, fileName); + } +}; + + + +}} + +#endif |
