Packageorg.antlr.runtime.tree
Classpublic class TreeParser
InheritanceTreeParser Inheritance BaseRecognizer

A parser for a stream of tree nodes. "tree grammars" result in a subclass of this. All the error reporting and recovery is shared with Parser via the BaseRecognizer superclass.



Public Properties
 PropertyDefined by
 InheritedbacktrackingLevel : int
BaseRecognizer
 InheritedgrammarFileName : String
For debugging and other purposes, might want the grammar name.
BaseRecognizer
 InheritednumberOfSyntaxErrors : int
Get number of recognition errors (lexer, parser, tree parser).
BaseRecognizer
  sourceName : String
[read-only]
TreeParser
 Inheritedstate : RecognizerSharedState
State of a lexer, parser, or tree parser are collected into a state object so the state can be shared.
BaseRecognizer
 InheritedtokenNames : Array
Used to print out token names like ID during debugging and error reporting.
BaseRecognizer
  treeNodeStream : TreeNodeStream
TreeParser
Protected Properties
 PropertyDefined by
  input : TreeNodeStream
TreeParser
Public Methods
 MethodDefined by
  
TreeParser
 Inherited
alreadyParsedRule(input:IntStream, ruleIndex:int):Boolean
Has this rule already parsed input at the current index in the input stream? Return the stop token index or MEMO_RULE_UNKNOWN.
BaseRecognizer
 Inherited
beginResync():void
A hook to listen in on the token consumption during error recovery.
BaseRecognizer
 Inherited
consumeUntil(input:IntStream, bitSet:BitSet):void
Consume tokens until one matches the given token set
BaseRecognizer
 Inherited
consumeUntilToken(input:IntStream, tokenType:int):void
BaseRecognizer
 Inherited
BaseRecognizer
 Inherited
emitErrorMessage(msg:String):void
Override this method to change where error messages go
BaseRecognizer
 Inherited
endResync():void
BaseRecognizer
  
Prefix error message with the grammar name because message is always intended for the programmer because the parser built the input tree not the user.
TreeParser
  
getErrorMessage(e:RecognitionException, tokenNames:Array):String
Tree parsers parse nodes they usually have a token object as payload.
TreeParser
 Inherited
getRuleMemoization(ruleIndex:int, ruleStartIndex:int):int
Given a rule number and a start token index number, return MEMO_RULE_UNKNOWN if the rule has not parsed input starting from start index.
BaseRecognizer
 Inherited
return how many rule/input-index pairs there are in total.
BaseRecognizer
 Inherited
How should a token be displayed in an error message? The default is to display just the text, but during development you might want to have a lot of information spit out.
BaseRecognizer
  
matchAny(ignore:IntStream):void
Match '.' in tree parser has special meaning.
TreeParser
 Inherited
Match the wildcard: in a symbol
BaseRecognizer
 Inherited
matchStream(input:IntStream, ttype:int, follow:BitSet):Object
Match current input symbol against ttype.
BaseRecognizer
 Inherited
memoize(input:IntStream, ruleIndex:int, ruleStartIndex:int):void
Record whether or not this rule parsed the input at this position successfully.
BaseRecognizer
 Inherited
mismatchIsMissingToken(input:IntStream, follow:BitSet):Boolean
BaseRecognizer
 Inherited
mismatchIsUnwantedToken(input:IntStream, ttype:int):Boolean
BaseRecognizer
 Inherited
Not currently used
BaseRecognizer
 Inherited
recoverFromMismatchedToken(input:IntStream, ttype:int, follow:BitSet):Object
Attempt to recover from a single missing or extra token.
BaseRecognizer
 Inherited
Recover from an error found on the input stream.
BaseRecognizer
 Inherited
Report a recognition problem.
BaseRecognizer
  
reset():void
TreeParser
 Inherited
toStrings(tokens:Array):Array
A convenience method for use most often with template rewrites.
BaseRecognizer
  
traceIn(ruleName:String, ruleIndex:int):void
TreeParser
 Inherited
traceInSymbol(ruleName:String, ruleIndex:int, inputSymbol:Object):void
BaseRecognizer
  
