alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

Error message line numbers / better parse error reporting #12

Closed daveyarwood closed 7 years ago

daveyarwood commented 7 years ago

Moved from https://github.com/alda-lang/alda/issues/150.

Quoting myself:

This is a consequence of the recent changes I made to the parser. I made it so that parsing happens in several stages (some of which can be parallelized for better performance). An unfortunate consequence is that since we're not parsing the whole file in one pass, we lose the ability to have accurate line numbers, and the error reporting is a bit more vague because it sometimes deals with intermediate data.

I'd happily accept a PR if anyone is interested in tackling this. I think one way to fix it would be a separate "error finding" step that runs only in the case of a parse error, and uses a single grammar in order to give you a proper line number and more accurate error message. The grammar could be a dumbed-down version of the grammar we had before, maybe. We might not even need a grammar for this at all, just a series of regular expressions to catch common errors and report them if normal parsing fails.

daveyarwood commented 7 years ago

37 fixes this.