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

data/python.gram produces wrong results when parsing fstring with = in {} #101

Open
zhenkuny opened this issue May 1, 2024 · 0 comments

Comments

@zhenkuny
Copy link

zhenkuny commented May 1, 2024

python -m pegen data/python.gram -o python_parser.py

import ast
import python_parser as pp

print(ast.dump(pp.parse_string('f"{x=}"', 'eval')))
print(ast.dump(ast.parse('f"{x=}"', mode='eval')))

outputs this:

Expression(body=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=114)]))
Expression(body=JoinedStr(values=[Constant(value='x='), FormattedValue(value=Name(id='x', ctx=Load()), conversion=114)]))

We can see that "=" is not considered in the python.gram.

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

1 participant