diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/ripper/tools/preproc.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/ripper/tools/preproc.rb')
-rwxr-xr-x | trunk/ext/ripper/tools/preproc.rb | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/trunk/ext/ripper/tools/preproc.rb b/trunk/ext/ripper/tools/preproc.rb deleted file mode 100755 index 06397cea05..0000000000 --- a/trunk/ext/ripper/tools/preproc.rb +++ /dev/null @@ -1,91 +0,0 @@ -# $Id$ - -require 'optparse' - -def main - output = nil - parser = OptionParser.new - parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>" - parser.on('--output=PATH', 'An output file.') {|path| - output = path - } - parser.on('--help', 'Prints this message and quit.') { - puts parser.help - exit true - } - begin - parser.parse! - rescue OptionParser::ParseError => err - $stderr.puts err.message - $stderr.puts parser.help - exit false - end - unless ARGV.size == 1 - abort "wrong number of arguments (#{ARGV.size} for 1)" - end - out = "" - File.open(ARGV[0]) {|f| - prelude f, out - grammar f, out - usercode f, out - } - if output - File.open(output, 'w') {|f| - f.write out - } - else - print out - end -end - -def prelude(f, out) - while line = f.gets - case line - when %r</\*%%%\*/> - out << '/*' << $/ - when %r</\*%> - out << '*/' << $/ - when %r<%\*/> - out << $/ - when /\A%%/ - out << '%%' << $/ - return - when /\A%token/ - out << line.sub(/<\w+>/, '<val>') - when /\A%type/ - out << line.sub(/<\w+>/, '<val>') - else - out << line - end - end -end - -def grammar(f, out) - while line = f.gets - case line - when %r</\*%%%\*/> - out << '#if 0' << $/ - when %r</\*%c%\*/> - out << '/*' << $/ - when %r</\*%c> - out << '*/' << $/ - when %r</\*%> - out << '#endif' << $/ - when %r<%\*/> - out << $/ - when /\A%%/ - out << '%%' << $/ - return - else - out << line - end - end -end - -def usercode(f, out) - while line = f.gets - out << line - end -end - -main |