aboutsummaryrefslogtreecommitdiff
path: root/lib/Lexer/Lexer.cc
diff options
context:
space:
mode:
authorov-4 <hausemasterstream@gmail.com>2026-01-29 11:13:05 +0000
committerov-4 <hausemasterstream@gmail.com>2026-01-29 11:13:05 +0000
commit05c19789d5e1b5edd050ee97c19a8ab86ec9e0f6 (patch)
tree4fd26a6611084908c445c61a285ebf849d571e57 /lib/Lexer/Lexer.cc
parentf1fedc36ec54578be4983d2fc6abee999dbc51c2 (diff)
Added half way of IF statement
Diffstat (limited to 'lib/Lexer/Lexer.cc')
-rw-r--r--lib/Lexer/Lexer.cc28
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 == ':') {