class RPStringScanner

Public Instance Methods

begin_of_line?() click to toggle source
# File lib/ruby_parser_extras.rb, line 54
def begin_of_line?
  pos == 0 or string[pos-1] == \n\
end
current_line() click to toggle source

if ENV then

alias :old_getch :getch
def getch
  warn({:getch => caller[0]}.inspect)
  old_getch
end

end

# File lib/ruby_parser_extras.rb, line 33
def current_line # HAHA fuck you (HACK)
  string[0..pos][%r\A.*__LINE__/].split(%r\n/).size
end
getch() click to toggle source
# File lib/ruby_parser_extras.rb, line 64
def getch
  c = self.old_getch
  p :getch => [c, caller.first]
  c
end
Also aliased as: old_getch
lineno() click to toggle source
# File lib/ruby_parser_extras.rb, line 37
def lineno
  string[0...pos].count("\n") + 1
end
old_getch() click to toggle source
Alias for: getch
old_scan(re) click to toggle source
Alias for: scan
scan(re) click to toggle source
# File lib/ruby_parser_extras.rb, line 71
def scan re
  s = old_scan re
  p :scan => [s, caller.first] if s
  s
end
Also aliased as: old_scan
unread(c) click to toggle source

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 43
def unread c # TODO: remove this entirely - we should not need it
  return if c.nil? # UGH
  warn({:unread => caller[0]}.inspect) if ENV['TALLY']
  string[pos, 0] = c
end
unread_many(str) click to toggle source
# File lib/ruby_parser_extras.rb, line 49
def unread_many str # TODO: remove this entirely - we should not need it
  warn({:unread_many => caller[0]}.inspect) if ENV['TALLY']
  string[pos, 0] = str
end
was_begin_of_line() click to toggle source
# File lib/ruby_parser_extras.rb, line 58
def was_begin_of_line # TODO: kill me
  pos <= 2 or string[pos-2] == \n\
end