Module: SexpGrammar

Defined in:
lib/sexp_grammar.rb,
lib/sexp_grammar/many.rb,
lib/sexp_grammar/rule.rb,
lib/sexp_grammar/element.rb,
lib/sexp_grammar/grammar.rb,
lib/sexp_grammar/version.rb,
lib/sexp_grammar/sequence.rb,
lib/sexp_grammar/terminal.rb,
lib/sexp_grammar/reference.rb,
lib/sexp_grammar/alternative.rb

Overview

A helper to manipulate sexp grammars

Defined Under Namespace

Modules: Element, Version Classes: Alternative, Grammar, Many, Reference, Rule, Sequence, Terminal

Constant Summary collapse

VERSION =
Version.to_s

Class Method Summary collapse

Class Method Details

.load(input) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sexp_grammar.rb', line 8

def self.load(input)
  case input
  when lambda{|x| x.respond_to?(:to_path)}
    require 'yaml'
    load(YAML.load_file input.to_path)
  when String
    require 'yaml'
    load(YAML.load input)
  when Hash
    Grammar.new(input)
  else
    raise ArgumentError, "Invalid argument for SexpGrammar::Grammar: #{input}"
  end
end