Skip to content

Instantly share code, notes, and snippets.

@rue
Created September 18, 2008 23:26
Show Gist options
  • Select an option

  • Save rue/11508 to your computer and use it in GitHub Desktop.

Select an option

Save rue/11508 to your computer and use it in GitHub Desktop.
=> #<OpenStruct lines=[[0, -1, 57], [0, 17, 522], [18, 35, 523], [36, 53, 524], [54, 71, 525], [72, 89, 526], [90, 113, 528], [114, 128, 529], [129, 147, 531],
[148, 172, 534], [173, 193, 536], [194, 214, 537], [215, 245, 539], [246, 280, 541], [281, 307, 542], [308, 334, 543], [335, 361, 545], [362, 383, 546], [384,
420, 548], [421, 460, 550], [461, 519, 552], [520, 550, 554], [551, 578, 556], [579, 605, 559], [606, 622, 560], [623, 649, 562], [650, 656, 563], [657, 683,
564], [684, 717, 565], [718, 733, 566], [734, 749, 577], [750, 776, 578], [777, 793, 580], [794, 806, 583], [807, 825, 584], [826, 838, 587], [839, 862, 588]],
required_args=3, local_names=[:func, :term, :paren, :awords, :escape, :expand, :regexp, :symbol, :paren_re, :term_re, :c], __ivars__=nil, total_args=3,
name=:tokadd_string, primitive=nil, file=:"lib/compiler/ruby_lexer.rb", splat=nil, iseq=[18, 0, 23, 0, 36, 1, 1, 71, 76, 10, 14, 2, 8, 15, 3, 17, 3, 16, 18, 0,
23, 2, 36, 3, 1, 71, 76, 10, 32, 2, 8, 33, 3, 17, 4, 16, 18, 0, 23, 4, 36, 5, 1, 71, 76, 10, 50, 2, 8, 51, 3, 17, 5, 16, 18, 0, 23, 6, 36, 7, 1, 71, 76, 10, 68,
2, 8, 69, 3, 17, 6, 16, 18, 0, 23, 8, 36, 9, 1, 71, 76, 10, 86, 2, 8, 87, 3, 17, 7, 16, 18, 2, 35, 10, 9, 99, 1, 8, 111, 23, 11, 23, 11, 18, 2, 36, 12, 1, 36, 13,
1, 17, 8, 16, 23, 11, 23, 11, 18, 1, 36, 14, 1, 36, 15, 1, 17, 9, 16, 7, 57, 1, 35, 16, 35, 17, 10, 820, 1, 17, 10, 16, 18, 8, 15, 9, 158, 16, 7, 57, 1, 35, 18,
18, 8, 36, 19, 1, 9, 173, 7, 15, 35, 20, 72, 36, 21, 1, 36, 22, 1, 8, 789, 7, 35, 23, 71, 76, 15, 9, 192, 16, 7, 57, 1, 35, 24, 18, 9, 36, 25, 1, 9, 215, 7, 57,
1, 35, 26, 15, 35, 27, 72, 36, 28, 1, 36, 29, 1, 16, 1, 8, 821, 8, 789, 7, 57, 1, 35, 30, 18, 9, 36, 31, 1, 9, 240, 7, 15, 35, 32, 72, 36, 33, 1, 36, 34, 1, 8,
789, 18, 3, 15, 9, 271, 16, 7, 57, 1, 35, 35, 6, 36, 15, 61, 9, 268, 16, 23, 11, 6, 37, 71, 36, 38, 2, 64, 36, 36, 39, 1, 15, 10, 306, 16, 18, 5, 15, 9, 306, 16,
7, 57, 1, 35, 40, 6, 41, 15, 61, 9, 303, 16, 23, 11, 6, 42, 71, 36, 43, 2, 64, 41, 36, 44, 1, 9, 329, 7, 57, 1, 35, 45, 15, 35, 46, 72, 36, 47, 1, 36, 48, 1, 16,
1, 8, 821, 8, 789, 18, 3, 15, 9, 360, 16, 7, 57, 1, 35, 49, 6, 50, 15, 61, 9, 357, 16, 23, 11, 6, 51, 71, 36, 52, 2, 64, 50, 36, 53, 1, 9, 378, 7, 57, 1, 35, 54,
6, 55, 48, 36, 56, 1, 16, 8, 129, 8, 789, 18, 5, 15, 9, 409, 16, 7, 57, 1, 35, 57, 6, 58, 15, 61, 9, 406, 16, 23, 11, 6, 51, 71, 36, 59, 2, 64, 58, 36, 60, 1, 9,
415, 8, 129, 8, 789, 18, 3, 15, 9, 446, 16, 7, 57, 1, 35, 61, 6, 62, 15, 61, 9, 443, 16, 23, 11, 6, 63, 71, 36, 64, 2, 64, 62, 36, 65, 1, 9, 455, 6, 66, 48, 17,
10, 8, 789, 18, 5, 15, 9, 486, 16, 7, 57, 1, 35, 67, 6, 68, 15, 61, 9, 483, 16, 23, 11, 6, 69, 71, 36, 70, 2, 64, 68, 36, 71, 1, 15, 10, 515, 16, 7, 57, 1, 35,
72, 6, 73, 15, 61, 9, 512, 16, 23, 11, 6, 51, 71, 36, 74, 2, 64, 73, 36, 75, 1, 9, 520, 1, 8, 789, 7, 57, 1, 35, 76, 6, 77, 15, 61, 9, 542, 16, 23, 11, 6, 78, 71,
36, 79, 2, 64, 77, 36, 80, 1, 9, 573, 18, 4, 9, 564, 7, 57, 1, 35, 81, 6, 82, 48, 36, 83, 1, 8, 565, 1, 16, 6, 82, 48, 17, 10, 8, 789, 18, 6, 15, 9, 604, 16, 7,
57, 1, 35, 84, 6, 85, 15, 61, 9, 601, 16, 23, 11, 6, 86, 71, 36, 87, 2, 64, 85, 36, 88, 1, 9, 617, 7, 18, 1, 36, 89, 1, 16, 8, 129, 8, 789, 18, 5, 15, 9, 648, 16,
7, 57, 1, 35, 90, 6, 91, 15, 61, 9, 645, 16, 23, 11, 6, 86, 71, 36, 92, 2, 64, 91, 36, 93, 1, 9, 657, 7, 35, 94, 17, 10, 8, 789, 7, 57, 1, 35, 95, 6, 96, 15, 61,
9, 679, 16, 23, 11, 6, 86, 71, 36, 97, 2, 64, 96, 36, 98, 1, 9, 734, 7, 57, 1, 35, 99, 18, 9, 36, 100, 1, 15, 10, 716, 16, 18, 2, 35, 101, 15, 10, 716, 16, 7, 57,
1, 35, 102, 18, 8, 36, 103, 1, 10, 731, 7, 57, 1, 35, 104, 6, 82, 48, 36, 105, 1, 8, 732, 1, 8, 789, 7, 57, 1, 35, 106, 35, 107, 17, 10, 16, 18, 7, 15, 9, 775,
16, 7, 57, 1, 35, 108, 6, 109, 15, 61, 9, 772, 16, 23, 11, 6, 110, 71, 36, 111, 2, 64, 109, 36, 112, 1, 9, 788, 7, 6, 113, 48, 57, 1, 36, 114, 1, 8, 789, 1, 16,
18, 10, 10, 805, 7, 57, 1, 35, 115, 35, 116, 17, 10, 8, 806, 1, 16, 7, 57, 1, 35, 117, 18, 10, 36, 118, 1, 16, 8, 129, 1, 16, 18, 10, 10, 837, 7, 57, 1, 35, 119,
35, 120, 17, 10, 8, 838, 1, 16, 7, 57, 1, 35, 121, 35, 122, 9, 856, 23, 123, 26, 124, 17, 10, 8, 857, 1, 16, 18, 10, 12, 12], literals=[:STR_FUNC_AWORDS, :&,
:STR_FUNC_ESCAPE, :&, :STR_FUNC_EXPAND, :&, :STR_FUNC_REGEXP, :&, :STR_FUNC_SYMBOL, :&, :nil?, :Regexp, :escape, :new, :escape, :new, :src, :eos?, :src, :scan,
:nest, :+, :nest=, :nest, :src, :scan, :src, :pos, :-, :pos=, :src, :scan, :nest, :-, :nest=, :src, nil, "\\s", :new, :scan, :src, nil, "#(?=[\\$\\@\\{])", :new,
:scan, :src, :pos, :-, :pos=, :src, nil, "\\\\\\n", :new, :scan, :token_buffer, "\n", :<<, :src, nil, :new, :scan, :src, nil, "\\\\\\s", :new, :scan, " ", :src,
nil, "#(?!\\n)", :new, :scan, :src, nil, :new, :scan, :src, nil, "\\\\\\\\", :new, :scan, :token_buffer, "\\", :<<, :src, nil, "\\\\", :new, :check,
:tokadd_escape, :src, nil, :new, :scan, :read_escape, :src, nil, :new, :scan, :src, :scan, :nil?, :src, :scan, :token_buffer, :<<, :src, :getch, :src, nil, "\\0",
:new, :scan, "symbol cannot contain '\\0'", :rb_compile_error, :src, :matched, :token_buffer, :<<, :src, :matched, :src, :eos?, :RubyLexer, :EOF], stack_size=33,
exceptions=[], local_count=11>
irb(main):139:0>
---
##
# Returns the next character in _@data_ as a Fixnum.
#--
# The current format uses a one-character type indicator
# followed by a newline. If that format changes, this
# will break and we'll fix it.
#++
def next_type
chr = @data[@start]
@start += 2
chr
end
private :next_type
##
# Returns the next string in _@data_ including the trailing
# "\n" character.
def next_string
idx = @data[@start..-1].index("\n") + @start
str = @data[@start..idx]
@start = idx + 1
str
end
private :next_string
##
# Returns the next _count_ bytes in _@data_.
def next_bytes(count)
str = @data[@start, count]
@start += count
str
end
private :next_bytes
##
# Moves the next read pointer ahead by one character.
def discard
@start += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment