diff options
[IPL/HW02] Implemented semi-working bison grammar and updated parts of flex regex
1 files changed, 11 insertions, 4 deletions
| -rw-r--r-- | Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l | 15 |
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("<span class=\"bracket\">%s</span>", yytext); } +{LEFTBRACKET} { return LBRACKET; } +{RIGHTBRACKET} { return RBRACKET; } {STR} { printf("<span class=\"string\">%s</span>", yytext); } {NUMBERS} { printf("<span class=\"number\">%s</span>", yytext); } {COMMENT} { printf("<span class=\"comment\">%s</span>", yytext); } @@ -50,7 +52,12 @@ CONST_VAR \+([0-9A-z.?-_])+\+ {GLOBAL_VAR}|{CONST_VAR} { printf("<span class=\"variable\">%s</span>", 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; } + %% |
