2024-01-12 15:23:43 +00:00
|
|
|
%{
|
2024-01-15 09:03:16 +00:00
|
|
|
#include <isa.h>
|
2024-01-12 15:23:43 +00:00
|
|
|
#include <addrexp.h>
|
2024-01-15 09:03:16 +00:00
|
|
|
static bool success = false;
|
2024-01-15 15:27:00 +00:00
|
|
|
void yyerror(word_t *result, const char *err);
|
2024-01-12 15:23:43 +00:00
|
|
|
%}
|
|
|
|
%option noyywrap
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
2024-01-15 15:31:50 +00:00
|
|
|
0[xX][0-9a-fA-F]+ { yylval = strtoul(yytext, NULL, 16); return HEX_NUMBER; }
|
2024-01-15 15:32:05 +00:00
|
|
|
[0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; }
|
2024-01-15 15:04:10 +00:00
|
|
|
$[a-zA-Z]{2,3} {
|
|
|
|
yylval = isa_reg_str2val(yytext + 1, &success);
|
|
|
|
if(!success) {
|
2024-01-15 15:27:00 +00:00
|
|
|
yyerror(NULL, "Failed to convert reg to value");
|
2024-01-15 15:04:10 +00:00
|
|
|
return YYerror;
|
|
|
|
}
|
|
|
|
}
|
2024-01-12 15:23:43 +00:00
|
|
|
[+\-*/()] { return *yytext; }
|
|
|
|
[ \t] { }
|
2024-01-15 14:50:16 +00:00
|
|
|
. { printf("Unexpected character: %s\n", yytext); return YYerror; }
|
2024-01-12 15:23:43 +00:00
|
|
|
%%
|