Module: Sexpr
- Includes:
- Node
- Defined in:
- lib/sexpr.rb,
lib/sexpr/node.rb,
lib/sexpr/errors.rb,
lib/sexpr/parser.rb,
lib/sexpr/grammar.rb,
lib/sexpr/matcher.rb,
lib/sexpr/version.rb,
lib/sexpr/matcher/many.rb,
lib/sexpr/matcher/rule.rb,
lib/sexpr/parser/citrus.rb,
lib/sexpr/grammar/options.rb,
lib/sexpr/grammar/parsing.rb,
lib/sexpr/grammar/tagging.rb,
lib/sexpr/grammar/matching.rb,
lib/sexpr/matcher/sequence.rb,
lib/sexpr/matcher/terminal.rb,
lib/sexpr/matcher/reference.rb,
lib/sexpr/matcher/alternative.rb
Overview
A helper to manipulate sexp grammars
Defined Under Namespace
Modules: Grammar, Matcher, Node, Parser, Version Classes: Error, InvalidParseSourceError, NoParserError, UnrecognizedParserError
Constant Summary collapse
- PathLike =
lambda{|x| x.respond_to?(:to_path) or (x.is_a?(String) and File.exists?(x)) }
- VERSION =
Version.to_s
Class Method Summary collapse
Methods included from Node
Class Method Details
.load(input) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sexpr.rb', line 13 def self.load(input) defn = case input when PathLike require 'yaml' path = input.respond_to?(:to_path) ? input.to_path : input.to_s YAML.load_file(path).merge(:path => input) when String require 'yaml' YAML.load(input) when Hash input else raise ArgumentError, "Invalid argument for Sexpr::Grammar: #{input}" end Grammar.new defn end |