50 lines
1.4 KiB
Text
50 lines
1.4 KiB
Text
%{
|
|
#include <stdio.h>
|
|
#include "types.h"
|
|
#include "code_defs.h"
|
|
#include "parser.h"
|
|
#include "y.tab.h"
|
|
|
|
%}
|
|
|
|
%%
|
|
|
|
|
|
":vec" return VEC;
|
|
|
|
[:][_a-zA-Z]+ {
|
|
yylval.str = yytext+1;
|
|
return TYPE_U;
|
|
}
|
|
|
|
"if" return IF;
|
|
"else" return ELSE;
|
|
"while" return WHILE;
|
|
"fn" return FN;
|
|
"var" return VAR;
|
|
"let" return LET;
|
|
"block" return BLOCK;
|
|
"is" return IS;
|
|
|
|
|
|
[-+*/%<=>!a-zA-Z]+ {
|
|
yylval.str = yytext;
|
|
return G_IDENT;
|
|
}
|
|
|
|
[0-9]+ {
|
|
yylval.st = make_iconst(atoi(yytext));
|
|
return CST;
|
|
}
|
|
|
|
[();] return *yytext;
|
|
|
|
[ \t\n]+ ;
|
|
|
|
. { yyerror("Invalid character"); }
|
|
|
|
%%
|
|
|
|
int yywrap(){
|
|
return 1;
|
|
}
|