Create interp.l
This commit is contained in:
parent
40bee9ebbc
commit
50d5fc9a3a
1 changed files with 41 additions and 0 deletions
41
interp.l
Normal file
41
interp.l
Normal file
|
@ -0,0 +1,41 @@
|
|||
%option yylineno
|
||||
%{
|
||||
#include "y.tab.h"
|
||||
int yycharno = 0;
|
||||
%}
|
||||
|
||||
|
||||
str \"([^\n]|\\\")+\"
|
||||
ws [ \t]+
|
||||
newline [\n]
|
||||
alpha [a-zA-Z]
|
||||
dig [0-9]
|
||||
float1 {dig}+[.]{dig}+
|
||||
int {dig}+
|
||||
float2 {float1}[eE][-+]?{dig}+
|
||||
float {float1}|{float2}
|
||||
number {int}|{float}
|
||||
var ([_]|{alpha})([_]|{alpha}|{dig})*
|
||||
%%
|
||||
|
||||
{newline} {yylineno = yylineno + 1;return T_NEWLINE;}
|
||||
{ws} {yycharno = yycharno + yyleng;}
|
||||
{var} {yylval.strVal = strdup(yytext);
|
||||
yycharno = yycharno + yyleng;
|
||||
printf("yyval.strVal = %s",yylval.strVal);
|
||||
return T_VAR;}
|
||||
{number} {yylval.floatVal = atof(yytext);
|
||||
yycharno = yycharno + yyleng;
|
||||
return T_NUM;}
|
||||
"-" {yycharno += 1;return T_SUB;}
|
||||
"+" {yycharno += 1;return T_ADD;}
|
||||
"*" {yycharno += 1;return T_MUL;}
|
||||
"/" {yycharno += 1; return T_DIV;}
|
||||
"(" {yycharno += 1; return T_LPATH;}
|
||||
")" {yycharno += 1; return T_RPATH;}
|
||||
. {yycharno += 1;}
|
||||
|
||||
%%
|
||||
int yywrap(void){
|
||||
return 1;
|
||||
}
|
Loading…
Reference in a new issue