Method: ANTLR3::UnicodeStream#initialize

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

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

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



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/antlr3/streams/unicode.rb', line 25

def initialize( data, options = {} )    # for 1.8
  @string = data.to_s
  @string.equal?( data ) and @string = @string.clone
  @string.freeze
  @data = @string.unpack( PACK_MASK )
  @position = options.fetch :position, 0
  @line = options.fetch :line, 1
  @column = options.fetch :column, 0
  @markers = []
  @name ||= options[ :file ] || options[ :name ] # || '(string)'
  mark
end