ohmjs / ohm

A library and language for building parsers, interpreters, compilers, etc.
MIT License
5.01k stars 217 forks source link

Partially parse grammar #487

Open cristiano-belloni opened 3 months ago

cristiano-belloni commented 3 months ago

Hi, I have a grammar that works well but I noticed that, if a match doesn't succeed, there is no way to get the AST. I see that in the editor it is possible to see the "partial" AST even if the parsing failed; for example, with the default grammar, if I type 1 * 2 *, which fails, I still get the viz to show 1 * 2. Do you do that just parsing whatever is before the error or is there a way to get a "partial AST of a grammar until it's not possible to parse anymore?