haoxiang47 / ply

Automatically exported from code.google.com/p/ply
0 stars 0 forks source link

Ply lexer does not reset line number on each new scan. #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run 'python ply_bug.py' (see attachment).

---

What is the expected output? What do you see instead?

The expected output is to have the line number the same each time, as we
parse the same input. However, it seems the line number is not reset each time.

---

What version of the product are you using? On what operating system?

Ply 3.3 on Linux.

---
Please provide any additional information below.

I included a patch (lex_bugfix.patch attachment) that resets the lineno
attribute of the lexer each time the input is set. If you apply the patch
and rerun the example, you will see that the line number of the parse error
is the same each time.

Also note that the lexpos attribute of the lexer is properly reset in the
input() function.

Original issue reported on code.google.com by d.hendr...@tue.nl on 8 Apr 2010 at 6:05

Attachments:

GoogleCodeExporter commented 8 years ago
Thank you for this patch!

Original comment by webseite...@googlemail.com on 25 May 2013 at 4:20