summaryrefslogtreecommitdiff
path: root/ext/ripper/tools/list-scan-event-ids.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ripper/tools/list-scan-event-ids.rb')
-rwxr-xr-xext/ripper/tools/list-scan-event-ids.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/ripper/tools/list-scan-event-ids.rb b/ext/ripper/tools/list-scan-event-ids.rb
new file mode 100755
index 0000000000..6f25362b5d
--- /dev/null
+++ b/ext/ripper/tools/list-scan-event-ids.rb
@@ -0,0 +1,32 @@
+#
+# list-scan-event-ids.rb
+#
+
+require 'getopts'
+
+def usage(status)
+ (status == 0 ? $stdout : $stderr).puts(<<EOS)
+Usage: #{File.basename($0)} eventids2.c
+ -a print IDs with arity.
+EOS
+ exit status
+end
+
+def main
+ ok = getopts('a', 'help')
+ usage 0 if $OPT_help
+ usage 1 unless ok
+ extract_ids(ARGF).sort.each do |id|
+ if $OPT_a
+ puts "#{id} 1"
+ else
+ puts id
+ end
+ end
+end
+
+def extract_ids(f)
+ (f.read.scan(/ripper_id_(\w+)/).flatten - ['scan']).uniq
+end
+
+main