Method: ANTLR3::StringStream#initialize

Defined in:
lib/antlr3/streams.rb,
lib/antlr3/streams.rb

#initialize(data, options = {}) ⇒ StringStream

creates a new StringStream object where data is the string data to stream. accepts the following options in a symbol-to-value hash:

:file or :name

the (file) name to associate with the stream; default: '(string)'

:line

the initial line number; default: 1

:column

the initial column number; default: 0



397
398
399
400
401
402
403
404
405
406
# File 'lib/antlr3/streams.rb', line 397

def initialize( data, options = {} )      # for 1.9
  @string   = data.to_s.encode( Encoding::UTF_8 ).freeze
  @data     = @string.codepoints.to_a.freeze
  @position = options.fetch :position, 0
  @line     = options.fetch :line, 1
  @column   = options.fetch :column, 0
  @markers  = []
  @name   ||= options[ :file ] || options[ :name ] # || '(string)'
  mark
end