FileDocCategorySizeDatePackage
TreeParser.javaAPI DocGlassfish v2 API5184Wed Aug 30 15:34:12 BST 2006persistence.antlr

TreeParser

public class TreeParser extends Object

Fields Summary
public static ASTNULLType
ASTNULL
The AST Null object; the parsing cursor is set to this when it is found to be null. This way, we can test the token type of a node without having to have tests for null everywhere.
protected AST
_retTree
Where did this rule leave off parsing; avoids a return parameter
protected TreeParserSharedInputState
inputState
Nesting level of registered handlers
protected String[]
tokenNames
Table of token type to token names
protected AST
returnAST
AST return value for a rule is squirreled away here
protected ASTFactory
astFactory
AST support code; parser and treeparser delegate to this object
protected int
traceDepth
Used to keep track of indentdepth for traceIn/Out
Constructors Summary
public TreeParser()


      
        inputState = new TreeParserSharedInputState();
    
Methods Summary
public persistence.antlr.collections.ASTgetAST()
Get the AST return value squirreled away in the parser

        return returnAST;
    
public persistence.antlr.ASTFactorygetASTFactory()

        return astFactory;
    
public java.lang.StringgetTokenName(int num)

        return tokenNames[num];
    
public java.lang.String[]getTokenNames()

        return tokenNames;
    
protected voidmatch(persistence.antlr.collections.AST t, int ttype)

        //System.out.println("match("+ttype+"); cursor is "+t);
        if (t == null || t == ASTNULL || t.getType() != ttype) {
            throw new MismatchedTokenException(getTokenNames(), t, ttype, false);
        }
    
public voidmatch(persistence.antlr.collections.AST t, persistence.antlr.collections.impl.BitSet b)
Make sure current lookahead symbol matches the given set Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.

        if (t == null || t == ASTNULL || !b.member(t.getType())) {
            throw new MismatchedTokenException(getTokenNames(), t, b, false);
        }
    
protected voidmatchNot(persistence.antlr.collections.AST t, int ttype)

        //System.out.println("match("+ttype+"); cursor is "+t);
        if (t == null || t == ASTNULL || t.getType() == ttype) {
            throw new MismatchedTokenException(getTokenNames(), t, ttype, true);
        }
    
public static voidpanic()

deprecated
as of 2.7.2. This method calls System.exit() and writes directly to stderr, which is usually not appropriate when a parser is embedded into a larger application. Since the method is static, it cannot be overridden to avoid these problems. ANTLR no longer uses this method internally or in generated code.

        System.err.println("TreeWalker: panic");
        System.exit(1);
    
public voidreportError(persistence.antlr.RecognitionException ex)
Parser error-reporting function can be overridden in subclass

        System.err.println(ex.toString());
    
public voidreportError(java.lang.String s)
Parser error-reporting function can be overridden in subclass

        System.err.println("error: " + s);
    
public voidreportWarning(java.lang.String s)
Parser warning-reporting function can be overridden in subclass

        System.err.println("warning: " + s);
    
public voidsetASTFactory(persistence.antlr.ASTFactory f)
Specify an object with support code (shared by Parser and TreeParser. Normally, the programmer does not play with this, using setASTNodeType instead.

        astFactory = f;
    
public voidsetASTNodeClass(java.lang.String nodeType)
Specify the type of node to create during tree building

        astFactory.setASTNodeType(nodeType);
    
public voidsetASTNodeType(java.lang.String nodeType)
Specify the type of node to create during tree building.

deprecated
since 2.7.2

        setASTNodeClass(nodeType);
    
public voidtraceIn(java.lang.String rname, persistence.antlr.collections.AST t)

        traceDepth += 1;
        traceIndent();
        System.out.println("> " + rname +
                           "(" + (t != null?t.toString():"null") + ")" +
                           ((inputState.guessing > 0)?" [guessing]":""));
    
public voidtraceIndent()

        for (int i = 0; i < traceDepth; i++)
            System.out.print(" ");
    
public voidtraceOut(java.lang.String rname, persistence.antlr.collections.AST t)

        traceIndent();
        System.out.println("< " + rname +
                           "(" + (t != null?t.toString():"null") + ")" +
                           ((inputState.guessing > 0)?" [guessing]":""));
        traceDepth--;