-
Notifications
You must be signed in to change notification settings - Fork 164
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
old print syntax throws #2339
Comments
Yes, the error message should be a nice syntax error message as usual. That's a bug in our parser. Thanks! |
I think with the current design, we can catch errors for Python 2 print of the forms print "some string here"
print "string", <sequence of expression here> To handle other case (like below) where the first argument is not a string, I think we might need to add new rule(s) in the parser. print xyz
print 523, "string"
print a + b |
I think it would be easy to recognize this in the tokenizer instead of the parser. Even if we try to recognize this in the parser, we might face conflict issues. |
Yes, exactly. There can be conflicts between two grammar rules, one for handling the prefix strings and the other for the python2 I wonder if we should handle the prefix strings at the tokenizer level as well. For example, we have this PR #1885 ready. (It might need a rebase/conflict resolution (if any)). Maybe we can then handle the python2 print at the parser level. @certik What do you say? |
I would say any solution that doesn't complicate or slow down neither the parser nor the tokenizer is ok. So you can try to implement it, and if it is clean, we can merge it. If it can't be done in a clean way, then we'll not do it. |
My fingers stupidly typed
print
syntax from Python 2.17. LPython responded with a barf, but, perhaps a friendly error message would be more appropriate.repro:
result:
The text was updated successfully, but these errors were encountered: