Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Implementation of Programming Languages / Homework 02 / commonlisp2html.l
diff options
context:
space:
mode:
Commit9b9cac4c0037b3c397842143f85c08e13d2bc91e (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-11-16 21:27:36 +0200
Committer
 Syndamia <kamen@syndamia.com>
2022-11-16 21:27:36 +0200
Files94d8bc3231a0e9657649f8557071e487cac79b76 /Year 2/Implementation of Programming Languages/Homework 02/commonlisp2html.l
uni-projects-9b9cac4c0037b3c397842143f85c08e13d2bc91e.tar
uni-projects-9b9cac4c0037b3c397842143f85c08e13d2bc91e.tar.gz
uni-projects-9b9cac4c0037b3c397842143f85c08e13d2bc91e.zip
Parenta2f93b2b17a2a101c849636ea10f31058cef6660 (diff)
[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.l15
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; }
+
%%