rgbds: "Syntax error" message is way too obtuse

issotm@link-panda tmp.UjOR1nmUvy% rgbasm -V
rgbasm v0.3.8-66-ge33e6e2
issotm@link-panda tmp.UjOR1nmUvy% cat test.asm   
if A
endc
issotm@link-panda tmp.UjOR1nmUvy% rgbasm test.asm
ERROR: test.asm(1):
    syntax error
error: Assembly aborted (1 errors)!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (23 by maintainers)

Commits related to this issue

Most upvoted comments

This is the Bison documentation on error reporting.

https://www.gnu.org/software/bison/manual/html_node/Error-Reporting.html

If we put %define parse.error verbose in “asmy.y”, then it will print the following error: syntax error, unexpected T_TOKEN_A

You can also name the tokens like this: %token T_TOKEN_A "Reg A"

Then it prints the following: syntax error, unexpected Reg A

This would make things a little better. We need to ditch yacc if we want really nice errors.

Perhaps the handler for syntax error could be modified so that the current line is printed, together with a row of ^ under the token that doesn’t match any rule?