summaryrefslogtreecommitdiff
path: root/ext/ripper/tools/list-parse-event-ids.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ripper/tools/list-parse-event-ids.rb')
-rwxr-xr-xext/ripper/tools/list-parse-event-ids.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/ripper/tools/list-parse-event-ids.rb b/ext/ripper/tools/list-parse-event-ids.rb
index 84c7e4c445..a8566fcbcf 100755
--- a/ext/ripper/tools/list-parse-event-ids.rb
+++ b/ext/ripper/tools/list-parse-event-ids.rb
@@ -17,17 +17,23 @@ def main
end
def extract_ids(f)
- results = []
+ ids = {}
f.each do |line|
- next if /\A\#\s*define\s+s?dispatch/ === line
- next if /ripper_dispatch/ === 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]
+ if ids[event]
+ unless ids[event] == arity.to_i
+ $stderr.puts "arity mismatch: #{event} (#{ids[event]} vs #{arity})"
+ exit 1
+ end
+ end
+ ids[event] = arity.to_i
end
end
end
- results.uniq.sort
+ ids.to_a.sort
end
main