Class: MTK::Lang::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/mtk/lang/parser.rb

Overview

Parser for the MTK syntax

Class Method Summary collapse

Class Method Details

.parse(syntax, grammar_rule = :root, dump = false) ⇒ Sequencers::LegatoSequencer, ...

Parse the given MTK syntax according to the grammar rules

Returns:

Raises:

  • (Citrus::ParseError)

    for invalid syntax



23
24
25
26
27
28
29
# 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