summaryrefslogtreecommitdiff
path: root/ext/ripper/tools
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-14 11:27:36 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-14 11:27:36 +0000
commitd3bce8cb5a9c44eb4413aca819bfa4dfeceda221 (patch)
treef8aa91fcc45b24d858c07096b6996309185209fe /ext/ripper/tools
parent26a828a605a6738db2388b6487c6ddef4a48088a (diff)
* parse.y [ripper]: space event is on__sp, not on__lwsp. [ruby-dev:24257]
* ext/ripper/eventids2.c: ditto. * ext/ripper/lib/ripper.rb: ditto. * ext/ripper/depend (ripper.o): No action is needed. [ruby-dev:24260] * ext/ripper/depend: Borland make does not accept pipes in Makefile rules. [ruby-dev:24589] * ext/ripper/depend: separate rules for developpers. * ext/ripper/Makefile.dev: new file. * ext/ripper/MANIFEST: add Makefile.dev. * ext/ripper/tools/generate-eventids1.rb: read from file, not stdin. * ext/ripper/extconf.rb: clean ripper.E. * ext/ripper/tools/generate-ripper_rb.rb: #include ids1/ids2 function was lost. * ext/ripper/tools/generate-ripper_rb.rb: SCANNER_EVENTS wrongly contained parser events. * ext/ripper/lib/ripper.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/ripper/tools')
-rwxr-xr-xext/ripper/tools/generate-eventids1.rb6
-rwxr-xr-xext/ripper/tools/generate-ripper_rb.rb28
2 files changed, 21 insertions, 13 deletions
diff --git a/ext/ripper/tools/generate-eventids1.rb b/ext/ripper/tools/generate-eventids1.rb
index de0e27b89c..3d9a57e034 100755
--- a/ext/ripper/tools/generate-eventids1.rb
+++ b/ext/ripper/tools/generate-eventids1.rb
@@ -1,8 +1,6 @@
-#
-# generate-eventids1.rb
-#
+# $Id$
-ids = ARGF.map {|s| s.strip }
+ids = File.readlines(ARGV[0]).map {|s| s.split[0] }
ids.each do |id|
puts "static ID ripper_id_#{id};"
diff --git a/ext/ripper/tools/generate-ripper_rb.rb b/ext/ripper/tools/generate-ripper_rb.rb
index c6b2aea13f..9d33bddc4c 100755
--- a/ext/ripper/tools/generate-ripper_rb.rb
+++ b/ext/ripper/tools/generate-ripper_rb.rb
@@ -1,14 +1,13 @@
-#
-# generate-ripper_rb.rb
-# Creates ripper.rb, filling in default event handlers, given a basic
-# template, the list of parser events (ids1), and a list of lexer
-# events (ids2).
-#
+# $Id$
def main
template, ids1, ids2 = *ARGV
File.foreach(template) do |line|
case line
+ when /\A\#include ids1/
+ print_items read_ids(ids1)
+ when /\A\#include ids2/
+ print_items read_ids(ids2)
when /\A\#include handlers1/
File.foreach(ids1) do |line|
id, arity = line.split
@@ -35,9 +34,20 @@ def main
end
end
-# Generate generic arg list depending on arity (n)
-# n:: [Integer] arity of method
-def argdecl( n )
+def print_items(ids)
+ comma = "\n"
+ ids.each do |id|
+ print comma; comma = ",\n"
+ print " #{id.intern.inspect}"
+ end
+ puts
+end
+
+def read_ids(path)
+ File.readlines(path).map {|line| line.split[0] }
+end
+
+def argdecl(n)
%w(a b c d e f g h i j k l m)[0, n].join(', ')
end