Skip to content

Fix Label Error Messages

Noah Krim requested to merge fix-label-error-messages into main

There was an issue when using unknown instruction mnemonics in certain circumstances, the wrong token would get underlined and there would be only the generic "syntax error" message:

VRV: (parser) syntax error on line 108 of file ../tests/asm/tty_m.s
-->     csrwrong    mtvec, t0
                    ^~~~~

There were specific rules addressing this for when the first operand is a register, but no generic rule. While there could have just been a cascade of extra rules for each circumstance, it would be nice to have something that could catch everything together.

The solution is two-fold, separate symbols and labels into two separate tokens, and use a generic Y_ID /* Empty */ rule to catch situations where a line starts with an unidentifiable string with no trailing :.

This MR contains a couple of other bug fixes and tweaks to the scanner/parser system, as described in the commits.

One choice that could be discussed is the removal of ; as an operator for separating multiple instructions on a single line. This seemed unnecessary and was causing some issues with the new error messaging rules and from moving the line-incrementing into the parser -- a necessary change since some error messages had erroneous line numbers. However, if this is a desired feature, then I can investigate more ways to reintroduce it.

Merge request reports