-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Chevrotain to 6.x #248
Comments
I'll try to do the update |
You will probably need to wrap the custom backtracking logic with |
Version 6.3 includes features and a guide related to improving initialization performance. |
With @clement26695, we are looking to update prettier-java to the latest version of Chevrotain. $.RULE("isCastExpression", () => {
if (this.BACKTRACK_LOOKAHEAD($.isPrimitiveCastExpression)) {
return true;
}
return this.BACKTRACK_LOOKAHEAD($.isReferenceTypeCastExpression);
});
$.RULE("isPrimitiveCastExpression", () => {
$.CONSUME(t.LBrace);
$.SUBRULE($.primitiveType);
// No dims so this is not a reference Type
$.CONSUME(t.RBrace);
return true;
}); |
Try wrapping the whole $.RULE("isCastExpression", () => {
return $.ACTION(() => {
if (this.BACKTRACK_LOOKAHEAD($.isPrimitiveCastExpression)) {
return true;
}
return this.BACKTRACK_LOOKAHEAD($.isReferenceTypeCastExpression);
})
}); |
Basically you want to avoid running backtracking logic during the grammar recording phase |
I have to admit that I am a bit lost here... I just tried to upgrade it and wrapped every Backtracking logic in an ACTION (see here), but I got an error when I try to parse any file, for instance this one: public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
public App() {
LOGGER.info("Constructing parts and car");
}
} I got this stacktrace:
|
Bad example: https://github.com/clement26695/prettier-java/pull/4/files#diff-3be86ec11b8168a43f3526a40d5af78eR214 Basically You want the "recording phase" to run on your rules to build the data structure representing the grammar. so it cannot be wrapped in ACTION as this skips its invocation during the recording phase. However you do not want to RECORD the backtracking logic as that is not part of the grammar, so you wrap calls to btw: GATES are not executed during backtracking so no need to wrap code already inside GATE property with ACTION. This is a pretty complex grammar in terms of using advanced optimized backtracking... |
Thank you for the clarifications ! Will try to upgrade this week, I will keep you posted |
Closed with #268 |
There have been quite a few changes including breaking ones.
https://sap.github.io/chevrotain/docs/changes/CHANGELOG.html#_6-1-0-8-25-2019
The text was updated successfully, but these errors were encountered: