From 9b9cac4c0037b3c397842143f85c08e13d2bc91e Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 16 Nov 2022 21:27:36 +0200 Subject: [IPL/HW02] Implemented semi-working bison grammar and updated parts of flex regex --- .../Homework 02/commonlisp2html.l | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l') diff --git a/Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l b/Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l index 46447b1..01b69d5 100644 --- a/Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l +++ b/Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l @@ -1,9 +1,10 @@ %{ - +#include "codefold.tab.h" %} DIGIT [0-9] -BRACKET \(|\) +LEFTBRACKET \( +RIGHTBRACKET \) STR \"([^\"]|\\\")*([^\\]|\\\\)\" NUMBERS [^A-z](\+|-)?{DIGIT}+(\.{DIGIT}+(e{DIGIT}+|d{DIGIT}+|e-{DIGIT}+)?|\/{DIGIT}+)? @@ -36,7 +37,8 @@ CONST_VAR \+([0-9A-z.?-_])+\+ %% -{BRACKET} { printf("%s", yytext); } +{LEFTBRACKET} { return LBRACKET; } +{RIGHTBRACKET} { return RBRACKET; } {STR} { printf("%s", yytext); } {NUMBERS} { printf("%s", yytext); } {COMMENT} { printf("%s", yytext); } @@ -50,7 +52,12 @@ CONST_VAR \+([0-9A-z.?-_])+\+ {GLOBAL_VAR}|{CONST_VAR} { printf("%s", yytext); } + /* " " { return SPACE; } */ +\t { return TAB; } +\n { return NEWLINE; } + /* flex catches the longest possibility, so if some variable name contains a known word (function, macro, etc.), this will prevent it from highlighting */ -[A-z]+ { printf("%s", yytext); } +[A-z]+ { yylval = strdup(yytext); return OTHER; } + %% -- cgit v1.3.1-26-gb76a