From 1b524f75401a6318fbaf3fee0bfcbe59348f2e51 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Mon, 2 Feb 2026 10:08:22 +0000 Subject: Added STRING --- lib/Lexer/Lexer.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib/Lexer') diff --git a/lib/Lexer/Lexer.cc b/lib/Lexer/Lexer.cc index d9eb09b..040c3e8 100644 --- a/lib/Lexer/Lexer.cc +++ b/lib/Lexer/Lexer.cc @@ -15,6 +15,17 @@ int Lexer::gettok() { LastChar = getchar(); } + if (LastChar == '"') { + StringVal = ""; + LastChar = getchar(); + while (LastChar != '"' && LastChar != EOF) { + StringVal += LastChar; + LastChar = getchar(); + } + if (LastChar == '"') LastChar = getchar(); + return tok_string_literal; + } + if (isalpha(LastChar)) { IdentifierStr = LastChar; while (isalnum((LastChar = getchar())) || LastChar == '_') @@ -24,7 +35,8 @@ int Lexer::gettok() { if (IdentifierStr == "INTEGER") return tok_integer_kw; if (IdentifierStr == "BOOLEAN") return tok_boolean_kw; if (IdentifierStr == "REAL") return tok_real_kw; - + if (IdentifierStr == "STRING") return tok_string_kw; + if (IdentifierStr == "TRUE") return tok_true; if (IdentifierStr == "FALSE") return tok_false; @@ -58,6 +70,12 @@ int Lexer::gettok() { if (IdentifierStr == "OR") return tok_or; if (IdentifierStr == "NOT") return tok_not; + if (IdentifierStr == "LENGTH") return tok_length; + if (IdentifierStr == "MID") return tok_mid; + if (IdentifierStr == "RIGHT") return tok_right; + if (IdentifierStr == "LCASE") return tok_lcase; + if (IdentifierStr == "UCASE") return tok_ucase; + if (IdentifierStr == "FUNCTION") return tok_function; if (IdentifierStr == "ENDFUNCTION") return tok_endfunction; if (IdentifierStr == "PROCEDURE") return tok_procedure; -- cgit v1.3.1-4-g156e