shithub: spirva

ref: a0d30aba763788d63e47878756cbd4e5cc6f6798
dir: /spirva.l/

View raw version
%{
#include "sym.h"
#include "y.tab.h"
#include "ops.h"
%}

WS	[ \t]
ANUM	[A-Za-z0-9_]
INT	-?[0-9]+
FLOAT	-?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)

%%

\;.*$ {}

Op[A-Za-z0-9]+ {
	yylval.op = o_lookup(yytext);
	return OP;
}

\%{ANUM}+ {
	yylval.sym = symfind(strdup(yytext));
	return SYM;
}

{INT} {
	yylval.i = atoi(yytext);
	return INT;
}

{FLOAT} {
	yylval.f = atof(yytext);
	return FLOAT;
}

{ANUM}+ {
	yylval.str = strdup(yytext);
	return STR;
}

\" { return '"'; }

=|\n { return yytext[0]; }

{WS}	{ }

%%
/* code */