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

Updated Python grammar list literal to support [*x] #1232

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

evtn
Copy link
Member

@evtn evtn commented Dec 18, 2022

Previous version used _testlist_comp which allowed for either one test or 2 and more test_or_star_expr.
This version also allows a list with one star_expr which is valid both in Python and in official Python grammar.
Moreover it merges rules used in set and list (since those terminals differ only in that set literal cannot be empty)

Previous version used `_testlist_comp` which allowed for either one `test` or 2 and more `test_or_star_expr`
This version allows a list with one `star_expr` which is valid both in Python and in official Python grammar.
Moreover it merges rules used in set and list (since those terminals differ only in one thing: set literal cannot be empty)
@evtn evtn changed the title Updated list literal to support [*x] Updated Python grammar list literal to support [*x] Dec 18, 2022
Copy link
Member

@MegaIng MegaIng left a comment

Choose a reason for hiding this comment

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

It would be really nice if we could find a syntax test bench for python somewhere to catch all these edge cases. But I don't think that exists.

@evtn
Copy link
Member Author

evtn commented Dec 18, 2022

Well, there is a suite that is used by PyPy, which is MIT-licensed and probably will be a good place to start
https://github.com/mozillazg/pypy/tree/master/pypy/interpreter/pyparser/test (this is a mirror, but still)

I probably could spend some time on this, since my current project requires a fully working Python grammar anyways

@erezsh erezsh merged commit f3d7904 into lark-parser:master Dec 19, 2022
@erezsh
Copy link
Member

erezsh commented Dec 19, 2022

Thank you, @evtn ! If you would like to set up tests for the Python grammar, we'll be happy to include them in our test suite!

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