Home | Download | News | Wiki | About ANTLR | Feedback | Support | Bugs


Latest version is 2.7.7.
Download now! »

Download
» Home
» Download
» News
»Using ANTLR
» Documentation
» Wiki
» FAQ
» Articles
» Grammars
» File Sharing
» Code API
» Tech Support
» Bug Tracking
»About ANTLR
» What is ANTLR
» Why use ANTLR
» Showcase
» Testimonials
» Getting Started
» Software License
» ANTLR WebLogs
» ANTLR Workshops
»StringTemplate
»TML
»PCCTS
»Feedback
»Credits
»Contact


Support StringTemplate, ANTLR Project by making a donation! Terence often pays for things like the antlr.org server, conference travel, and this site design (that alone cost US$1000). Buy him a beer and pizza remotely ;)

Search



TokenStreamSelector


antlr
Class TokenStreamSelector

java.lang.Object
  extended byantlr.TokenStreamSelector
All Implemented Interfaces:
TokenStream

public class TokenStreamSelector
extends java.lang.Object
implements TokenStream

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.


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.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenStreamSelector

public TokenStreamSelector()
Method Detail

addInputStream

public void addInputStream(TokenStream stream,
                           java.lang.String key)

getCurrentStream

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


getStream

public TokenStream getStream(java.lang.String sname)

nextToken

public Token nextToken()
                throws TokenStreamException
Specified by:
nextToken in interface TokenStream
Throws:
TokenStreamException

pop

public TokenStream pop()

push

public void push(TokenStream stream)

push

public void push(java.lang.String sname)

retry

public void retry()
           throws TokenStreamRetryException
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."

Throws:
TokenStreamRetryException

select

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


select

public void select(java.lang.String sname)
            throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException