Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 200 forks source link

recoveryEnabled does not work with EmbeddedActionsParser #1909

Closed nupthale closed 1 year ago

nupthale commented 1 year ago

i have 2 parser, an EmbeddedActionsParser and a CstParser, both open recoveryEnabled;

const lexingResult = Lexer.tokenize('list().filter().CurrentValue');
parser.input = lexingResult.tokens;

const tree = parser.entry();
console.info(tree);

expect(lexingResult.errors.length).toBe(0);
// list().filter().CurrentValue will cause error
expect(parser.errors.length).toBe(1);

When encounter error: CstParser - console.log(tree)

print the recovered tree

EmbeddedActionsParser - console.log(tree)

print undefined

Does EmbeddedActionsParser support recovery? What should i do to make the recovery work?

nupthale commented 1 year ago

My error hits 287- 294 line, EmbeddedActionsParser.outputCst is false, so it just throw an error, but CstParser has a partialCstResult, I guess this cause the difference:

image

Should code in 297 line changed to call recoveryValueFunc instead of just throw Error ?

bd82 commented 1 year ago

Hello @nupthale

I am unfortunately quite rusty in regards to the EmbeddedActionsParser + error recovery as I do not think I have used a none CST parser in years...

Could you take a look at the test examples for your scenario and see if they help clear things up

nupthale commented 1 year ago

ok, thanks