Open GoogleCodeExporter opened 8 years ago
Update: A choice is made to 'abuse' the current system, and have 'lineno' point
to a Position object instead of an integer. In that way, lextokens get the
right object automatically with zero effort, as long as position updates are
done by creating a new position object.
It is not the prettiest solution, but it seems like an effective solution for
now.
Original comment by Alberth2...@gmail.com
on 17 Jun 2010 at 7:04
PLY seems to have unnecessary limitations to the line number:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nml/tokens.py", line 230, in dump_tokens
fp.write(str(tok) + '\n')
File "/usr/lib/python2.6/site-packages/ply/lex.py", line 71, in __str__
return "LexToken(%s,%r,%d,%d)" % (self.type,self.value,self.lineno,self.lexpos)
TypeError: %d format: a number is required, not LinePosition
Due to the hard-coded %d for the lineno, it is impossible to print a token with
a Position object as line number.
Suggested fix: Change %d to %s ("%s" % 123 outputs the number, so that solution
is backwards compatible).
Original comment by Alberth2...@gmail.com
on 15 Sep 2010 at 8:18
Original issue reported on code.google.com by
Alberth2...@gmail.com
on 9 Jun 2010 at 6:59Attachments: