#pragma once #include "Location.h" #include #include enum TokenType { TT_Identifier, TT_Number, TT_Float, TT_Keyword, TT_String, TT_Plus, TT_Minus, TT_Mul, TT_Div, TT_At, TT_Equal, TT_LessThan, TT_GreaterThan, TT_LParen, TT_RParen, TT_LBracket, TT_RBracket, TT_Semicolon, TT_LoadedString, TT_EOF, TT_Null, TT_Equals, TT_GTE, TT_LTE, TT_Period, TT_Comma, TT_Path, TT_Exclamation, TT_NEqual, TT_LSQB, TT_RSQB, TT_Type, TT_Import, TT_Syscall0, TT_Syscall1, TT_Syscall2, TT_Syscall3, TT_Syscall4, TT_Syscall5 }; extern const std::string token_strings[]; struct Token { TokenType tk_type; int int_value; std::string string_value; float float_value; Location loc; Token(const TokenType& type); Token(const TokenType& type, const Location& location); Token(const TokenType& type, const int& val, const Location& location); Token(const TokenType& type, const std::string& val, const Location& location); Token(const TokenType& type, const std::string& val); Token(const TokenType& type, const float& val, const Location& location); ~Token(); std::string to_string() const; std::string line() const; static Token make_with_line(const Token& origin, const std::string& line_text); void operator=(const Token& other); static void erase(Token& tk); Token copy_with_new_type(const TokenType& type); static bool match_token_types(const std::vector& a, const std::vector& b, int count); private: std::string line_text; }; typedef std::vector TokenStream;