Method: ListTokenSource#initialize

Defined in:
lib/antlr4/ListTokenSource.rb

#initialize(_tokens, source_name = nil) ⇒ ListTokenSource

Returns a new instance of ListTokenSource.

Raises:

  • (ReferenceError)


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/antlr4/ListTokenSource.rb', line 23

def initialize(_tokens, source_name=nil)
    raise ReferenceError.new("tokens cannot be null") if tokens.nil? 
    @tokens = _tokens
    @sourceName = source_name
    # The index into {@link #tokens} of token to return by the next call to
    # {@link #nextToken}. The end of the input is indicated by this value
    # being greater than or equal to the number of items in {@link #tokens}.
    @pos = 0
    # This field caches the EOF token for the token source.
    @eofToken = nil
    # This is the backing field for {@link #getTokenFactory} and
    @factory = CommonTokenFactory.DEFAULT
end