Sha256: c6332a1c67265dc1f3641c38a1638e6d7c0ebfdecd3b0266e91370e6aabc9cce

Contents?: true

Size: 471 Bytes

Versions: 3

Compression:

Stored size: 471 Bytes

Contents

module GrammarHelper

  def grammar_for(grammar_file = "simple")
    source_path = Pathname.new("../../fixtures").expand_path(__FILE__)
    Ace::Grammar.from_file(source_path.children.select(&:file?)
      .find { |x| x.to_s =~ /#{Regexp.escape(grammar_file)}\..*\z/ }.to_s)
  end

  def with_recognizer(grammar = simple_grammar)
    recognizer = Generation::Recognizer.new(grammar).call
    grammar
  end

  alias_method :simple_grammar, :grammar_for
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
antelope-0.2.4 spec/support/grammar_helper.rb
antelope-0.2.3 spec/support/grammar_helper.rb
antelope-0.2.2 spec/support/grammar_helper.rb