class Lutaml::Uml::Parsers::Dsl

Class for parsing LutaML dsl into Lutaml::Uml::Document

Constants

KEYWORDS

Public Class Methods

parse(io, options = {}) click to toggle source

@param [String] io - LutaML string representation

[Hash] options - options for parsing

@return [Lutaml::Uml::Document]

# File lib/lutaml/uml/parsers/dsl.rb, line 19
def self.parse(io, options = {})
  new.parse(io, options)
end

Public Instance Methods

parse(input_file, _options = {}) click to toggle source
Calls superclass method
# File lib/lutaml/uml/parsers/dsl.rb, line 23
def parse(input_file, _options = {})
  data = Lutaml::Uml::Parsers::DslPreprocessor.call(input_file)
  # https://kschiess.github.io/parslet/tricks.html#Reporter engines
  # Parslet::ErrorReporter::Deepest allows more
  # detailed display of error
  reporter = Parslet::ErrorReporter::Deepest.new
  ::Lutaml::Uml::Document
    .new(DslTransform.new.apply(super(data, reporter: reporter)))
rescue Parslet::ParseFailed => e
  raise(ParsingError,
        "#{e.message}\ncause: #{e.parse_failure_cause.ascii_tree}")
end