Packageorg.antlr.runtime
Classpublic class CommonTokenStream
ImplementsTokenStream
SubclassesTokenRewriteStream

The most common stream of tokens is one where every token is buffered up and tokens are prefiltered for a certain channel (the parser will only see these tokens and cannot change the filter channel number during the parse). TODO: how to access the full token stream? How to track all tokens matched per rule?



Public Properties
 PropertyDefined by
  index : int
[read-only]
CommonTokenStream
  size : int
[read-only]
CommonTokenStream
  sourceName : String
[read-only]
CommonTokenStream
  tokenSource : TokenSource
CommonTokenStream
Protected Properties
 PropertyDefined by
  channel : int = 0
Skip tokens on any channel but this one; this is how we skip whitespace...
CommonTokenStream
  channelOverrideMap : Array
Map to override some Tokens' channel numbers
CommonTokenStream
  _discardOffChannelTokens : Boolean = false
By default, track all incoming tokens
CommonTokenStream
  discardSet : Array
Set; discard any tokens with this type
CommonTokenStream
  lastMarker : int
Track the last mark() call result value for use in rewind().
CommonTokenStream
  p : int = -1
The index into the tokens list of the current token (next token to consume).
CommonTokenStream
  tokens : Array
Record every single token pulled from the source so we can reproduce chunks of it later.
CommonTokenStream
  _tokenSource : TokenSource
CommonTokenStream
Public Methods
 MethodDefined by
  
CommonTokenStream(tokenSource:TokenSource = null, channel:int)
CommonTokenStream
  
consume():void
Move the input pointer to the next incoming token.
CommonTokenStream
  
discardOffChannelTokens(discardOffChannelTokens:Boolean):void
CommonTokenStream
  
discardTokenType(ttype:int):void
CommonTokenStream
  
getToken(i:int):Token
Return absolute token i; ignore which channel the tokens are on; that is, count all tokens not just on-channel tokens.
CommonTokenStream
  
getTokens():Array
CommonTokenStream
  
getTokensArray(start:int, stop:int, types:Array):Array
CommonTokenStream
  
getTokensBitSet(start:int, stop:int, types:BitSet):Array
Given a start and stop index, return a List of all tokens in the token type BitSet.
CommonTokenStream
  
getTokensInt(start:int, stop:int, ttype:int):Array
CommonTokenStream
  
getTokensRange(start:int, stop:int):Array
CommonTokenStream
  
LA(i:int):int
CommonTokenStream
  
LT(k:int):Token
Get the ith token from the current position 1..n where k=1 is the first symbol of lookahead.
CommonTokenStream
  
mark():int
CommonTokenStream
  
release(marker:int):void
CommonTokenStream
  
reset():void
CommonTokenStream
  
rewind():void
CommonTokenStream
  
rewindTo(marker:int):void
CommonTokenStream
  
seek(index:int):void
CommonTokenStream
  
setTokenTypeChannel(ttype:int, channel:int):void
A simple filter mechanism whereby you can tell this token stream to force all tokens of type ttype to be on channel.
CommonTokenStream
  
toString():String
CommonTokenStream
  
toStringWithRange(start:int, stop:int):String
CommonTokenStream
  
toStringWithTokenRange(start:Token, stop:Token):String
CommonTokenStream
Protected Methods
 MethodDefined by
  
fillBuffer():void
Load all tokens from the token source and put in tokens.
CommonTokenStream
  
LB(k:int):Token
Look backwards k tokens on-channel tokens
CommonTokenStream
  
Given a starting index, return the index of the first on-channel token.
CommonTokenStream
  
CommonTokenStream
Property detail
channelproperty
protected var channel:int = 0

Skip tokens on any channel but this one; this is how we skip whitespace...

channelOverrideMapproperty 
protected var channelOverrideMap:Array

Map to override some Tokens' channel numbers

_discardOffChannelTokensproperty 
protected var _discardOffChannelTokens:Boolean = false

By default, track all incoming tokens

discardSetproperty 
protected var discardSet:Array

Set; discard any tokens with this type

indexproperty 
index:int  [read-only]Implementation
    public function get index():int
lastMarkerproperty 
protected var lastMarker:int

Track the last mark() call result value for use in rewind().

pproperty 
protected var p:int = -1

