diff options
Diffstat (limited to 'include/lexer.hpp')
-rw-r--r-- | include/lexer.hpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/include/lexer.hpp b/include/lexer.hpp index 8d0d826..e674999 100644 --- a/include/lexer.hpp +++ b/include/lexer.hpp @@ -7,7 +7,14 @@ #ifndef LEXER_H #define LEXER_H -const std::string EMPTY_STRING = ""; +enum function_name{ + sin, + cos, + tan, + csc, + sec, + ctg +}; enum token_type{ sum, @@ -17,29 +24,32 @@ enum token_type{ power, variable, number, - sin, - cos, - tan, function, left_parens, - right_parens + right_parens, + nil }; struct Token{ token_type type; std::string value; + Token(token_type type, std::string value) : type(type), value(value){} }; class Lexer{ private: + char var_name; std::string text; - size_t txt_ptr; + size_t current_char; Token current_token; - void setCurrentToken(Token val); + bool matchFunction(std::string function_name); + std::string createNumber(); public: - Lexer(std::string text); - void nextToken(); + Lexer(std::string text = {}); + void setText(std::string text); Token getCurrentToken(); + Token match(); + Token nextToken(); }; #endif /* LEXER_H */ |