Warn user about tuple flattening in precedence table
mrontio opened this issue · comments
When creating a precedence table, the example in the documentation suggests to do something like this:
precedence = (
('left', 'PLUS', 'MINUS'),
('left', 'TIMES', 'DIVIDE'),
)
There's a very easy mistake to make here, if you have a single entry in the table and you miss the end comma, e.g.
precedence = (
('left', 'ARROW')
)
Python flattens the tuple, so the precedence
would simply be ('left', 'ARROW')
instead of (('left', 'ARROW'),)
.
The way to fix this is to simply add a ,
to the end of the entry, but its not clear what the issue is once you make a mistake.
This flattening trips the following line:
Line 2161 in 66369a6
My suggestion is to make this line a bit more descriptive, including what it expected, what it got, and a note about tuple flattening:
Line 2162 in 66369a6
I intend on making a pull request with a solution later.
My bad. Didn't read the README.
I would accept a pull request for this.
Fantastic, I do think it will save some time in the labs.