class MODL::Parser::Parsed::ParsedMap

Class to represent a parsed grammar object

Attributes

mapItems[RW]

Public Class Methods

new(global) click to toggle source
# File lib/modl/parser/parsed.rb, line 86
def initialize(global)
  @global = global
  @mapItems = []
end

Public Instance Methods

enterModl_map(ctx) click to toggle source
# File lib/modl/parser/parsed.rb, line 101
def enterModl_map(ctx)
  modl_map_item = ctx.modl_map_item
  return if modl_map_item.nil?

  modl_map_item.each do |mi|
    map_item = ParsedMapItem.new @global
    mi.enter_rule(map_item)
    @mapItems << map_item
  end
end
extract_hash() click to toggle source
# File lib/modl/parser/parsed.rb, line 112
def extract_hash
  result = {}
  @mapItems.each do |i|
    i_hash = i.extract_hash
    next unless i_hash.is_a? Hash

    i_hash.keys.each do |k|
      result[k] = i_hash[k]
    end
  end
  result.is_a?(Array) && result.length == 1 ? result[0] : result
end
find_property(key) click to toggle source
# File lib/modl/parser/parsed.rb, line 91
def find_property(key)
  if key.is_a? Integer
    return @mapItems[key]
  else
    @mapItems.each do |mi|
      return mi.pair if mi.pair.key == key
    end
  end
end