Method: Antlr4::Runtime::CodePointCharStream#text
- Defined in:
- lib/antlr4/runtime/code_point_char_stream.rb
#text(interval) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/antlr4/runtime/code_point_char_stream.rb', line 13 def text(interval) start_idx = [interval.a, @size].min len = [interval.b - interval.a + 1, @size - start_idx].min # We know the maximum code point in byte_array is U+00FF, # so we can treat this as if it were ISO-8859-1, aka Latin-1, # which shares the same code points up to 0xFF. chars = @byte_array.slice(start_idx, len) result = '' chars.each do |c| result << c end result end |