summaryrefslogtreecommitdiffstats
path: root/ext/ripper/tools
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-19 19:49:56 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-19 19:49:56 +0000
commit30e167b31080d8f4e9bc540fe36a2a8589d90b5d (patch)
treeeaa106de94064b044b41defeda51c1e18140a12f /ext/ripper/tools
parent8d6da74378fc60945a0845d0d405b0268d90b3c4 (diff)
downloadruby-30e167b31080d8f4e9bc540fe36a2a8589d90b5d.tar.gz
ruby-30e167b31080d8f4e9bc540fe36a2a8589d90b5d.tar.xz
ruby-30e167b31080d8f4e9bc540fe36a2a8589d90b5d.zip
* ext/ripper/ripper.rb.in: new const Ripper::PARSER_EVENT_TABLE.
* ext/ripper/ripper.rb.in: new const Ripper::SCANNER_EVENT_TABLE. * ext/ripper/lib/ripper.rb: sync with ripper.rb.in. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/ripper/tools')
-rwxr-xr-xext/ripper/tools/generate-ripper_rb.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/ext/ripper/tools/generate-ripper_rb.rb b/ext/ripper/tools/generate-ripper_rb.rb
index 9d33bddc4..b85d2745a 100755
--- a/ext/ripper/tools/generate-ripper_rb.rb
+++ b/ext/ripper/tools/generate-ripper_rb.rb
@@ -2,6 +2,12 @@
def main
template, ids1, ids2 = *ARGV
+ print <<header
+#
+# This file is automatically generated from #{template} and parse.y.
+# DO NOT MODIFY!!!!!!
+#
+header
File.foreach(template) do |line|
case line
when /\A\#include ids1/
@@ -13,7 +19,7 @@ def main
id, arity = line.split
arity = arity.to_i
puts
- puts " def on__#{id}(#{argdecl(arity)})"
+ puts " def on__#{id}#{paramdecl(arity)}"
puts " #{arity == 0 ? 'nil' : 'a'}"
puts " end"
end
@@ -35,20 +41,21 @@ def main
end
def print_items(ids)
- comma = "\n"
- ids.each do |id|
+ comma = ''
+ ids.each do |id, arity|
print comma; comma = ",\n"
- print " #{id.intern.inspect}"
+ print " #{id.intern.inspect} => #{arity}"
end
puts
end
def read_ids(path)
- File.readlines(path).map {|line| line.split[0] }
+ File.readlines(path).map {|line| line.split }
end
-def argdecl(n)
- %w(a b c d e f g h i j k l m)[0, n].join(', ')
+def paramdecl(n)
+ return '' if n == 0
+ '(' + %w(a b c d e f g h i j k l m)[0, n].join(', ') + ')'
end
main