|
From: <bc...@wo...> - 2001-03-22 16:20:21
|
[Javier Fradiletti]
>Hi!
>I'm triying to parse an expression in jython sintaxis and with the result
>tree do something.
>I'm having some troubles when i try to get the information in the tree
>nodes.
>I have to know the 'structure' of the tree (an if statment with a
>condition -and have acces to that condition-) to represent it in a graphic
>interfase.
>There is not much java api documentation in the jython site, so i really
>need your help.
I don't quite understand what you mean. Is your "result tree" the syntax
tree create by the org.python.parser.* classes?
I'll assume that it is, because I don't know of any other way tree
representaions of jython expressions. You can investigate the actual
tree structure with the SimpleNode.dump(..) method:
from java import io
from org.python.core import parser
istream = io.ByteArrayInputStream("if 1: print 'true'")
tree = parser.parse(istream, "exec", "dummy");
tree.dump("if-stmt:")
The language grammar in jython.jjt is also a necessary tool when
understanding the syntax tree.
Keep in mind that the syntax tree is an internal feature of the python
language and that the tree may change between releases.
regards,
finn
|