Skip to content
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 #268

Merged

Conversation

clementdessoude
Copy link
Contributor

@clementdessoude clementdessoude commented Sep 24, 2019

I started working on Chevrotain upgrade. It seems that it works with these changes, but the way I implemented it should be improved.

@bd82 if you could review this PR and give me your feedback, it would be great !

I especially modified some "is..." rules to make the tests pass and removed some errors throwing in the process, so I guess something should be improved here.

Copy link
Contributor

@bd82 bd82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better. 👍

Try to add $.ACTION directly inside this.BACKTRACK_LOOKAHEAD?

@bd82
Copy link
Contributor

bd82 commented Sep 24, 2019

Perhaps in a different change:

Try to remove ignoredIssues property from the Parser's config.
Most ambiguities that are resolved by GATE are auto magically ignored.

You will still get (fewer) errors regarding ambiguities because the new ambiguity ignoring is more granular. Those errors should be inspected, either we already handle those ambiguities in ways other than GATE, in which case they need to be ignored explicitly on the DSL method (new options).
Or perhaps this will cause us to detect some new edge case bugs.

See: Chevrotain/chevrotain#869

@bd82
Copy link
Contributor

bd82 commented Sep 24, 2019

Remove "hacky" fix for CST Building while backtracking.
See: Chevrotain/chevrotain#789

@clementdessoude
Copy link
Contributor Author

Try to add $.ACTION directly inside this.BACKTRACK_LOOKAHEAD?

Done !

I will try to delete the ignoredIssues afterwards, when the changes in the parser look good enough

Copy link
Contributor Author

@clementdessoude clementdessoude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR to remove the ignoredIssues flag

}
]);
],
IGNORE_AMBIGUITIES: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ambiguous Alternatives Detected: <1 ,2> in inside Rule,
<Identifier, '='> may appears as a prefix path in all these alternatives.

It is because an elementValue could be a binaryExpression and could start with Identifier and '='. Do you think we must use a GATE or backtracking here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use 3 or 4 tokens lookahead would that resolve in this case?
because you can increase the maxLookahead for this specific rule...
I don't remember the specific grammar rules, does the list alternative always have a comma somewhere? how far ahead is that comma?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it is not enough to increase the maxLookahead for this rule. The list alternative always has a comma somewhere, but as the elementValue could be an expression, it could have several annotations and thus we cannot look ahead at a specific step.

{ ALT: () => $.SUBRULE($.unannType) },
{ ALT: () => $.CONSUME(t.Var) }
],
IGNORE_AMBIGUITIES: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to enforce not using 'var' in unannType

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can var be used as an identifier? is that the cause of the ambiguity?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case (I have some fuzzy memory of limitations for the var keyword.
You may be able to define a IdentifierButNotVar Token using token categories.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right. I think I will try to improve this in a following PR, adding a token and change some parser logic seems out of the scope of this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitively out of scope

@clementdessoude
Copy link
Contributor Author

Remove "hacky" fix for CST Building while backtracking.
See: SAP/chevrotain#789

Concerning this one, It would be great if @Shaolans could have a look, as he added the "prettier-ignore" logic here

@Shaolans
Copy link
Member

Concerning this one, It would be great if @Shaolans could have a look, as he added the "prettier-ignore" logic here

I will take a look

@clementdessoude clementdessoude force-pushed the feature/upgrade-chevrotain branch from ac9359c to 4a70840 Compare September 27, 2019 15:07
@clementdessoude
Copy link
Contributor Author

@bd82: Do you think it can be merged ? We could do the rest of the work (removing "hacky" fix for CST Building while backtracking & working on IGNORE_AMBIGUITIES cases in follow-up PRs)

@bd82
Copy link
Contributor

bd82 commented Sep 27, 2019

@bd82: Do you think it can be merged ? We could do the rest of the work (removing "hacky" fix for CST Building while backtracking & working on IGNORE_AMBIGUITIES cases in follow-up PRs)

Yes, this looks good 👍

@clementdessoude clementdessoude merged commit 7a1873f into jhipster:master Sep 27, 2019
@clementdessoude clementdessoude deleted the feature/upgrade-chevrotain branch September 27, 2019 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants