Module: MODL

Defined in:
lib/modl/parser/parsed.rb,
lib/modl/parser/parser.rb,
lib/modl/parser/version.rb,
lib/modl/parser/evaluator.rb,
lib/modl/parser/modl_class.rb,
lib/modl/parser/modl_index.rb,
lib/modl/parser/interpreter.rb,
lib/modl/parser/modl_method.rb,
lib/modl/parser/modl_keylist.rb,
lib/modl/parser/object_cache.rb,
lib/modl/parser/file_importer.rb,
lib/modl/parser/ref_processor.rb,
lib/modl/parser/substitutions.rb,
lib/modl/parser/class_processor.rb,
lib/modl/parser/global_parse_context.rb,
lib/modl/parser/instruction_processor.rb

Defined Under Namespace

Modules: Parser Classes: Interpreter, InterpreterError

Class Method Summary collapse

Class Method Details

.parse(string) ⇒ Object

Parse a MODL string and return a hash, array, or String depending on how the MODL is structured.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/modl/parser/interpreter.rb', line 40

def self.parse(string)
  # Parse the MODL string into a MODL::Parser::Parsed object.
  parsed = MODL::Parser::Parser.parse(string)

  # 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.
  MODL::Parser::ClassProcessor.process(parsed.global, interpreted)
  MODL::Parser::InstructionProcessor.process(parsed.global, interpreted)
  # If the result is a simple string then just return it.
  interpreted
end