Packageorg.antlr.runtime
Classpublic class Parser
InheritanceParser Inheritance BaseRecognizer

A parser for TokenStreams. "parser grammars" result in a subclass of this.



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]
Parser
 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
  tokenStream : TokenStream
Parser
Protected Properties
 PropertyDefined by
  input : TokenStream
Parser
Public Methods
 MethodDefined by
  
Parser
 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
 Inherited
What is the error header, normally line/character position information?
BaseRecognizer
 Inherited
getErrorMessage(e:RecognitionException, tokenNames:Array):String
What error message should be generated for the various exception types? Not very object-oriented code, but I like having all error message generation within one method rather than spread among all of the exception classes.
BaseRecognizer
 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
 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
Parser
 Inherited
toStrings(tokens:Array):Array
A convenience method for use most often with template rewrites.
BaseRecognizer
  
traceIn(ruleName:String, ruleIndex:int):void
Parser
 Inherited
traceInSymbol(ruleName:String, ruleIndex:int, inputSymbol:Object):void
BaseRecognizer
  
traceOut(ruleName:String, ruleIndex:int):void
Parser
 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
  
Parser
  
getMissingSymbol(input:IntStream, e:RecognitionException, expectedTokenType:int, follow:BitSet):Object
Parser
 Inherited
mismatch(input:IntStream, ttype:int, follow:BitSet):void
Factor out what to do upon token mismatch so tree parsers can behave differently.
BaseRecognizer
 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
 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
Property detail
inputproperty
protected var input:TokenStream
sourceNameproperty 
sourceName:String  [read-only]Implementation
    public function get sourceName():String
tokenStreamproperty 
tokenStream:TokenStream  [read-write]Implementation
    public function get tokenStream():TokenStream
    public function set tokenStream(value:TokenStream):void
Constructor detail
Parser()constructor
public function Parser(input:TokenStream, state:RecognizerSharedState = null)Parameters
input:TokenStream
 
state:RecognizerSharedState (default = null)
Method detail
getCurrentInputSymbol()method
protected override function getCurrentInputSymbol(input:IntStream):ObjectParameters
input:IntStream

Returns
Object
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
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