Produce expectations after parser error

23 views
Skip to first unread message

Roded Bahat

unread,
Jan 14, 2013, 8:49:05 AM1/14/13
to pe...@googlegroups.com
Hi,
I'm using PEG.js for building an editor whose requirements are among others, validation and auto-completion.
As suggested by otac0n (here), I managed validation by catching parser errors and building an AST which contains errors as nodes - this way not just the first error is produced.
At this point, auto-completion works by turning off the parser's error handling, with the limitation that the parser is not able to provide suggestions for code which is after a parse error.
Is there a workaround to this problem I'm missing? 
My first thought was to try to provide error nodes with parse-able code which will be replaced with the error code via a 2nd parsing pass - but this has its issues...
If anyone managed this somehow or has any ideas, it would be much appreciated.
Thanks a lot,
Roded

Roded Bahat

unread,
Jan 18, 2013, 3:58:45 AM1/18/13
to pe...@googlegroups.com
My final solution was to parse the last statement for creating explicit suggestions while traversing the ast for those implicit (tag closes and such).
Thanks for the work on PEGjs.
Reply all
Reply to author
Forward
0 new messages