From: Jim B. <jb...@zy...> - 2009-05-29 23:50:48
|
Yin, PythonPartial is not meant to return an AST. Its sole purpose is to determine if the input presented at the console is complete or not. For the Python REPL, we need a separate grammar because it's OK if the partial parse contains a fragment, such as a multiline string that's not been terminated with a """. PythonPartial is generated from PythonPartial.g, exposed by ParserFacade, and documented in terms of its usage in the comments for InteractiveInterpreter#runsource. If you compare PythonPartial.g and Python.g, you will see the specifics of this (I would not really look at the generated source in PythonPartial.java). PythonPartial.g is just a parser grammar, with some sharing against Python.g for tokens (tokenVocab). There is no AST construction performed. In contrast, Python.g contains the tree construction as needed for subsequent compilation, and is consequently a much larger file. - Jim On Sat, May 30, 2009 at 4:28 AM, Yin Wang <yin...@gm...> wrote: > Hi, > > I'm trying to figure out how to use the partial parser > org.python.antlr.PythonPartial, but I haven't found how to get an AST > from it. It doesn't even refer to any type in the PythonTree > hierarchy. Strange. Any ideas or code examples? The file > org.python.antlr.PythonPartialTester simple succeeds without giving > out any value. It calls single_input() but that method's return type > is void. Thanks. > > > -- yin > > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. > Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp as they present alongside digital heavyweights like Barbarian > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-dev > -- Jim Baker jb...@zy... |