> 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:
parent
7ccd5d8e83
commit
a718c5c723
4 changed files with 9 additions and 2 deletions
|
@ -1,11 +1,13 @@
|
||||||
%{
|
%{
|
||||||
|
#include <isa.h>
|
||||||
#include <addrexp.h>
|
#include <addrexp.h>
|
||||||
|
static bool success = false;
|
||||||
%}
|
%}
|
||||||
%option noyywrap
|
%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[xX][0-9a-fA-F]+ { yylval = strtoul(yytext, NULL, 16); return HEX_NUMBER; }
|
||||||
[0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; }
|
[0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; }
|
||||||
[+\-*/()] { return *yytext; }
|
[+\-*/()] { return *yytext; }
|
||||||
|
|
|
@ -28,6 +28,7 @@ input
|
||||||
|
|
||||||
expression
|
expression
|
||||||
: number { $$ = $1; }
|
: number { $$ = $1; }
|
||||||
|
| register { $$ = $1; }
|
||||||
| expression '+' expression { $$ = $1 + $3; }
|
| expression '+' expression { $$ = $1 + $3; }
|
||||||
| expression '-' expression { $$ = $1 - $3; }
|
| expression '-' expression { $$ = $1 - $3; }
|
||||||
| expression '*' expression { $$ = $1 * $3; }
|
| expression '*' expression { $$ = $1 * $3; }
|
||||||
|
@ -45,4 +46,7 @@ number
|
||||||
: NUMBER
|
: NUMBER
|
||||||
| HEX_NUMBER
|
| HEX_NUMBER
|
||||||
|
|
||||||
|
register
|
||||||
|
: REGISTER
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
|
// TODO: Cache expression evalutation result in ExprResult
|
||||||
enum ExprType {
|
enum ExprType {
|
||||||
EXPR_TYPE_MEM_ADDR,
|
EXPR_TYPE_MEM_ADDR,
|
||||||
EXPR_TYPE_REG
|
EXPR_TYPE_REG
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "sys/types.h"
|
#include "sys/types.h"
|
||||||
#include "unistd.h"
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
Loading…
Reference in a new issue