diff options
Diffstat (limited to 'lib/Lexer')
| -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 == ':') { |
