diff options
| author | _ov4 <hausemasterstream@gmail.com> | 2026-01-30 13:11:20 +0000 |
|---|---|---|
| committer | _ov4 <hausemasterstream@gmail.com> | 2026-01-30 13:11:20 +0000 |
| commit | bd799e42b40613983c6e3cb9aedf58866ac68605 (patch) | |
| tree | 03fdd0dffba45fa2a1d9b8d4b0e78f49140c07e5 /lib/Lexer | |
| parent | 80420b0f92f42edc0a3cac4490a08adb8b2457dc (diff) | |
Added FUNCTION and PROCEDURE
Diffstat (limited to 'lib/Lexer')
| -rw-r--r-- | lib/Lexer/Lexer.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Lexer/Lexer.cc b/lib/Lexer/Lexer.cc index 51e27dd..6854cc9 100644 --- a/lib/Lexer/Lexer.cc +++ b/lib/Lexer/Lexer.cc @@ -21,6 +21,9 @@ int Lexer::gettok() { if (IdentifierStr == "DECLARE") return tok_declare; if (IdentifierStr == "INTEGER") return tok_integer_kw; + if (IdentifierStr == "BOOLEAN") return tok_integer_kw; // TODO: implement real BOOLEAN + if (IdentifierStr == "REAL") return tok_integer_kw; // TODO: implement real REAL + if (IdentifierStr == "INPUT") return tok_input; if (IdentifierStr == "OUTPUT") return tok_output; @@ -44,6 +47,14 @@ int Lexer::gettok() { if (IdentifierStr == "ARRAY") return tok_array; if (IdentifierStr == "OF") return tok_of; + if (IdentifierStr == "FUNCTION") return tok_function; + if (IdentifierStr == "ENDFUNCTION") return tok_endfunction; + if (IdentifierStr == "PROCEDURE") return tok_procedure; + if (IdentifierStr == "ENDPROCEDURE") return tok_endprocedure; + if (IdentifierStr == "RETURN") return tok_return; + if (IdentifierStr == "RETURNS") return tok_returns; + if (IdentifierStr == "CALL") return tok_call; + return tok_identifier; } @@ -93,6 +104,15 @@ int Lexer::gettok() { return tok_colon; } + if (LastChar == '(') { LastChar = getchar(); return '('; } + if (LastChar == ')') { LastChar = getchar(); return ')'; } + if (LastChar == '[') { LastChar = getchar(); return '['; } + if (LastChar == ']') { LastChar = getchar(); return ']'; } + if (LastChar == ',') { LastChar = getchar(); return ','; } + if (LastChar == '+') { LastChar = getchar(); return '+'; } + if (LastChar == '-') { LastChar = getchar(); return '-'; } + if (LastChar == '*') { LastChar = getchar(); return '*'; } + if (LastChar == '/') { int NextChar = getchar(); if (NextChar == '/') { |
