|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectantlr.TokenStreamSelector
public class TokenStreamSelector
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 java.util.Hashtable |
inputStreamNames
The set of inputs to the MUX |
protected Stack |
streamStack
Used to track stack of input streams |
Constructor Summary | |
---|---|
TokenStreamSelector()
|
Method Summary | |
---|---|
void |
addInputStream(TokenStream stream,
java.lang.String key)
|
TokenStream |
getCurrentStream()
Return the stream from tokens are being pulled at the moment. |
java.lang.String |
getEntireText()
Returns the entire text input to the lexer. |
TokenOffsetInfo |
getOffsetInfo(Token token)
Returns the offset information for the token |
TokenStream |
getStream(java.lang.String sname)
|
Token |
nextToken()
|
TokenStream |
pop()
|
void |
push(java.lang.String sname)
|
void |
push(TokenStream stream)
|
void |
retry()
Abort recognition of current Token and try again. |
void |
select(java.lang.String sname)
|
void |
select(TokenStream stream)
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 |
---|
protected java.util.Hashtable inputStreamNames
protected TokenStream input
protected Stack streamStack
Constructor Detail |
---|
public TokenStreamSelector()
Method Detail |
---|
public void addInputStream(TokenStream stream, java.lang.String key)
public TokenStream getCurrentStream()
public TokenStream getStream(java.lang.String sname)
public Token nextToken() throws TokenStreamException
nextToken
in interface TokenStream
TokenStreamException
public TokenStream pop()
public void push(TokenStream stream)
public void push(java.lang.String sname)
public void retry() throws TokenStreamRetryException
TokenStreamRetryException
public void select(TokenStream stream)
public void select(java.lang.String sname) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public java.lang.String getEntireText()
IASDebugStream
getEntireText
in interface IASDebugStream
null
, if error occured or System.in was used.public TokenOffsetInfo getOffsetInfo(Token token)
IASDebugStream
getOffsetInfo
in interface IASDebugStream
token
- the token whose information need to be retrieved
null
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |