class MODL::Parser::Parsed::ParsedNbArray
Class to represent a parsed grammar object
Attributes
arrayItems[RW]
Public Class Methods
new(global)
click to toggle source
# File lib/modl/parser/parsed.rb, line 1252 def initialize(global) @global = global @arrayItems = [] end
Public Instance Methods
enterModl_nb_array(ctx)
click to toggle source
# File lib/modl/parser/parsed.rb, line 1278 def enterModl_nb_array(ctx) i = 0 previous = nil ctx_children = ctx.children ctx_children.each do |pt| if pt.is_a? MODLParser::Modl_array_itemContext array_item = ParsedArrayItem.new @global pt.enter_rule(array_item) @arrayItems[i] = array_item i += 1 elsif pt.is_a? Antlr4::Runtime::TerminalNode if !previous.nil? && previous.is_a?(Antlr4::Runtime::TerminalNode) && pt.is_a?(Antlr4::Runtime::TerminalNode) # If we get here then we have two terminal nodes in a row, so we need to output something unless # the terminal symbols are newlines # prev_symbol = previous.symbol.type current_symbol = pt.symbol.type if prev_symbol == MODLLexer::COLON && current_symbol == MODLLexer::COLON array_item = Parsed.handle_empty_array_item @arrayItems[i] = array_item i += 1 end end end previous = pt end end
extract_hash()
click to toggle source
# File lib/modl/parser/parsed.rb, line 1268 def extract_hash result = [] @arrayItems.each do |i| result << i.extract_hash end result end
find_property(key)
click to toggle source
# File lib/modl/parser/parsed.rb, line 1257 def find_property(key) if key.is_a? Integer return @arrayItems[key].arrayValueItem else @arrayItems.each do |mi| return mi.arrayValueItem.pair if mi.arrayValueItem.pair && mi.arrayValueItem.pair.key == key end nil end end