Class: RPStringScanner

Inherits:
StringScanner
  • Object
show all
Defined in:
lib/ruby_parser_extras.rb

Overview

:startdoc:

Instance Method Summary collapse

Instance Method Details

#d(o) ⇒ Object



88
89
90
# File 'lib/ruby_parser_extras.rb', line 88

def d o
  $stderr.puts o.inspect
end

#getchObject



73
74
75
76
77
# File 'lib/ruby_parser_extras.rb', line 73

def getch
  c = self.old_getch
  p :getch => [c, caller.first]
  c
end

#old_getchObject



72
# File 'lib/ruby_parser_extras.rb', line 72

alias :old_getch :getch

#old_scanObject



79
# File 'lib/ruby_parser_extras.rb', line 79

alias :old_scan :scan

#scan(re) ⇒ Object



80
81
82
83
84
85
# File 'lib/ruby_parser_extras.rb', line 80

def scan re
  s = old_scan re
  where = caller[1].split(/:/).first(2).join(":")
  d :scan => [s, where] if s
  s
end

#string_to_posObject



42
43
44
# File 'lib/ruby_parser_extras.rb', line 42

def string_to_pos
  string.byteslice(0, pos)
end

#unread_many(str) ⇒ Object

TODO: remove this entirely - we should not need it



62
63
64
65
66
67
68
69
# File 'lib/ruby_parser_extras.rb', line 62

def unread_many str # TODO: remove this entirely - we should not need it
  warn({:unread_many => caller[0]}.inspect) if ENV['TALLY']
  begin
    string[charpos, 0] = str
  rescue IndexError
    # HACK -- this is a bandaid on a dirty rag on an open festering wound
  end
end