diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-09 10:23:05 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-09 10:23:05 +0000 |
| commit | cc75c9bfec08007a483c9a5b3a733d4adc4d5c30 (patch) | |
| tree | 4b28e1fa3d897811a403f4402c74fc8c255e4542 /include/lexer/token.h | |
| parent | 88274ecae045df69903c4efddc9b24a87ffe31e2 (diff) | |
add class for recurrent lexer
Diffstat (limited to 'include/lexer/token.h')
| -rw-r--r-- | include/lexer/token.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/include/lexer/token.h b/include/lexer/token.h index a79cd2a..f2de46b 100644 --- a/include/lexer/token.h +++ b/include/lexer/token.h @@ -2,8 +2,8 @@ #include <string> +#include "lexer/lexer_class.h" #include "lexer/enum_type.h" -#include "lexer/shared.h" #include "lexer/symbol_property.h" using namespace std; // remove this @@ -11,7 +11,7 @@ using namespace std; // remove this namespace ov4 { -class T_token +class T_lexer::T_token { public: T_token() = default; @@ -22,7 +22,7 @@ public: int bracket_depth = 0; }; -string trim(const string &s, const string &trim_target = " \t") +string T_lexer::trim(const string &s, const string &trim_target) // trim_target = " \t" { size_t b = s.find_first_not_of(trim_target); if (b == string::npos) @@ -32,7 +32,7 @@ string trim(const string &s, const string &trim_target = " \t") } -bool is_single_symbol(char c) +bool T_lexer::is_single_symbol(char c) { string s = " "; s[0] = c; @@ -41,7 +41,7 @@ bool is_single_symbol(char c) return false; } -void bracket_depth_changer(char c, int &bracket_depth) +void T_lexer::bracket_depth_changer(char c, int &bracket_depth) { if (c == '(') { @@ -63,7 +63,7 @@ void bracket_depth_changer(char c, int &bracket_depth) } -bool token_continue(const string &s, char next) +bool T_lexer::token_continue(const string &s, char next) { println("token_continue: receiving {} {}", s, next); // s is empty, so next can be part of the token @@ -102,7 +102,7 @@ bool token_continue(const string &s, char next) } // handle [prev, current) -void token_push(const string &push_s, int bracket_depth, bool force_text = false) +void T_lexer::token_push(const string &push_s, int bracket_depth, bool force_text) // force_text = false { T_token tmp; tmp.bracket_depth = bracket_depth; @@ -127,7 +127,7 @@ void token_push(const string &push_s, int bracket_depth, bool force_text = false token.push_back(tmp); } -int tokenizer(const string &s) +int T_lexer::tokenizer(const string &s) { if (s.size() == 0) return -1; |
