40 lines
969 B
Text
40 lines
969 B
Text
%{
|
|
#include <string.h>
|
|
|
|
#include "exprtree.h"
|
|
#include "parser.tab.h"
|
|
%}
|
|
|
|
%option noyywrap
|
|
|
|
%%
|
|
|
|
if return T_IF;
|
|
then return T_THEN;
|
|
else return T_ELSE;
|
|
end return T_END;
|
|
while return T_WHILE;
|
|
do return T_DO;
|
|
[a-zA-Z_][a-zA-Z0-9_]* { strncpy(yylval.ident, yytext, 63);
|
|
yylval.ident[63] = 0;
|
|
return T_IDENT;
|
|
}
|
|
[0-9]+ { yylval.exprtree = make_number(atof(yytext)); return T_NUMBER; }
|
|
[0-9]*\.[0-9]+ { yylval.exprtree = make_number(atof(yytext)); return T_NUMBER; }
|
|
[-,()+*/%=;] return yytext[0];
|
|
#.* ;
|
|
[ \t\n] ;
|
|
|
|
%%
|
|
|
|
void
|
|
scanFromString (char *string)
|
|
{
|
|
yy_scan_string(string);
|
|
}
|
|
|
|
void
|
|
endScanningFromString (void)
|
|
{
|
|
yy_delete_buffer(YY_CURRENT_BUFFER);
|
|
}
|