Package antlr
Class TreeParser
- java.lang.Object
-
- antlr.TreeParser
-
public class TreeParser extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected AST_retTreeWhere did this rule leave off parsing; avoids a return parameterprotected ASTFactoryastFactoryAST support code; parser and treeparser delegate to this objectstatic ASTNULLTypeASTNULLThe AST Null object; the parsing cursor is set to this when it is found to be null.protected TreeParserSharedInputStateinputStateNesting level of registered handlersprotected ASTreturnASTAST return value for a rule is squirreled away hereprotected java.lang.String[]tokenNamesTable of token type to token namesprotected inttraceDepthUsed to keep track of indentdepth for traceIn/Out
-
Constructor Summary
Constructors Constructor Description TreeParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ASTgetAST()Get the AST return value squirreled away in the parserASTFactorygetASTFactory()java.lang.StringgetTokenName(int num)java.lang.String[]getTokenNames()protected voidmatch(AST t, int ttype)voidmatch(AST t, 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.protected voidmatchNot(AST t, int ttype)static voidpanic()Deprecated.as of 2.7.2.voidreportError(RecognitionException ex)Parser error-reporting function can be overridden in subclassvoidreportError(java.lang.String s)Parser error-reporting function can be overridden in subclassvoidreportWarning(java.lang.String s)Parser warning-reporting function can be overridden in subclassvoidsetASTFactory(ASTFactory f)Specify an object with support code (shared by Parser and TreeParser.voidsetASTNodeClass(java.lang.String nodeType)Specify the type of node to create during tree buildingvoidsetASTNodeType(java.lang.String nodeType)Deprecated.since 2.7.2voidtraceIn(java.lang.String rname, AST t)voidtraceIndent()voidtraceOut(java.lang.String rname, AST t)
-
-
-
Field Detail
-
ASTNULL
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.
-
_retTree
protected AST _retTree
Where did this rule leave off parsing; avoids a return parameter
-
inputState
protected TreeParserSharedInputState inputState
Nesting level of registered handlers
-
tokenNames
protected java.lang.String[] tokenNames
Table of token type to token names
-
returnAST
protected AST returnAST
AST return value for a rule is squirreled away here
-
astFactory
protected ASTFactory astFactory
AST support code; parser and treeparser delegate to this object
-
traceDepth
protected int traceDepth
Used to keep track of indentdepth for traceIn/Out
-
-
Method Detail
-
getAST
public AST getAST()
Get the AST return value squirreled away in the parser
-
getASTFactory
public ASTFactory getASTFactory()
-
getTokenName
public java.lang.String getTokenName(int num)
-
getTokenNames
public java.lang.String[] getTokenNames()
-
match
protected void match(AST t, int ttype) throws MismatchedTokenException
- Throws:
MismatchedTokenException
-
match
public void match(AST t, BitSet b) throws MismatchedTokenException
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.- Throws:
MismatchedTokenException
-
matchNot
protected void matchNot(AST t, int ttype) throws MismatchedTokenException
- Throws:
MismatchedTokenException
-
panic
public static void panic()
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 isstatic, it cannot be overridden to avoid these problems. ANTLR no longer uses this method internally or in generated code.
-
reportError
public void reportError(RecognitionException ex)
Parser error-reporting function can be overridden in subclass
-
reportError
public void reportError(java.lang.String s)
Parser error-reporting function can be overridden in subclass
-
reportWarning
public void reportWarning(java.lang.String s)
Parser warning-reporting function can be overridden in subclass
-
setASTFactory
public void setASTFactory(ASTFactory f)
Specify an object with support code (shared by Parser and TreeParser. Normally, the programmer does not play with this, using setASTNodeType instead.
-
setASTNodeType
public void setASTNodeType(java.lang.String nodeType)
Deprecated.since 2.7.2Specify the type of node to create during tree building.
-
setASTNodeClass
public void setASTNodeClass(java.lang.String nodeType)
Specify the type of node to create during tree building
-
traceIndent
public void traceIndent()
-
traceIn
public void traceIn(java.lang.String rname, AST t)
-
traceOut
public void traceOut(java.lang.String rname, AST t)
-
-