From 5eeb355805e0d5d91981dbe7eacb078f41da0437 Mon Sep 17 00:00:00 2001 From: Felix Perktold Date: Sat, 20 Dec 2025 21:59:28 +0100 Subject: init commit --- lisp.l | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lisp.l (limited to 'lisp.l') diff --git a/lisp.l b/lisp.l new file mode 100644 index 0000000..329fc0f --- /dev/null +++ b/lisp.l @@ -0,0 +1,25 @@ +%{ +#include +#include "lisp.h" +#include "lisp.tab.h" + +int tcnt = 0; +%} + +%% +[+-]?([0-9]+|([0-9]*\.[0-9]+))([eE][-+]?[0-9]+)? { + yylval.dval = atof(yytext); + printf("%d: NUMBER: %f\n", ++tcnt, yylval.dval); + return NUMBER; + } +[ \t\n]+ { printf("%d: WHITESPACE\n", tcnt); return WHITESPACE; } +"(" { printf("%d: LPAREN\n", ++tcnt); return LPAREN; } +")" { printf("%d: RPAREN\n", ++tcnt); return RPAREN; } +"\." { printf("%d: DOT\n", ++tcnt); return DOT; } +"+" { printf("%d: PLUS\n", ++tcnt); return PLUS; } +"-" { printf("%d: MINUS\n", ++tcnt); return MINUS; } +"*" { printf("%d: MULT\n", ++tcnt); return MULT; } +"/" { printf("%d: DIV\n", ++tcnt); return DIV; } +\".*\" { printf("%d: STRING\n", ++tcnt); return STRING; } +. ; // do nothing +%% -- cgit v1.2.3