antlr
Class TokenStreamSelector

java.lang.Object
  |
  +--antlr.TokenStreamSelector
All Implemented Interfaces:
TokenStream

public class TokenStreamSelector
extends Object
implements TokenStream

Untamed: A token stream MUX (multiplexor) knows about n token streams and can multiplex them onto the same channel for use by token stream consumer like a parser. This is a way to have multiple lexers break up the same input stream for a single parser. Or, you can have multiple instances of the same lexer handle multiple input streams; this works great for includes.


Field Summary
protected  TokenStream input
          The currently-selected token stream input
protected  Hashtable inputStreamNames
          The set of inputs to the MUX
protected  Stack streamStack
          Used to track stack of input streams
 
Constructor Summary
TokenStreamSelector()
          Enabled:
 
Method Summary
 void addInputStream(TokenStream stream, String key)
          Enabled:
 TokenStream getCurrentStream()
          Enabled: Return the stream from tokens are being pulled at the moment.
 TokenStream getStream(String sname)
          Enabled:
 Token nextToken()
          Enabled:
 TokenStream pop()
          Enabled:
 void push(String sname)
          Enabled:
 void push(TokenStream stream)
          Enabled:
 void retry()
          Enabled: Abort recognition of current Token and try again.
 void select(String sname)
          Enabled:
 void select(TokenStream stream)
          Enabled: Set the stream without pushing old stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStreamNames

protected Hashtable inputStreamNames
The set of inputs to the MUX


input

protected TokenStream input
The currently-selected token stream input


streamStack

protected Stack streamStack
Used to track stack of input streams

Constructor Detail

TokenStreamSelector

public TokenStreamSelector()
Enabled:

Method Detail

addInputStream

public void addInputStream(TokenStream stream,
                           String key)
Enabled:


getCurrentStream

public TokenStream getCurrentStream()
Enabled: Return the stream from tokens are being pulled at the moment.


getStream

public TokenStream getStream(String sname)
Enabled:


nextToken

public Token nextToken()
                throws TokenStreamException
Enabled:

Specified by:
nextToken in interface TokenStream
TokenStreamException

pop

public TokenStream pop()
Enabled:


push

public void push(TokenStream stream)
Enabled:


push

public void push(String sname)
Enabled:


retry

public void retry()
           throws TokenStreamRetryException
Enabled: Abort recognition of current Token and try again. A stream can push a new stream (for include files for example, and then retry(), which will cause the current stream to abort back to this.nextToken(). this.nextToken() then asks for a token from the current stream, which is the new "substream."

TokenStreamRetryException

select

public void select(TokenStream stream)
Enabled: Set the stream without pushing old stream


select

public void select(String sname)
            throws IllegalArgumentException
Enabled:

IllegalArgumentException


comments?