shithub: spirva

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