From fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 9 Jun 2017 11:34:21 -0700 Subject: Initial import of code. --- source/slang/token.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 source/slang/token.h (limited to 'source/slang/token.h') 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 -- cgit v1.2.3