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

@@keyword + @name directives fail if keyword is "True" or "False" #335

Closed
KrzysztofT opened this issue Mar 16, 2024 · 1 comment
Closed

Comments

@KrzysztofT
Copy link

After a few years I revisited my old project which uses TatSu. I upgraded the library to version 5.11.3 (I'm using Python 3.12). I had to fix a few things - but no matter what I did, I couldn't make my booleans working properly. Diving with debugger into TatSu code showed that there might be some issue with keyword handling.

If the keyword declarations contains "True" or "False" spelled exactly like this - with first letter being capital:

@@keyword :: True False

Then the ModelContext.keywords set will contain these two words - not as strings, but as regular Python booleans instead. Consequently, _check_name will not match with a string "False" nor "True".

Changing these keywords to lowercase is a quick workaround.

@KrzysztofT KrzysztofT changed the title @@keywords + @name directives fail if keyword is "True" or "False" @@keyword + @name directives fail if keyword is "True" or "False" Mar 16, 2024
@apalala
Copy link
Collaborator

apalala commented Mar 17, 2024

This is a result of recent changes to make literals map to Python basic types.

It looks like something easy to fix in the grammar, by making keyword only match strings and words.

It's an obnoxious bug that merits a new release.

apalala added a commit that referenced this issue Mar 18, 2024
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

No branches or pull requests

2 participants