> 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
 17:03:16  up 2 days  5:58,  2 users,  load average: 0.87, 0.69, 0.71
This commit is contained in:
tracer-ysyx 2024-01-15 17:03:16 +08:00 committed by xinyangli
parent 7ccd5d8e83
commit a718c5c723
4 changed files with 9 additions and 2 deletions

View file

@ -1,11 +1,13 @@
%{
#include <isa.h>
#include <addrexp.h>
static bool success = false;
%}
%option noyywrap
%%
$[a-zA-Z] { }
$?[a-zA-Z]{2,3} { yylval = isa_reg_str2val(yytext, &success); if(!success) { return YYerror; } }
0[xX][0-9a-fA-F]+ { yylval = strtoul(yytext, NULL, 16); return HEX_NUMBER; }
[0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; }
[+\-*/()] { return *yytext; }

View file

@ -28,6 +28,7 @@ input
expression
: number { $$ = $1; }
| register { $$ = $1; }
| expression '+' expression { $$ = $1 + $3; }
| expression '-' expression { $$ = $1 - $3; }
| expression '*' expression { $$ = $1 * $3; }
@ -45,4 +46,7 @@ number
: NUMBER
| HEX_NUMBER
register
: REGISTER
%%

View file

@ -18,6 +18,7 @@
#include <common.h>
// TODO: Cache expression evalutation result in ExprResult
enum ExprType {
EXPR_TYPE_MEM_ADDR,
EXPR_TYPE_REG

View file

@ -1,5 +1,5 @@
#include "sys/types.h"
#include "unistd.h"
#include <unistd.h>
#include <assert.h>
#include <check.h>
#include <math.h>