module ASTNode

Public Class Methods

new(*properties, &body) click to toggle source

macro

# File lib/parse.rb, line 539
def self.new(*properties, &body)
  (if properties.empty? then Class.new else Struct.new(*properties); end).tap do |c|
    c.class_eval do
      
      include ASTNode
      
      # @return [Boolean]
      def === other
        self.class == other.class and
        self.members.all? { |member| self.__send__(member) === other.__send__(member) }
      end
      
      if properties.empty? then
        # @return [Array<Symbol>]
        def members
          []
        end
      end
      
    end
    c.class_eval(&body) if body
  end
end

Public Instance Methods

===(other) click to toggle source

@return [Boolean]

# File lib/parse.rb, line 546
def === other
  self.class == other.class and
  self.members.all? { |member| self.__send__(member) === other.__send__(member) }
end
initialize_pos(pos) click to toggle source

Sets {#pos} to pos.

@param [Parse::Position] pos @return [self]

# File lib/parse.rb, line 568
def initialize_pos(pos)
  @pos = pos
  self
end
members() click to toggle source

@return [Array<Symbol>]

# File lib/parse.rb, line 553
def members
  []
end
pos() click to toggle source

@note {#initialize_pos} must be called before this method can be used. @return [Parse::Position]

# File lib/parse.rb, line 575
def pos
  raise "initialize_pos() must be called before this method can be used" unless @pos
  @pos
end