News for hackers. Stuff that matters.
Re:Don't Panic! Better, Fewer, Syntax Errors for LR Parsers by cornstalks on Wednesday July 15, 2020 @04:33PM (#23851309)
I've thought about doing something like this when using matching/parsing with derivatives[1]. When the graph collapses to ∅ (indicating an error), you could back up one character, then ask the graph "what are the next valid token(s)?" This would give you a list of possible things to insert (`,` and `=` for the example given in the article, though naively implementing this would also suggest stuff like `;`).

But this article takes it a step further and suggests deletions, too. That's actually really cool. My biggest gripe with people making DSLs is the crappy error messages you get when you have a syntax error (GCL, I'm looking at you). Hopefully research like this will improve the lives of those of us that have to use DSLs.

[1]: http://matt.might.net/articles/parsing-with-derivatives/

There are no comments on this comment yet.