lib/modl/parser/interpreter.rb in modl-0.3.11 vs lib/modl/parser/interpreter.rb in modl-0.3.12

- old
+ new

@@ -25,10 +25,11 @@ require 'modl/parser/MODLParserListener' require 'modl/parser/MODLParserVisitor' require 'modl/parser/MODLLexer' require 'modl/parser/MODLParser' require 'modl/parser/class_processor' +require 'modl/parser/orphan_handler' require 'modl/parser/parser' require 'json' module MODL # Interpreter-specific errors @@ -56,9 +57,12 @@ # Parse a MODL string and return a hash, array, or String depending on how the MODL is structured. def self.parse(string) # Parse the MODL string into a MODL::Parser::Parsed object. parsed = MODL::Parser::Parser.parse(string) + + # Check for orphan pairs and adopt them. + parsed.structures = MODL::Parser::OrphanHandler.adopt(parsed.global, parsed.structures) # Convert the Parsed object into a simpler structure of and Array or Hash interpreted = parsed.extract_hash # Process any class definitions used by the MODL file.