diff options
| author | ov-4 <hausemasterstream@gmail.com> | 2026-01-29 11:13:05 +0000 |
|---|---|---|
| committer | ov-4 <hausemasterstream@gmail.com> | 2026-01-29 11:13:05 +0000 |
| commit | 05c19789d5e1b5edd050ee97c19a8ab86ec9e0f6 (patch) | |
| tree | 4fd26a6611084908c445c61a285ebf849d571e57 /lib/Lexer/Lexer.cc | |
| parent | f1fedc36ec54578be4983d2fc6abee999dbc51c2 (diff) | |
Added half way of IF statement
Diffstat (limited to 'lib/Lexer/Lexer.cc')
| -rw-r--r-- | lib/Lexer/Lexer.cc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/Lexer/Lexer.cc b/lib/Lexer/Lexer.cc index b04438b..9ac01d9 100644 --- a/lib/Lexer/Lexer.cc +++ b/lib/Lexer/Lexer.cc @@ -19,6 +19,10 @@ int Lexer::gettok() { if (IdentifierStr == "INTEGER") return tok_integer_kw; if (IdentifierStr == "INPUT") return tok_input; if (IdentifierStr == "OUTPUT") return tok_output; + if (IdentifierStr == "IF") return tok_if; + if (IdentifierStr == "THEN") return tok_then; + if (IdentifierStr == "ELSE") return tok_else; + if (IdentifierStr == "ENDIF") return tok_endif; return tok_identifier; } @@ -34,13 +38,35 @@ int Lexer::gettok() { if (LastChar == '<') { LastChar = getchar(); - if (LastChar == '-') { + if (LastChar == '-') { // <- LastChar = getchar(); return tok_assign; } + if (LastChar == '=') { // <= + LastChar = getchar(); + return tok_le; + } + if (LastChar == '>') { // <> + LastChar = getchar(); + return tok_ne; + } return '<'; } + if (LastChar == '>') { + LastChar = getchar(); + if (LastChar == '=') { // >= + LastChar = getchar(); + return tok_ge; + } + return '>'; + } + + if (LastChar == '=') { + LastChar = getchar(); + return tok_eq; + } + // for comments if (LastChar == ':') { |
