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

Fragments can be used only in another lexer rule error #3018

Conversation

KvanTTT
Copy link
Member

@KvanTTT KvanTTT commented Dec 29, 2020

A more clear error message to avoid confusion if fragment lexer rules are used in parser rules; fix #3016, fix #2886

@parrt
Copy link
Member

parrt commented Jan 2, 2021

hi. This is a bit hard to evaluate since there seem to be a lot of changes but really they are just comment changes. Can you undo all of the unnecessary changes so I can look at the difference? BTW, I'm pretty nervous about introducing a new imaginary token.

@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 2, 2021

Can you undo all of the unnecessary changes so I can look at the difference?

Ok.

BTW, I'm pretty nervous about introducing a new imaginary token.

It's possible to implement without introducing a new imaginary token type but such error will work only with combined grammar, i.e. the test testFragmentRuleInParserRuleInSeparatedGrammar will not work.

The current implementation adds fragment tokens to .tokens file and analyzes them in the parser generation stage if grammars are separated:

TOKEN=1
FRAGMENT=-3
FRAGMENT2=-3

@parrt
Copy link
Member

parrt commented Jan 3, 2021

Hmm... in the end I don't have the motivation to think carefully about these things and any kind of changes that affect end-users should be done after a lot of thought. I think we should focus on the targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants