Top Description Fields Constructors Methods
org.antlr.runtime

public Class UnbufferedTokenStream

extends LookaheadStream<Token>
implements TokenStream
Class Inheritance
All Implemented Interfaces
org.antlr.runtime.TokenStream, org.antlr.runtime.IntStream
Imports
org.antlr.runtime.misc.LookaheadStream

A token stream that pulls tokens from the code source on-demand and without tracking a complete buffer of the tokens. This stream buffers the minimum number of tokens possible. It's the same as OnDemandTokenStream except that OnDemandTokenStream buffers all tokens. You can't use this stream if you pass whitespace or other off-channel tokens to the parser. The stream can't ignore off-channel tokens. You can only look backwards 1 token: LT(-1). Use this when you need to read from a socket or other infinite stream.
See Also
BufferedTokenStream, CommonTokenStream

Field Summary

Modifier and TypeField and Description
protected int
channel

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

protected int
protected TokenSource
Inherited from org.antlr.runtime.misc.LookaheadStream:
currentElementIndexeoflastMarkermarkDepthprevElementUNINITIALIZED_EOF_ELEMENT_INDEX

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Token
get(int i)

Implements org.antlr.runtime.TokenStream.get.

Get a token at an absolute index i; 0..n-1.
public String
getSourceName()

Implements org.antlr.runtime.IntStream.getSourceName.

Where are you getting symbols from?
public TokenSource
getTokenSource()

Implements org.antlr.runtime.TokenStream.getTokenSource.

Where is this stream pulling tokens from?
public boolean
public int
LA(int i)

Implements org.antlr.runtime.IntStream.LA.

Get int at current input pointer + i ahead where i=1 is next int.
public Token
nextElement()

Implements abstract org.antlr.runtime.misc.LookaheadStream.nextElement.

Implement nextElement to supply a stream of elements to this lookahead buffer.
public String
toString(int start, int stop)

Implements org.antlr.runtime.TokenStream.toString.

Return the text of all tokens from start to stop, inclusive.
public String
toString(Token start, Token stop)

Implements org.antlr.runtime.TokenStream.toString.

Because the user is not required to use a token with an index stored in it, we must provide a means for two token objects themselves to indicate the start/end location.
Inherited from org.antlr.runtime.misc.LookaheadStream:
consumefillindexLBLTmarkreleaseremoveresetrewindrewindseeksizesyncAhead

Field Detail

channelback to summary
protected int channel

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

tokenIndexback to summary
protected int tokenIndex
tokenSourceback to summary
protected TokenSource tokenSource

Constructor Detail

UnbufferedTokenStreamback to summary
public UnbufferedTokenStream(TokenSource tokenSource)

Method Detail

getback to summary
public Token get(int i)

Implements org.antlr.runtime.TokenStream.get.

Doc from org.antlr.runtime.TokenStream.get.

Get a token at an absolute index i; 0..n-1. This is really only needed for profiling and debugging and token stream rewriting. If you don't want to buffer up tokens, then this method makes no sense for you. Naturally you can't use the rewrite stream feature. I believe DebugTokenStream can easily be altered to not use this method, removing the dependency.

Annotations
@Override
getSourceNameback to summary
public String getSourceName()

Implements org.antlr.runtime.IntStream.getSourceName.

Doc from org.antlr.runtime.IntStream.getSourceName.

Where are you getting symbols from? Normally, implementations will pass the buck all the way to the lexer who can ask its input stream for the file name or whatever.

Annotations
@Override
getTokenSourceback to summary
public TokenSource getTokenSource()

Implements org.antlr.runtime.TokenStream.getTokenSource.

Doc from org.antlr.runtime.TokenStream.getTokenSource.

Where is this stream pulling tokens from? This is not the name, but the object that provides Token objects.

Annotations
@Override
isEOFback to summary
public boolean isEOF(Token o)

Implements abstract org.antlr.runtime.misc.LookaheadStream.isEOF.

Annotations
@Override
LAback to summary
public int LA(int i)

Implements org.antlr.runtime.IntStream.LA.

Doc from org.antlr.runtime.IntStream.LA.

Get int at current input pointer + i ahead where i=1 is next int. Negative indexes are allowed. LA(-1) is previous token (token just matched). LA(-i) where i is before first token should yield -1, invalid char / EOF.

Annotations
@Override
nextElementback to summary
public Token nextElement()

Implements abstract org.antlr.runtime.misc.LookaheadStream.nextElement.

Doc from org.antlr.runtime.misc.LookaheadStream.nextElement.

Implement nextElement to supply a stream of elements to this lookahead buffer. Return EOF upon end of the stream we're pulling from.

Annotations
@Override
toStringback to summary
public String toString(int start, int stop)

Implements org.antlr.runtime.TokenStream.toString.

Doc from org.antlr.runtime.TokenStream.toString.

Return the text of all tokens from start to stop, inclusive. If the stream does not buffer all the tokens then it can just return "" or null; Users should not access $ruleLabel.text in an action of course in that case.

Annotations
@Override
toStringback to summary
public String toString(Token start, Token stop)

Implements org.antlr.runtime.TokenStream.toString.

Doc from org.antlr.runtime.TokenStream.toString.

Because the user is not required to use a token with an index stored in it, we must provide a means for two token objects themselves to indicate the start/end location. Most often this will just delegate to the other toString(int,int). This is also parallel with the TreeNodeStream.toString(Object,Object).

Annotations
@Override