File: r2r_show

package info (click to toggle)
libruby2ruby-ruby 1.2.4-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 104 kB
  • ctags: 120
  • sloc: ruby: 899; sh: 15; makefile: 7
file content (33 lines) | stat: -rwxr-xr-x 560 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/ruby -ws

require 'rubygems'
require 'ruby2ruby'
require 'ruby_parser'

$h ||= false
$s ||= false

if $h then
  puts "usage: #{File.basename $0} [options] [file...]"
  puts "options:"
  puts "-h     : display usage"
  puts "-s     : print the sexp before displaying the translated ruby"

  exit 1
end

ARGV.push "-" if ARGV.empty?

parser    = RubyParser.new
ruby2ruby = Ruby2Ruby.new

ARGV.each do |file|
  ruby = file == "-" ? $stdin.read : File.read(file)

  sexp = parser.process(ruby, file)

  p sexp if $s

  puts ruby2ruby.process(sexp)
end