summaryrefslogtreecommitdiff
path: root/ext/ripper/tools/list-parse-event-ids.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-12 17:34:30 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-12 17:34:30 +0000
commitc971589817150d1850b06a49e11d11edfc489bbf (patch)
tree49ad381864fc0561cc3844ecb05600ae5dbb649b /ext/ripper/tools/list-parse-event-ids.rb
parent5bea219a9d95e58a1b2ad77637776a8e0cade1bf (diff)
* ext/ripper: ripper extention added.
* 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
Diffstat (limited to 'ext/ripper/tools/list-parse-event-ids.rb')
-rwxr-xr-xext/ripper/tools/list-parse-event-ids.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/ripper/tools/list-parse-event-ids.rb b/ext/ripper/tools/list-parse-event-ids.rb
new file mode 100755
index 0000000000..2936f9b092
--- /dev/null
+++ b/ext/ripper/tools/list-parse-event-ids.rb
@@ -0,0 +1,38 @@
+#
+# list-parse-event-ids.rb
+#
+
+require 'getopts'
+
+def usage( status )
+ (status == 0 ? $stdout : $stderr).print(<<EOS)
+Usage: #{File.basename($0)} [-a] filename
+EOS
+ exit status
+end
+
+def main
+ getopts('a') or usage(1)
+ extract_ids(ARGF).each do |id, arity|
+ if $OPT_a
+ then puts "#{id} #{arity}"
+ else puts id
+ end
+ end
+end
+
+def extract_ids( f )
+ results = []
+ f.each do |line|
+ next if /\A\#\s*define\s+s?dispatch/ === line
+ next if /ripper_dispatch/ === line
+ if a = line.scan(/dispatch(\d)\((\w+)/)
+ a.each do |arity, event|
+ results.push [event, arity.to_i]
+ end
+ end
+ end
+ results.uniq.sort
+end
+
+main