mna / pigeon

Command pigeon generates parsers in Go from a PEG grammar.
BSD 3-Clause "New" or "Revised" License
845 stars 67 forks source link

How to get a partial AST for a partial input? #154

Closed jadetang closed 3 months ago

jadetang commented 3 months ago

Hello, we are using this tool, it works well for our project. Now I want to implement the autocomplete in the LSP where most of the time the input is incomplete. Is it possible to get a partial AST? I read the error label and recovery document and examples, but I am not sure that can work for me, because I don't need to continue parsing in case something goes wrong. Any suggestion is appreciated.

breml commented 3 months ago

Hi @jadetang Me personally, I have never tried to build a parser with pigeon, that works on partial AST. That being said, two ideas come to mind:

But since I have never done such a thing, I might not be of a lot of help.

jadetang commented 3 months ago

@breml thanks, I think the second approach sounds promising. I will try that.