Re:Don't Panic! Better, Fewer, Syntax Errors for LR Parsers
by choeger on Thursday July 16, 2020 @03:57AM
(#23856816)
You can always start from a different place even with an LR(k) parser. You just need to make sure that your starting point is sensible.
Re:Don't Panic! Better, Fewer, Syntax Errors for LR Parsers
by userbinator on Wednesday July 15, 2020 @08:09PM
(#23854095)
This is fine of course, but what if we want to parse, say, only an expression, only a function body, etc?
...and this is the beauty of recursive descent: you can call the appropriate method directly to parse that part of the grammar.
I feel most parsing APIs tend to expose a single method, something like:
... which is kind of a limited API to do the things I ask about above.With a more flexible API, an structure aware editor [1] could keep different areas of the buffer separated, and know if the user is typing a function body, a variable definition, etc, and only parse that part w/o breaking the rest of the parser progress (is this a good idea? I think so but I don't think most editors work like this, so maybe not :-)
--
An area of parser APIs that I've recently seen trouble with is lack of metadata on the productions. I'd like to be able to do something like:
... or something like that. This is very useful while error reporting, for instance. I was trying to find a parser for RDF Turtle that would do this, but couldn't find any!1: https://en.wikipedia.org/wiki/Structure_editor