Sha256: 62527ce44c416800f8119152a47ffc720dedfef41f289159ce3d174165bb57bf

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

#!/usr/bin/env jruby

# Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
# All contributing project authors may be found in the NOTICE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

$: << File.dirname(File.dirname(__FILE__)) + '/lib'
require 'mirah'

module Java::OrgJrubyparserAst
  class Node
    def pp(indent = 0)
      return if self.invisible?
      name = ""
      name = ":#{self.name}" if respond_to? :getName
      name += " #{value.inspect}" if respond_to? :getValue
      name += " (#{depth})" if respond_to? :getDepth
      print "#{' '*indent}(#{node_name}#{name}"
      if child_nodes.size == 0
        puts ')'
      else
        puts
        indent += 2
        child_nodes.each {|n| n.pp(indent)}
        puts "#{' '*indent})"
      end
    end
  end
end

filename = ARGV.shift
case filename
when '-e'
  contents = ARGV.join(' ')
when '-', nil
  contents = $stdin.read
else
  contents = IO.read(filename)
end

puts Duby::AST.parse_ruby(contents, filename).pp

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mirah-0.0.7-java bin/jrubyp
mirah-0.0.6-java bin/jrubyp
mirah-0.0.5-java bin/jrubyp