org.norecess.antlr
Class PostParse

java.lang.Object
  extended by org.norecess.antlr.PostParse

public class PostParse
extends Object

Allows processing of parser output. PostScan.parseAs(String) returns post-parse objects. Assert describes how to deal with these objects in a practical way; read that documentation first.

For those wanting more details...

There are typically two things you want to do with the results of a successful parse:

Author:
Jeremy D. Frens

Field Summary
private static Class<?>[] CONSTRUCTOR_PARAMETER_TYPES
           
private  IANTLRFrontEnd myFrontEnd
           
private  org.antlr.runtime.tree.Tree myTree
           
 
Constructor Summary
PostParse(org.antlr.runtime.tree.Tree tree, IANTLRFrontEnd frontEnd)
          Constructs a post-parse object.
 
Method Summary
 org.antlr.runtime.tree.Tree getTree()
          Returns the tree saved in this object.
private  org.antlr.runtime.tree.TreeParser treeParse(org.antlr.runtime.tree.Tree tree)
           
 Object treeParseAs(String production)
          Creates an instance of your tree parser and invokes the specified production.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRUCTOR_PARAMETER_TYPES

private static final Class<?>[] CONSTRUCTOR_PARAMETER_TYPES

myFrontEnd

private final IANTLRFrontEnd myFrontEnd

myTree

private final org.antlr.runtime.tree.Tree myTree
Constructor Detail

PostParse

public PostParse(org.antlr.runtime.tree.Tree tree,
                 IANTLRFrontEnd frontEnd)
Constructs a post-parse object. PostScan.parseAs(String) uses this, and it's unlikely that it would be generally useful.

Parameters:
tree - the result of a parse.
frontEnd - the factory for creating a tree parser.
Method Detail

getTree

public org.antlr.runtime.tree.Tree getTree()
Returns the tree saved in this object. Usually this is the result from PostScan.parseAs(String).

Returns:
the tree from the parse.

treeParseAs

public Object treeParseAs(String production)
Creates an instance of your tree parser and invokes the specified production. The value returned by the tree-parser production is returned by this method. Since this method is usally called in a JUnit assertion, the return type of Object is sufficient.

Parameters:
production - the production rule from the tree parser to invoke.
Returns:
whatever the production rule generates.

treeParse

private org.antlr.runtime.tree.TreeParser treeParse(org.antlr.runtime.tree.Tree tree)