The index into the tokens list of the current token (next token to consume). p==-1 indicates that the tokens list is empty

sizeproperty 
size:int  [read-only]Implementation
    public function get size():int
sourceNameproperty 
sourceName:String  [read-only]Implementation
    public function get sourceName():String
tokensproperty 
protected var tokens:Array

Record every single token pulled from the source so we can reproduce chunks of it later.

_tokenSourceproperty 
protected var _tokenSource:TokenSource
tokenSourceproperty 
tokenSource:TokenSource  [read-write]Implementation
    public function get tokenSource():TokenSource
    public function set tokenSource(value:TokenSource):void
Constructor detail
CommonTokenStream()constructor
public function CommonTokenStream(tokenSource:TokenSource = null, channel:int)Parameters
tokenSource:TokenSource (default = null)
 
channel:int
Method detail
consume()method
public function consume():void

Move the input pointer to the next incoming token. The stream must become active with LT(1) available. consume() simply moves the input pointer so that LT(1) points at the next input symbol. Consume at least one token. Walk past any token not on the channel the parser is listening to.

discardOffChannelTokens()method 
public function discardOffChannelTokens(discardOffChannelTokens:Boolean):voidParameters
discardOffChannelTokens:Boolean
discardTokenType()method 
public function discardTokenType(ttype:int):voidParameters
ttype:int
fillBuffer()method 
protected function fillBuffer():void

Load all tokens from the token source and put in tokens. This is done upon first LT request because you might want to set some token type / channel overrides before filling buffer.

getToken()method 
public function getToken(i:int):Token

Return absolute token i; ignore which channel the tokens are on; that is, count all tokens not just on-channel tokens.

Parameters
i:int

Returns
Token
getTokens()method 
public function getTokens():Array

Returns
Array
getTokensArray()method 
public function getTokensArray(start:int, stop:int, types:Array):ArrayParameters
start:int
 
stop:int
 
types:Array

Returns
Array
getTokensBitSet()method 
public function getTokensBitSet(start:int, stop:int, types:BitSet):Array

Given a start and stop index, return a List of all tokens in the token type BitSet. Return null if no tokens were found. This method looks at both on and off channel tokens. Renamed from getTokens

Parameters
start:int
 
stop:int
 
types:BitSet

Returns
Array
getTokensInt()method 
public function getTokensInt(start:int, stop:int, ttype:int):ArrayParameters
start:int
 
stop:int
 
ttype:int

Returns
Array
getTokensRange()method 
public function getTokensRange(start:int, stop:int):ArrayParameters
start:int
 
stop:int

Returns
Array
LA()method 
public function LA(i:int):intParameters
i:int

Returns
int
LB()method 
protected function LB(k:int):Token

Look backwards k tokens on-channel tokens

Parameters
k:int

Returns
Token
LT()method 
public function LT(k:int):Token

Get the ith token from the current position 1..n where k=1 is the first symbol of lookahead.

Parameters
k:int

Returns
Token
mark()method 
public function mark():int

Returns
int
release()method 
public function release(marker:int):voidParameters
marker:int
reset()method 
public function reset():void
rewind()method 
public function rewind():void
rewindTo()method 
public function rewindTo(marker:int):voidParameters
marker:int
seek()method 
public function seek(index:int):voidParameters
index:int
setTokenTypeChannel()method 
public function setTokenTypeChannel(ttype:int, channel:int):void

A simple filter mechanism whereby you can tell this token stream to force all tokens of type ttype to be on channel. For example, when interpreting, we cannot exec actions so we need to tell the stream to force all WS and NEWLINE to be a different, ignored channel.

Parameters
ttype:int
 
channel:int
skipOffTokenChannels()method 
protected function skipOffTokenChannels(i:int):int

Given a starting index, return the index of the first on-channel token.

Parameters
i:int

Returns
int
skipOffTokenChannelsReverse()method 
protected function skipOffTokenChannelsReverse(i:int):intParameters
i:int

Returns
int
toString()method 
public function toString():String

Returns
String
toStringWithRange()method 
public function toStringWithRange(start:int, stop:int):StringParameters
start:int
 
stop:int

Returns
String
toStringWithTokenRange()method 
public function toStringWithTokenRange(start:Token, stop:Token):StringParameters
start:Token
 
stop:Token

Returns
String