#pragma once #include #include #include #include #include namespace Parser { class Lexer { public: struct Token { enum TokenType { INT, PLUS, MINUS, MULTIPLY, DIVIDE, ASSIGNMENT, BRACKET_LEFT, BRACKET_RIGHT, IDENTIFIER }; TokenType type; uint line; std::string_view occurence; Token(TokenType type, uint line, std::string_view&& str) { this->type = type; this->line = line; occurence = str; } std::string toString(){ return std::to_string(type) + " " + std::string(occurence); } }; Lexer() = default; std::list tokenize(const std::string_view &text); private: uint current{}; uint start{}; uint line{}; std::string_view text; std::list tokens; private: void identifier(); bool isAlpha(const char& c); bool isDigit(const char& c); void number(); void advance(); char peek(); void token(const Token::TokenType type); }; }