ysyx-workbench/nemu/src/monitor/sdb/addrexp.l
tracer-ysyx 1ab8e91cc2 > compile NEMU
ysyx_22040000 李心杨
Linux calcite 6.1.71 #1-NixOS SMP PREEMPT_DYNAMIC Fri Jan  5 14:18:41 UTC 2024 x86_64 GNU/Linux
 23:34:10  up 2 days 12:29,  2 users,  load average: 0.47, 0.39, 0.37
2024-01-15 23:34:10 +08:00

25 lines
659 B
Text

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