From cc7b9b34e99fa17357e14ac69f5fb2d1535b5512 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 3 Mar 2026 07:22:19 +0000 Subject: Added all built-in functions --- lib/Lexer/Lexer.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/Lexer/Lexer.cc') diff --git a/lib/Lexer/Lexer.cc b/lib/Lexer/Lexer.cc index 040c3e8..ef3a920 100644 --- a/lib/Lexer/Lexer.cc +++ b/lib/Lexer/Lexer.cc @@ -15,15 +15,24 @@ int Lexer::gettok() { LastChar = getchar(); } - if (LastChar == '"') { + if (LastChar == '"' || LastChar == '\'') { + char QuoteType = LastChar; StringVal = ""; + LastChar = getchar(); - while (LastChar != '"' && LastChar != EOF) { + + while (LastChar != QuoteType && LastChar != EOF && LastChar != '\n') { StringVal += LastChar; LastChar = getchar(); } - if (LastChar == '"') LastChar = getchar(); - return tok_string_literal; + + if (LastChar == QuoteType) { + LastChar = getchar(); + } else { + fprintf(stderr, "Error: Unterminated string or char literal\n"); + } + + return tok_string_literal; } if (isalpha(LastChar)) { @@ -73,6 +82,7 @@ int Lexer::gettok() { if (IdentifierStr == "LENGTH") return tok_length; if (IdentifierStr == "MID") return tok_mid; if (IdentifierStr == "RIGHT") return tok_right; + if (IdentifierStr == "LEFT") return tok_left; if (IdentifierStr == "LCASE") return tok_lcase; if (IdentifierStr == "UCASE") return tok_ucase; -- cgit v1.3.1-4-g156e