Skip to content

Commit

Permalink
Attempt to recover from syntax errors with bison
Browse files Browse the repository at this point in the history
Fixes gbdev#595
  • Loading branch information
Rangi42 committed Jan 21, 2021
1 parent 41d544a commit 4c7678f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/asm/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ line : label T_NEWLINE
| label directive T_NEWLINE
| assignment_directive T_NEWLINE
| line_directive /* Directives that manage newlines themselves */
| error T_NEWLINE /* Continue parsing the next line on a syntax error */
;

/*
Expand Down
17 changes: 16 additions & 1 deletion test/asm/label-macro-arg.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
syntax error, unexpected =
while expanding symbol "VAR_DEF"
error: Assembly aborted (1 errors)!
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(29):
Interpolated symbol "sizeof_.something" does not exist
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25):
Label "sizeof_" created outside of a SECTION
while expanding symbol "VAR_DEF"
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25):
Macro "something" not defined
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26):
'sizeof_' already defined at label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25)
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26):
Macro "something" not defined
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29):
Invalid format spec 'sizeof_'
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29):
Interpolated symbol "something" does not exist
error: Assembly aborted (8 errors)!
2 changes: 2 additions & 0 deletions test/asm/label-macro-arg.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ $8
sizeof__something equals $1
sizeof_@something equals $1
sizeof_#something equals $1
sizeof_.something equals
sizeof_:something equals
19 changes: 18 additions & 1 deletion test/asm/label-macro-arg.simple.err
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ while expanding symbol "VAR_DEF"
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
syntax error
while expanding symbol "VAR_DEF"
error: Assembly aborted (2 errors)!
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(26):
Local label 'sizeof_.something' in main scope
ERROR: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(29):
Interpolated symbol "sizeof_.something" does not exist
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25):
Label "sizeof_" created outside of a SECTION
while expanding symbol "VAR_DEF"
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25):
Macro "something" not defined
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26):
'sizeof_' already defined at label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25)
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26):
Macro "something" not defined
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29):
Invalid format spec 'sizeof_'
ERROR: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29):
Interpolated symbol "something" does not exist
error: Assembly aborted (10 errors)!

0 comments on commit 4c7678f

Please sign in to comment.