aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-12 17:43:48 +1300
committerAndrew Chambers <[email protected]>2021-10-12 17:43:48 +1300
commitb4e630f77661aae9e030e9dabead9ba5b0370368 (patch)
treecadf6306d3b30b7494312bdfb1ff330463a68295
parent71ba2cdd14a4462829a2e5d859ea776b934d4322 (diff)
Add hex numbers.
-rw-r--r--asm.peg10
1 files changed, 8 insertions, 2 deletions
diff --git a/asm.peg b/asm.peg
index 4ee8d78..8a36802 100644
--- a/asm.peg
+++ b/asm.peg
@@ -554,7 +554,13 @@ ident =
{ $$.charptr = xstrdup(yytext); }
number =
- <'-'? ws? [0-9]+>
- { $$.i64 = strtoll(yytext, NULL, 10); }
+ '-' ws? n:unsigned-number
+ { $$.i64 = -n.i64; }
+ | n:unsigned-number
+ { $$.i64 = n.i64; }
+
+unsigned-number =
+ '0' [xX] <[0-9a-fA-F]+>
+ { $$.i64 = (int64_t)strtoull(yytext, NULL, 16); }
| <[0-9]+>
{ $$.i64 = (int64_t)strtoull(yytext, NULL, 10); }