Open kolipakakondal opened 6 years ago
Hi Kondal,
thanks for your request. That sounds like an interesting feature. The crucial part is probably the recovery strategy itself, but we might be able to reuse the ideas that you adopt already. This feature is something we might look into in the future. I cannot promise any date, though, as this is not a priority in our current plans.
If by any chance you are able to contribute improvements to our parser, we are happy to help in integrating them and help you resolve problems. Note that our code is a fork of the Nashorn
parser, so they are pretty similar still.
Best, Christian
Thanks for quick response. I'll analyze and see how much I can contribute for this.
https://github.com/graalvm/graaljs/blob/21177b89d21e8082607d688567a55f020d91626d/graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java#L1062
I'm planning to migrate from beaver JS parser to GraalJS parser for implementing javascript grammar in the eclipse editor. But I realised it doesn't have the implementation for error recovery strategies.
For example:
Math.
If I give above js code to the graalJS parser it just returns the syntax error the moment it found the unexpected token - which is completely fine, but it doesn't recover from the error and build the AST model https://github.com/graalvm/graaljs/blob/master/graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java#L1062
FunctionNode null returned here https://github.com/graalvm/graaljs/blob/master/graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java#L378
Being the consumer - I can't build the auto proposals on the "Math." functions since the AST model itself is missing.
For example, here is the implementation for beaver parser recovery https://github.com/enebo/beaver/blob/master/beaver-rt/src/main/java/beaver/Parser.java#L576