L
Ludwig Miniatur
Hi, I ran into a funny thing when I played with the python parser, to
build a python call graph for learning...
When I have a (special) python program, that runs without any error it
gives an error, when I try to parse it parser.suite. The error is,
when my program has a comment on the last line after an indented
block. Note that there no newline behind "# comment". With a newline
everything is fine.
For example:
#!/usr/bin/env python
from parser import suite, ast2list
fh = file(__file__)
s = fh.read()
fh.close()
ast = suite(s)
while False:
print "hello world"
# comment
Looks like a little bug in parser; but what I don't understand is that
I thought parser was build with the current syntax of python.
So, why can python run the script (an it can if you comment out the
line "ast = suite(s)") but parser can't?
Looking forward for answers...
Ludwig
build a python call graph for learning...
When I have a (special) python program, that runs without any error it
gives an error, when I try to parse it parser.suite. The error is,
when my program has a comment on the last line after an indented
block. Note that there no newline behind "# comment". With a newline
everything is fine.
For example:
#!/usr/bin/env python
from parser import suite, ast2list
fh = file(__file__)
s = fh.read()
fh.close()
ast = suite(s)
while False:
print "hello world"
# comment
Looks like a little bug in parser; but what I don't understand is that
I thought parser was build with the current syntax of python.
So, why can python run the script (an it can if you comment out the
line "ast = suite(s)") but parser can't?
Looking forward for answers...
Ludwig