Ambigious path, how to solve this :)
See original GitHub issueThe problem I have a parameterlist like
void doSomething(boolean a, boolean b, boolean... list);
Only the last element can be this … which means it resolves to an array and the whole function cant ake infinitive booleans at the end. The problem is that everything looks the same only the last one is different, this is pretty hard to parse.
Ambiguous alternatives: <1 ,2> in <OR> inside <formalParameterList> Rule, <Identifier, ‘.’, Identifier, ‘[’> may appears as a prefix path in all these alternatives. To Resolve this, try one of of the following: 1. Refactor your grammar to be LL(K) for the current value of k (by default k=5) 2. Increase the value of K for your grammar by providing a larger ‘maxLookahead’ value in the parser’s config 3. This issue can be ignored (if you know what you are doing…), see http://sap.github.io/chevrotain/documentation/1_0_1/interfaces/_chevrotain_d_.iparserconfig.html#ignoredissues for more details
I get this error over on over… Can you help me to refactor this into something that works? Sorry I have no idea how. I dont wanna do 2. and 3. no I don’t know what I’m doing…
// formalParameterList
// : formalParameter (',' formalParameter)* (',' lastFormalParameter)?
// | lastFormalParameter
$.RULE("formalParameterList", () => {
$.OR([
{
ALT: () => {
$.SUBRULE($.formalParameter);
$.MANY(() => {
$.CONSUME(tokens.Comma);
$.SUBRULE($.variableModifier);
});
$.OPTION(() => {
$.CONSUME2(tokens.Comma);
$.SUBRULE2($.lastFormalParameter);
});
}
},
{
ALT: () => {
$.SUBRULE3($.lastFormalParameter);
}
}
]);
});
// formalParameter
// : variableModifier* typeType variableDeclaratorId
$.RULE("formalParameter", () => {
$.MANY(() => {
$.SUBRULE($.variableModifier);
});
$.SUBRULE($.typeType);
$.SUBRULE($.variableDeclaratorId);
});
// lastFormalParameter
// : variableModifier* typeType '...' variableDeclaratorId
$.RULE("lastFormalParameter", () => {
$.MANY(() => {
$.SUBRULE($.variableModifier);
});
$.SUBRULE($.typeType);
$.CONSUME(tokens.DotDotDot);
$.SUBRULE($.variableDeclaratorId);
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
thank you, helped me again a lot. I will close this 😃
https://github.com/SAP/chevrotain/blob/d4c904f2b143c4fb7b3bda0b891ce38e7d68c027/src/parse/parser_public.ts#L1829-L1831
The mismatchTokenException constructor is available on the public API. So your code will need to access it via:
In the next version the API will be flattened, so it would be
-> Do you work at SAP? And can I send you a pizza or some beer for your help? 😃 Yes, I work for SAP, but I think the pizza would get cold as its over 10,000 kilometers between California and Israel 😄
btw you can also join the discord channel for random questions and discussions. https://discord.gg/J5Nx6r9