#ifndef YERBACON_LEX_H #define YERBACON_LEX_H #include #include "Yerbacon.hpp" #include #include struct tok { typedef Yerbacon::Exception LexerException; enum type: const unsigned short { UNEXPECTED = std::numeric_limits::max() + 1, IDENTIFIER, NUMBER, ALPHACHAR, DEFINE = '=', TAG = '#', DOLLAR_SIGN = '$', DOT = '.', COMMA = ',', LPAR = '(', LBRACE = '{', LBRACKET = '[', RPAR = ')', RBRACE = '}', RBRACKET = ']', PLUS = '+', HYPHEN = '-', DIVIDE = '/', LCOMP = '>', RCOMP = '<', SQUOTE = '\'', ASTERISK = '*', STRING = '"', }; static auto inverseLCharacter(const unsigned char& character) { return static_cast(((character + 2) - (character == tok::LPAR))); }; type toktype; std::string toktext; unsigned long line; tok(): toktype(UNEXPECTED), toktext(), line(0) {}; tok(const type& Type, std::string_view Text, const decltype(line)& line = 0): toktype(Type), toktext(Text), line(line) {} explicit tok(const type& Type, const decltype(line)& line = 0): tok(Type, std::string(1, Type), line) {}; friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; } }; std::vector lex(const std::string& in); #endif //YERBACON_TEST_H