TokenSource as a wrapper around a list
of Token objects.
If the final token in the list is an Token#EOF token, it will be used
as the EOF token for every call to nextToken after the end of the
list is reached. Otherwise, an EOF token will be created.
| Modifier and Type | Field and Description |
|---|---|
| private TokenFactory | _factory
This is the backing field for |
| protected Token | eofToken
This field caches the EOF token for the token source. |
| protected int | |
| private final String | sourceName
The name of the input source. |
| protected final List |
| Access | Constructor and Description |
|---|---|
| public | ListTokenSource(List<? extends Token>
The collection of tokens)Token objects to provide as a
TokenSource.Constructs a new |
| public | ListTokenSource(List<? extends Token>
The collection of tokens, String Token objects to provide as a
TokenSource.The name of the sourceName)TokenSource. If this value is
null, getSourceName will attempt to infer the name from
the next Token (or the previous token if the end of the input has
been reached).Constructs a new |
| Modifier and Type | Method and Description |
|---|---|
| public int | getCharPositionInLine()
Implements org. |
| public CharStream | getInputStream()
Implements org. CharStream from which this token source is currently
providing tokens.
|
| public int | getLine()
Implements org. |
| public String | getSourceName()
Implements org. |
| public TokenFactory | getTokenFactory()
Implements org. TokenFactory this token source is currently using for
creating Token objects from the input.
|
| public Token | nextToken()
Implements org. Token object from your input stream (usually a
CharStream).
|
| public void | setTokenFactory(TokenFactory
The factory)TokenFactory to use for creating tokens.Implements org. TokenFactory this token source should use for creating
Token objects from the input.
|
| _factory | back to summary |
|---|---|
| private TokenFactory _factory This is the backing field for | |
| eofToken | back to summary |
|---|---|
| protected Token eofToken This field caches the EOF token for the token source. | |
| i | back to summary |
|---|---|
| protected int i The index into | |
| sourceName | back to summary |
|---|---|
| private final String sourceName The name of the input source. If this value is | |
| tokens | back to summary |
|---|---|
| protected final List<? extends Token> tokens The wrapped collection of | |
| ListTokenSource | back to summary |
|---|---|
| public ListTokenSource(List<? extends Token> tokens) Constructs a new
| |
| ListTokenSource | back to summary |
|---|---|
| public ListTokenSource(List<? extends Token> tokens, String sourceName) Constructs a new
| |
| getCharPositionInLine | back to summary |
|---|---|
| public int getCharPositionInLine() Implements org. Doc from org. Get the index into the current line for the current position in the input stream. The first character on a line has position 0.
| |
| getInputStream | back to summary |
|---|---|
| public CharStream getInputStream() Implements org. Doc from org. Get the
| |
| getLine | back to summary |
|---|---|
| public int getLine() Implements org. Doc from org. Get the line number for the current position in the input stream. The first line in the input is line 1.
| |
| getSourceName | back to summary |
|---|---|
| public String getSourceName() Implements org. Doc from org. Gets the name of the underlying input source. This method returns a
non-null, non-empty string. If such a name is not known, this method
returns
| |
| getTokenFactory | back to summary |
|---|---|
| public TokenFactory getTokenFactory() Implements org. Doc from org. Gets the
| |
| nextToken | back to summary |
|---|---|
| public Token nextToken() Implements org. Doc from org. Return a
| |
| setTokenFactory | back to summary |
|---|---|
| public void setTokenFactory(TokenFactory factory) Implements org. Doc from org. Set the
| |