mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
c971589817
* ext/ripper/MANIFEST: new file. * ext/ripper/README: new file. * ext/ripper/depend: new file. * ext/ripper/extconf.rb: new file. * ext/ripper/eventids2.c: new file. * ext/ripper/ripper.rb.in: new file. * ext/ripper/lib/ripper.rb: new file. * ext/ripper/test/check-event-arity.rb: new file. * ext/ripper/test/check-event-coverage.sh: new file. * ext/ripper/test/check-scanner-event-coverage.rb: new file. * ext/ripper/test/list-called-events.rb: new file. * ext/ripper/test/src_rb: new file. * ext/ripper/test/validate.rb: new file. * ext/ripper/tools/generate-eventids1.rb: new file. * ext/ripper/tools/generate-param-macros.rb: new file. * ext/ripper/tools/generate-ripper_rb.rb: new file. * ext/ripper/tools/list-parse-event-ids.rb: new file. * ext/ripper/tools/list-scan-event-ids.rb: new file. * ext/ripper/tools/preproc.rb: new file. * ext/ripper/tools/strip.rb: new file. * test/ripper: ripper tests added. * test/ripper/dummyparser.rb: new file. * test/ripper/test_parser_events.rb: new file. * test/ripper/test_scanner_events.rb: new file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
68 lines
986 B
Ruby
68 lines
986 B
Ruby
require 'ripper.so'
|
|
|
|
class R < Ripper
|
|
def initialize(*args)
|
|
super
|
|
@lineno = 0
|
|
end
|
|
|
|
def parse
|
|
result = super
|
|
puts "#{@lineno}:result: #{rawVALUE(result)}"
|
|
validate_object result
|
|
p result
|
|
result
|
|
end
|
|
|
|
def on__nl(str)
|
|
@lineno += 1
|
|
end
|
|
|
|
def on__ignored_nl(str)
|
|
@lineno += 1
|
|
end
|
|
|
|
def on__comment(cmt)
|
|
@lineno += 1
|
|
end
|
|
|
|
def on__embdoc_beg(str)
|
|
@lineno += 1
|
|
end
|
|
|
|
def on__embdoc(str)
|
|
@lineno += 1
|
|
end
|
|
|
|
def on__embdoc_end(str)
|
|
@lineno += 1
|
|
end
|
|
|
|
def method_missing(mid, *args)
|
|
puts mid
|
|
args.each_with_index do |a,idx|
|
|
puts "#{@lineno}:#{mid}\##{idx+1}: #{rawVALUE(a)}"
|
|
validate_object a
|
|
p a
|
|
end
|
|
args[0]
|
|
end
|
|
|
|
def warn(*args)
|
|
end
|
|
|
|
def warning(*args)
|
|
end
|
|
|
|
unless respond_to?(:validate_object)
|
|
def validate_object(x)
|
|
x
|
|
end
|
|
def rawVALUE(x)
|
|
x.object_id
|
|
end
|
|
end
|
|
end
|
|
|
|
fname = (ARGV[0] || 'test/src_rb')
|
|
R.new(File.read(fname), fname, 1).parse
|