aboutsummaryrefslogtreecommitdiff
path: root/asm.peg
diff options
context:
space:
mode:
Diffstat (limited to 'asm.peg')
-rw-r--r--asm.peg13
1 files changed, 11 insertions, 2 deletions
diff --git a/asm.peg b/asm.peg
index 3e396c3..a1d517f 100644
--- a/asm.peg
+++ b/asm.peg
@@ -45,7 +45,6 @@ instr =
| i:sub { $$ = i; }
| i:xor { $$ = i; }
-
jmp =
"jmp" ws t:ident
{ $$.jmp = (Jmp){ .kind = ASM_JMP, .target=t.ident.name } ; }
@@ -241,7 +240,17 @@ r64 =
| "%r14" ![lwb] { $$ = REG(ASM_R14); }
| "%r15" ![lwb] { $$ = REG(ASM_R15); }
-string = '"' <(('\\\"')|( !'"' .))*> '"' { $$.string = decodestring(yytext); }
+# We disallow newlines in our strings, it is simpler for error messages.
+string = '"' <(string-escape | ( ! '\n' ! '\\' !'"' .))*> '"'
+ { $$.string = decodestring(yytext); }
+
+string-escape = '\\' (
+ '\\'
+ | '"'
+ | [nrt]
+ | 'x' [0-9A-Fa-f]+
+ | [0-7][0-7][0-7]
+)
ident =
<[._a-zA-Z][._a-zA-Z0-9]*>