C# Class Antlr4.Runtime.ListTokenSource

Provides an implementation of ITokenSource as a wrapper around a list of IToken objects.

If the final token in the list is an TokenConstants.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.

Inheritance: ITokenSource
Show file Open project: antlr/antlr4 Class Usage Examples

Protected Properties

Property Type Description
eofToken IToken
i int
tokens IList

Public Methods

Method Description
ListTokenSource ( IList tokens ) : System

Constructs a new ListTokenSource instance from the specified collection of IToken objects.

ListTokenSource ( IList tokens, string sourceName ) : System

Constructs a new ListTokenSource instance from the specified collection of IToken objects and source name.

NextToken ( ) : IToken

Method Details

ListTokenSource() public method

Constructs a new ListTokenSource instance from the specified collection of IToken objects.
/// NullPointerException /// if /// /// is /// ///
public ListTokenSource ( IList tokens ) : System
tokens IList /// The collection of /// /// objects to provide as a /// /// . ///
return System

ListTokenSource() public method

Constructs a new ListTokenSource instance from the specified collection of IToken objects and source name.
/// NullPointerException /// if /// /// is /// ///
public ListTokenSource ( IList tokens, string sourceName ) : System
tokens IList /// The collection of /// /// objects to provide as a /// /// . ///
sourceName string /// The name of the /// /// . If this value is /// /// , /// /// will attempt to infer the name from /// the next /// /// (or the previous token if the end of the input has /// been reached). ///
return System

NextToken() public method

public NextToken ( ) : IToken
return IToken

Property Details

eofToken protected property

This field caches the EOF token for the token source.
This field caches the EOF token for the token source.
protected IToken eofToken
return IToken

i protected property

The index into tokens of token to return by the next call to NextToken() . The end of the input is indicated by this value being greater than or equal to the number of items in tokens .
protected int i
return int

tokens protected property

The wrapped collection of IToken objects to return.
protected IList tokens
return IList