I recently played around a bit with the addition of some optional operator names in python, and this worked fine until I got to the if statement, and added the optional name for else and elif:
if_stmt = 'if' test ':' suite ('elif' test ':'suite)* ['else' ':' suite] | 'wenn' test ':' suite ('andernfalls' test ':'suite)* ['sonst' ':' suite]
then it compiled without errors, but when I ran the test with wenn and andernfalls, and the interpreter threw the error:
SystemError: unexpected token in 'if' statement: andernfalls
And every addition I made did a great job. So why can't I add another and elif and how could I do this?
I am changing the most recent python 2.7 code from the python website.
EDIT My test code:
x = 1
y = 2
wenn x > y:
print 1
andernfalls x < y:
print 2
sonst:
print 3
The file I added the line at the top, it was a grammar file in the grammar directory of the python source code.
source
share