Class: ParseTree

Inherits:
RawParseTree show all
Defined in:
lib/parse_tree.rb

Overview

RawParseTree class

Constant Summary

Constants inherited from RawParseTree

RawParseTree::NODE_NAMES, RawParseTree::VERSION

Instance Method Summary collapse

Methods inherited from RawParseTree

has_alloca, #parse_tree, #parse_tree_for_method, #parse_tree_for_str0, #parse_tree_for_string, translate

Constructor Details

#initialize(include_newlines = $DEBUG) ⇒ ParseTree

Initializes a ParseTree instance. Includes newline nodes if include_newlines which defaults to $DEBUG.



1177
1178
1179
1180
# File 'lib/parse_tree.rb', line 1177

def initialize(include_newlines=$DEBUG)
  super
  @unifier = Unifier.new
end

Instance Method Details

#process(input, verbose = nil, file = "(string)", line = -1)) ⇒ Object

Main driver for ParseTree. Returns a Sexp instance containing the AST representing the input given. This is a UnifiedRuby sexp, not a raw sexp from ruby. If you want raw, use the old parse_tree_for_xxx methods… Please tell me if/why you want raw, I’d like to know so I can justify keeping the code around.



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
# File 'lib/parse_tree.rb', line 1189

def process(input, verbose = nil, file = "(string)", line = -1)
  case input
  when Array then
    @unifier.process(input)
  when String then
    pt = self.parse_tree_for_string(input, file, line, verbose).first
    @unifier.process(pt)
  else
    raise ArgumentError, "Unknown input type #{input.inspect}"
  end
end