aboutsummaryrefslogtreecommitdiff
path: root/asm.peg
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-09 22:09:05 +1300
committerAndrew Chambers <[email protected]>2021-10-09 22:09:05 +1300
commita3edd52b53b236a2b88049e634981e8dc7b0bc4d (patch)
tree85c7ea213218de4005eaebc698fd8e6e8467a41a /asm.peg
parentc726740a3882ebdc85c0d06c922dfaf5c6532c69 (diff)
Simplify.
Diffstat (limited to 'asm.peg')
-rw-r--r--asm.peg20
1 files changed, 10 insertions, 10 deletions
diff --git a/asm.peg b/asm.peg
index 4b1828e..568510e 100644
--- a/asm.peg
+++ b/asm.peg
@@ -14,7 +14,7 @@ stmt =
directive =
"glob" 'o'? 'l' ws i:ident
- { $$.globl = (Globl){.kind = ASM_DIR_GLOBL, .name = i.ident.name }; }
+ { $$.globl = (Globl){.kind = ASM_DIR_GLOBL, .name = i.charptr }; }
| "ascii" <'z'?> ws s:string
{ s.kind = *yytext ? ASM_DIR_ASCII : ASM_DIR_ASCIIZ ; $$ = s; }
| "data"
@@ -22,9 +22,9 @@ directive =
| "text"
{ $$.kind = ASM_DIR_TEXT; }
| "balign" ws n:number
- { $$.balign = (Balign){.kind = ASM_DIR_BALIGN, .align = n.number.v }; }
+ { $$.balign = (Balign){.kind = ASM_DIR_BALIGN, .align = n.i64 }; }
| "byte" ws n:number
- { $$.byte = (Byte){.kind = ASM_DIR_BYTE, .b = (uint8_t)n.number.v }; }
+ { $$.byte = (Byte){.kind = ASM_DIR_BYTE, .b = (uint8_t)n.i64 }; }
| sd:section-directive { $$ = sd; }
section-directive =
@@ -45,7 +45,7 @@ section-type =
label =
i:ident ':'
- { $$.label = (Label){.kind = ASM_LABEL, .name = i.ident.name}; }
+ { $$.label = (Label){.kind = ASM_LABEL, .name = i.charptr}; }
instr =
# XXX Order the rules by frequency to get better lookup time.
@@ -79,11 +79,11 @@ pop =
call =
"call" 'q'? ws t:ident
- { $$.call = (Call){ .kind = ASM_CALL, .target=t.ident.name } ; }
+ { $$.call = (Call){ .kind = ASM_CALL, .target=t.charptr } ; }
jmp =
"jmp" ws t:ident
- { $$.jmp = (Jmp){ .kind = ASM_JMP, .target=t.ident.name } ; }
+ { $$.jmp = (Jmp){ .kind = ASM_JMP, .target=t.charptr } ; }
lea =
"lea" (
@@ -156,8 +156,8 @@ m =
{ $$.memarg = (Memarg){ .kind = ASM_MEMARG, .c = 0, .l = NULL, .reg = r.kind }; }
| <'-'?[0-9]+> ws? '(' ws? r:r64-or-rip ws? ')'
{ $$.memarg = (Memarg){ .kind = ASM_MEMARG, .c = strtoll(yytext, NULL, 10), .l = NULL, .reg = r.kind }; }
- | i:ident ws? '(' ws? r:r64-or-rip ws? ')'
- { $$.memarg = (Memarg){ .kind = ASM_MEMARG, .c = 0, .l = i.ident.name, .reg = r.kind }; }
+ | i:ident ws? '(' ws? r:r64-or-rip ws? ')'
+ { $$.memarg = (Memarg){ .kind = ASM_MEMARG, .c = 0, .l = i.charptr, .reg = r.kind }; }
imm8 = i:imm { i.imm.nbytes = 1; $$ = i; }
imm16 = i:imm { i.imm.nbytes = 2; $$ = i; }
@@ -259,8 +259,8 @@ string-escape = '\\' (
ident =
<[._a-zA-Z][._a-zA-Z0-9]*>
- { $$.ident = (Ident){ .kind = ASM_IDENT, .name = xstrdup(yytext) }; }
+ { $$.charptr = xstrdup(yytext); }
number =
<'-'?[0-9]+>
- { $$.number = (Number){ .kind = ASM_NUMBER, .v = strtoll(yytext, NULL, 10) }; }
+ { $$.i64 = strtoll(yytext, NULL, 10); }