traceOut(ruleName:String, ruleIndex:int):void
TreeParser
 Inherited
traceOutSymbol(ruleName:String, ruleIndex:int, inputSymbol:Object):void
BaseRecognizer
Protected Methods
 MethodDefined by
 Inherited
combineFollows(exact:Boolean):BitSet
BaseRecognizer
 Inherited
Compute the context-sensitive FOLLOW set for current rule.
BaseRecognizer
 Inherited
BaseRecognizer
  
TreeParser
  
getMissingSymbol(input:IntStream, e:RecognitionException, expectedTokenType:int, follow:BitSet):Object
TreeParser
  
mismatch(input:IntStream, ttype:int, follow:BitSet):void
We have DOWN/UP nodes in the stream that have no line info; override.
TreeParser
 Inherited
pushFollow(fset:BitSet):void
Push a rule's follow set using our own hardcoded stack
BaseRecognizer
Public Constants
 ConstantDefined by
 InheritedDEFAULT_TOKEN_CHANNEL : int = 0
[static]
BaseRecognizer
  DOWN : int = 2
[static]
TreeParser
 InheritedHIDDEN : int = 99
[static]
BaseRecognizer
 InheritedINITIAL_FOLLOW_STACK_SIZE : int = 100
[static]
BaseRecognizer
 InheritedMEMO_RULE_FAILED : int = -2
[static]
BaseRecognizer
 InheritedMEMO_RULE_UNKNOWN : int = -1
[static]
BaseRecognizer
 InheritedNEXT_TOKEN_RULE_NAME : String = "nextToken"
[static]
BaseRecognizer
  UP : int = 3
[static]
TreeParser
Property detail
inputproperty
protected var input:TreeNodeStream
sourceNameproperty 
sourceName:String  [read-only]Implementation
    public function get sourceName():String
treeNodeStreamproperty 
treeNodeStream:TreeNodeStream  [read-write]Implementation
    public function get treeNodeStream():TreeNodeStream
    public function set treeNodeStream(value:TreeNodeStream):void
Constructor detail
TreeParser()constructor
public function TreeParser(input:TreeNodeStream, state:RecognizerSharedState = null)Parameters
input:TreeNodeStream
 
state:RecognizerSharedState (default = null)
Method detail
getCurrentInputSymbol()method
protected override function getCurrentInputSymbol(input:IntStream):ObjectParameters
input:IntStream

Returns
Object
getErrorHeader()method 
public override function getErrorHeader(e:RecognitionException):String

Prefix error message with the grammar name because message is always intended for the programmer because the parser built the input tree not the user.

Parameters
e:RecognitionException

Returns
String
getErrorMessage()method 
public override function getErrorMessage(e:RecognitionException, tokenNames:Array):String

Tree parsers parse nodes they usually have a token object as payload. Set the exception token and do the default behavior.

Parameters
e:RecognitionException
 
tokenNames:Array

Returns
String
getMissingSymbol()method 
protected override function getMissingSymbol(input:IntStream, e:RecognitionException, expectedTokenType:int, follow:BitSet):ObjectParameters
input:IntStream
 
e:RecognitionException
 
expectedTokenType:int
 
follow:BitSet

Returns
Object
matchAny()method 
public function matchAny(ignore:IntStream):void

Match '.' in tree parser has special meaning. Skip node or entire tree if node has children. If children, scan until corresponding UP node.

Parameters
ignore:IntStream
mismatch()method 
protected override function mismatch(input:IntStream, ttype:int, follow:BitSet):void

We have DOWN/UP nodes in the stream that have no line info; override. plus we want to alter the exception type. Don't try to recover from tree parser errors inline...

Parameters
input:IntStream
 
ttype:int
 
follow:BitSet
reset()method 
public override function reset():void
traceIn()method 
public function traceIn(ruleName:String, ruleIndex:int):voidParameters
ruleName:String
 
ruleIndex:int
traceOut()method 
public function traceOut(ruleName:String, ruleIndex:int):voidParameters
ruleName:String
 
ruleIndex:int
Constant detail
DOWNconstant
public static const DOWN:int = 2
UPconstant 
public static const UP:int = 3