picrin/src/scan.l

32 lines
467 B
Plaintext
Raw Normal View History

2013-10-11 02:18:37 -04:00
%{
2013-10-11 23:07:28 -04:00
#include <stdlib.h>
2013-10-11 02:18:37 -04:00
#include "picrin.h"
#include "y.tab.h"
struct parser_control {
pic_state *pic;
pic_value value;
};
#define YY_DECL int yylex (struct parser_control *p)
%}
2013-10-12 05:46:41 -04:00
%option nounput
2013-10-11 02:18:37 -04:00
%%
2013-10-12 05:46:11 -04:00
[ \t\n\r] /* skip whitespace */
2013-10-11 02:18:37 -04:00
"(" return tLPAREN;
")" return tRPAREN;
2013-10-11 23:07:28 -04:00
[1-9][0-9]* { yylval.datum = pic_int_value(atoi(yytext)); return tINT; }
2013-10-11 04:36:51 -04:00
[a-z0-9A-Z]+ { yylval.datum = pic_intern_cstr(p->pic, yytext); return tSYMBOL; }
2013-10-11 02:18:37 -04:00
%%
int
yywrap()
{
return 1;
}