Class: Peggy::AST

Inherits:
Node
  • Object
show all
Defined in:
lib/parse/ast.rb

Overview

The root node of an Abstract Syntax Tree. Every node in the tree maps to a production found in the parse.

Instance Attribute Summary collapse

Attributes inherited from Node

#_first, #_name, #_next, #_parent, #_range, #_source

Instance Method Summary collapse

Methods inherited from Node

#<<, #[], #_count, #_depth, #_format, #_last, #_length, #_option, #_root, #_sample, #_strip, #children, #each, #inspect, #method_missing, #to_sym

Constructor Details

#initialize(source, results, options = {}) ⇒ AST

Returns a new instance of AST.



163
164
165
166
167
168
169
170
# File 'lib/parse/ast.rb', line 163

def initialize source, results, options={}
  super nil
  @results = results
  @_options = options
  @ignore = Array(options[:ignore]) # XXX: turn to set
  self._source = source
  build_left nil, 0, self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Peggy::Node

Instance Attribute Details

#_optionsObject (readonly)

Returns the value of attribute _options.



161
162
163
# File 'lib/parse/ast.rb', line 161

def _options
  @_options
end

Instance Method Details

#to_sObject



172
173
174
# File 'lib/parse/ast.rb', line 172

def to_s
  _format
end