class MTK::Lang::Parser

Parser for the {file:lib/mtk/lang/mtk_grammar.citrus MTK syntax}

Public Class Methods

parse(syntax, grammar_rule=:root, dump=false) click to toggle source

Parse the given MTK syntax according to the {file:lib/mtk/lang/mtk_grammar.citrus grammar rules} @return [Sequencers::LegatoSequencer] by default @return [Core,Patterns,Sequencers] a core object, pattern or sequencer when an optional grammar rule

is given. Depends on the rule.

@raise [Citrus::ParseError] for invalid syntax

# File lib/mtk/lang/parser.rb, line 23
def self.parse(syntax, grammar_rule=:root, dump=false)
  syntax = syntax.to_s.strip
  return nil if syntax.empty?
  match = ::MTK_Grammar.parse(syntax, root: grammar_rule)
  puts match.dump if dump
  match.value
end