From fa6e0588dbad8fb8fc517e94e06490080718b90c Mon Sep 17 00:00:00 2001 From: Fredrik Robertsen Date: Sat, 14 Feb 2026 13:42:58 +0100 Subject: [PATCH] ps2: remove comments from scanner.l --- ps2/src/scanner.l | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/ps2/src/scanner.l b/ps2/src/scanner.l index a63475e..d932e1a 100644 --- a/ps2/src/scanner.l +++ b/ps2/src/scanner.l @@ -23,35 +23,17 @@ BINDING ^[a-zA-Z]+[a-zA-Z0-9_]*$ {WHITESPACE}+ { /* Eliminate whitespace */ } {QUOTED} { return STRING_TOKEN; } -/* - * TODO: - * - * Add the rest of the translation rules here. - * See the lexical structure definition of the modified VSL in PS2. - * Also see the `%token` directives in parser.y for all symbolic names that can be returned - e.g. FUNC, IF, IDENTIFIER_TOKEN. - * - * Hint to get you started: - * The WHITESPACE regex defined above is not quite finished. Finish it. - * The scanner returns STRING_TOKEN when matching the QUOTED regex above. - * When should the scanner return a NUMBER_TOKEN, IDENTIFIER_TOKEN, etc? - * In which specific scenarios should the scanner return keyword tokens like FUNC or PRINT? - * - * For operators, which are all a single char or two chars, we let each char be a separate token. - * This is achieved by using the "catch-all" rule at the very bottom of this file. - */ - - /* All other chars get returned as single char tokens */ -{func} { return FUNC; } -{var} { return VAR; } -{return} { return RETURN; } -{print} { return PRINT; } -{println} { return PRINTLN; } -{if} { return IF; } -{else} { return ELSE; } -{while} { return WHILE; } -{break} { return BREAK; } -{and} { return AND; } -{or} { return OR; } +func { return FUNC; } +var { return VAR; } +return { return RETURN; } +print { return PRINT; } +println { return PRINTLN; } +if { return IF; } +else { return ELSE; } +while { return WHILE; } +break { return BREAK; } +and { return AND; } +or { return OR; } {NUMERIC} { return NUMBER_TOKEN; } {BINDING} { return IDENTIFIER_TOKEN; } . { return yytext[0]; }