diff options
| author | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2025-12-20 21:59:28 +0100 |
|---|---|---|
| committer | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2025-12-20 21:59:28 +0100 |
| commit | 5eeb355805e0d5d91981dbe7eacb078f41da0437 (patch) | |
| tree | d4d2a76e7988cf63aa9438d2b42d0a4a4656ee42 /lisp.l | |
init commit
Diffstat (limited to 'lisp.l')
| -rw-r--r-- | lisp.l | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -0,0 +1,25 @@ +%{ +#include <stdlib.h> +#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 +%% |
