Sha256: 1dd740fec439123435c5a9e9c238530bc06491fc621418c0351862bb8d798936
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
#!/usr/local/bin/ruby -ws require 'pp' begin require 'rubygems' rescue LoadError end require 'parse_tree' require 'sexp' $a ||= false $h ||= false $n ||= false $r ||= false $s ||= false $U ||= false $n = $n.intern if $n $u ||= ! ($U || $r) if $h then puts "usage: #{File.basename $0} [options] [file...]" puts "options:" puts "-h : display usage" puts "-a : all nodes, including newline" puts "-n=node : only display matching nodes" puts "-r : raw arrays, no sexps" puts "-s : structural sexps, strip all content and show bare tree" puts "-u : unified sexps (now the default)" puts "-U : UNunified sexps" exit 1 end ARGV.push "-" if ARGV.empty? if $u then require 'sexp_processor' require 'unified_ruby' class Unifier include UnifiedRuby end end parse_tree = ParseTree.new($a) unifier = Unifier.new if $u ARGV.each do |file| ruby = file == "-" ? $stdin.read : File.read(file) sexp = parse_tree.parse_tree_for_string(ruby, file).first sexp = Sexp.from_array sexp unless $r sexp = unifier.process(sexp) if $u sexp = sexp.structure if $s if $n then sexp.each_of_type $n do |node| p node end elsif defined? $q then p sexp else pp sexp end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ParseTree-3.0.5 | bin/parse_tree_show |
ParseTree-3.0.4 | bin/parse_tree_show |
ParseTree-3.0.3 | bin/parse_tree_show |