diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-09 11:34:21 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-09 13:44:59 -0700 |
| commit | fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd (patch) | |
| tree | 41047c94883b86ec085a81597391ce3ef557cd43 /source/slang/token.h | |
| parent | 52e8d4b9a27ab0060f874c3a63ab531847be35c0 (diff) | |
Initial import of code.
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 |
