Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Implementation of Programming Languages / Transpiler / frontend / commonlisp2transpilerstr.l
diff options
context:
space:
mode:
diff --git a/Year 2/Implementation of Programming Languages/Transpiler/frontend/commonlisp2transpilerstr.l b/Year 2/Implementation of Programming Languages/Transpiler/frontend/commonlisp2transpilerstr.l
new file mode 100644
index 0000000..d2bffba
--- /dev/null
+++ b/Year 2/Implementation of Programming Languages/Transpiler/frontend/commonlisp2transpilerstr.l
@@ -0,0 +1,30 @@
+%{
+#include "../build/commonlisp2transpilerstr.tab.h"
+%}
+
+DIGIT [0-9]
+LEFTBRACKET \(
+RIGHTBRACKET \)
+
+/* STR \"([^\"]|\\\")*([^\\]|\\\\)\" */
+INTEGER (\+|-)?{DIGIT}
+FLOAT {INTEGER}(\.{DIGIT}+(e{DIGIT}+|d{DIGIT}+|e-{DIGIT}+)?|\/{DIGIT}+)?
+
+COMMENT ;.*$
+
+FUNCTION "+ "|"- "|"* "|\/|defun|defvar|if|=|>|>=|<|<=
+
+%%
+
+{LEFTBRACKET} { return LBRACKET; }
+{RIGHTBRACKET} { return RBRACKET; }
+/* {STR} { yylval = strdup(yytext); return STR; } */
+{INTEGER} { yylval = strdup(yytext); return INTEGER; }
+{FLOAT} { yylval = strdup(yytext); return FLOAT;}
+
+{FUNCTION} { yylval = strdup(yytext); return FUNCTION; }
+
+ /* 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!-'*-@]+|" "|\t { yylval = strdup(yytext); return NAME; }
+
+%%