diff options
author | Julian T <julian@jtle.dk> | 2019-10-24 07:51:51 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2019-10-24 07:53:12 +0200 |
commit | ad2bc056ae684f8de57f2ff880e51440d07ee04a (patch) | |
tree | 01b81c1da9e12da3ae8d559c6de032bb41fffe49 /sem1/osc/mm11/regn/regn.l | |
parent | 7c77ee39d5e3a41d5d74d32a3c3388f92998ae32 (diff) |
Simple calculator assignment
Diffstat (limited to 'sem1/osc/mm11/regn/regn.l')
-rw-r--r-- | sem1/osc/mm11/regn/regn.l | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sem1/osc/mm11/regn/regn.l b/sem1/osc/mm11/regn/regn.l new file mode 100644 index 0000000..bbaadb8 --- /dev/null +++ b/sem1/osc/mm11/regn/regn.l @@ -0,0 +1,40 @@ +%{ +#include <math.h> +#include <string.h> +#include "symtab.h" +#include "regn.tab.h" +%} + +realtal ([0-9]+|([0-9]*\.[0-9]+))([eE][-+]?[0-9]+)? +var_begin let +op_log log +op_exp exp +op_sqrt sqrt +var [A-Za-z][A-Za-z0-9]* + +%% +{realtal} {yylval.dval = atof(yytext); + return TAL;} +{var_begin} {return VAR_BEGIN;} +{op_log} {return LOG;} +{op_exp} {return EXP;} +{op_sqrt} {return SQRT;} + +{var} {yylval.string = strdup(yytext); return VAR;} + +[ \t] ; + + +'$' {return 0;} + +\n|. {return yytext[0];} + +%% + +void init_sym() +{ + int i; + for (i = 0; i < HASHSIZE; i++) + symbolarray[i] = NULL; +} + |