# File lib/ruby_parser_extras.rb, line 48 def charpos string_to_pos.length end
# File lib/ruby_parser_extras.rb, line 59 def current_line # HAHA fuck you (HACK) string_to_pos[%r\A.*__LINE__/].split(%r\n/).size end
# File lib/ruby_parser_extras.rb, line 104 def d o $stderr.puts o.inspect end
# File lib/ruby_parser_extras.rb, line 63 def extra_lines_added @extra_lines_added ||= 0 end
# File lib/ruby_parser_extras.rb, line 67 def extra_lines_added= val @extra_lines_added = val end
# File lib/ruby_parser_extras.rb, line 90 def getch c = self.old_getch p :getch => [c, caller.first] c end
# File lib/ruby_parser_extras.rb, line 71 def lineno string[0...charpos].count("\n") + 1 - extra_lines_added end
# File lib/ruby_parser_extras.rb, line 97 def scan re s = old_scan re d :scan => [s, caller.first] if s s end
# File lib/ruby_parser_extras.rb, line 39 def string_to_pos string.byteslice(0, pos) end
TODO: once we get rid of these, we can make things like TODO: #current_line and lineno much more accurate and easy to do
# File lib/ruby_parser_extras.rb, line 78 def unread_many str # TODO: remove this entirely - we should not need it warn({:unread_many => caller[0]}.inspect) if ENV['TALLY'] self.extra_lines_added += str.count("\n") - 1 begin string[charpos, 0] = str rescue IndexError # HACK -- this is a bandaid on a dirty rag on an open festering wound end end