blob: bbaadb8dfbb0b4c857aa06ab97e185938f24d75d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}
|