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

Operator precedence is not being handled #11

Open
darkfoxprime opened this issue Apr 22, 2015 · 1 comment
Open

Operator precedence is not being handled #11

darkfoxprime opened this issue Apr 22, 2015 · 1 comment

Comments

@darkfoxprime
Copy link

Operator precedence is not being properly handled. A couple of examples:

>>> to_ast = lambda x:ast.parse(x, mode='eval')
>>> codegen.to_source(to_ast( '(1+2)*3' ))
'1 + 2 * 3'

1+2*3 = 7. (1+2)*3 = 9

>>> codegen.to_source(to_ast( '( "%s " % (sep,) ).join(foo)' ))
"'%s ' % (sep,).join(foo)"

This is evaluated as '%s ' % ((sep,).join(foo)) because . is higher precedence than %

@pmaupin
Copy link

pmaupin commented Jun 9, 2015

The version of this at https://github.com/berkerpeksag/astor handles this properly.

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