-
Notifications
You must be signed in to change notification settings - Fork 289
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
[FIX] Return token in Lezer parser only when it applies #4898
[FIX] Return token in Lezer parser only when it applies #4898
Conversation
I think for this to move forward I need to fix the grammar a bit, and handle indentation properly. |
@Felienne This PR is ready now! I also added some tests for levels 5, 6 and 7, please take a look whenever you want |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
Description
On Spanish, Bulgarian, and possibly other languages, there was an error when highlighting
for
commands, because in these languages the word forin
andat
is the same. This PR fixes that and also fixes it in other possible occurrences of the same problem by only returning the token if the parser can shift the state were the token be accepted, for example take into consideration the following code of level 10:The English version of this program is:
When the parser reaches the token
en
, the stack already has:[For, Text]
. Then it iterates through every keyword relevant for this level in the highlighting.json dictionary and asks: Doesen
matches the regex for the current keyword? If it does, it then asks, can the parser shifts if I accept this token? If the answer is yes, it is accepted, if it ins't it continues to the next token, and finishes when it finds one that it can accept or it returns -1, in the case than none is accepted.The problem was in this last step: we didn't ask if the parser would be in a good state if we accepted the token, resulting in accepting the first token that was found.
Fixes #4772
How to test
Go to level 12, set the language to Spanish and write: