John Leuner wrote:
> [snip]
> My own cl-peg parser is batch based and I haven't thought much about ways
> to efficiently do incremental parsing. The whole parsing model is also
> wrong for something like interactive editing, because the parser greedily
> builds a parse tree and never tries to do error correction or "fill-in"
> something missing to achieve a full parse.

Good point! A parser without error correction isn't useful for editors no matter how "incremental" it is. Truth is, a parser without error correction isn't useful for most applications. I'd give solid error correction in PEG higher priority than all other extension I've seen proposed.

The damage/repair scanner scheme used in Eclipse simply has a list of scanners (which you can think of as parse rules), each of which in author-specified order is given a chance to match the text at a given position. First match wins. If all scanners fail to match, the region including the current position is assigned an unknown type, and the scan begins at the next character. Error correction falls out, in the sense that as soon as a scanner successfully matches and creates a partition, subsequent text is much more likely to be matched.

If this scheme were applied to a Lisp editor, it wouldn't be able to balance parenthesis. However, I have successfully used the partitions output by the scan as a tokenizing pass for a recursive descent parse of several languages, including XML and RELAX NG (compact syntax). In terms of error recovery, it is more important in an editor to recognize all tokens in a language than it is the full parse tree. But it is important to _try_ to fit a parse tree to the tokens recognized, as this enables syntax-derived distinctions such as identifiers in the function name position in Lisp. This separation of concerns seems rather un-PEG-like.

(subvert-the-dominant-paradigm.net is an interesting domain name ;)

Bob


_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to