shithub: spirva

ref: ca99199e72dc182d2801eb591cdf470c707c1e6c
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 */