Sha256: 5c95d16d5db9353081c68783535594ae285cf1df119fa9a4fd46dd718d829485

Contents?: true

Size: 548 Bytes

Versions: 15

Compression:

Stored size: 548 Bytes

Contents

# Load the builder class
require_relative '../../../lib/rley/syntax/grammar_builder'


module GrammarABCHelper
  # Factory method. Creates a grammar builder for a simple grammar.
  # (based on example in N. Wirth "Compiler Construction" book, p. 6)
  def grammar_abc_builder()
    builder = Rley::Syntax::GrammarBuilder.new
    builder.add_terminals('a', 'b', 'c')
    builder.add_production('S' => ['A'])
    builder.add_production('A' => %w(a A c))
    builder.add_production('A' => ['b'])

    return builder
  end
end # module

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rley-0.2.11 spec/rley/support/grammar_abc_helper.rb
rley-0.2.10 spec/rley/support/grammar_abc_helper.rb
rley-0.2.09 spec/rley/support/grammar_abc_helper.rb
rley-0.2.08 spec/rley/support/grammar_abc_helper.rb
rley-0.2.06 spec/rley/support/grammar_abc_helper.rb
rley-0.2.05 spec/rley/support/grammar_abc_helper.rb
rley-0.2.04 spec/rley/support/grammar_abc_helper.rb
rley-0.2.03 spec/rley/support/grammar_abc_helper.rb
rley-0.2.02 spec/rley/support/grammar_abc_helper.rb
rley-0.2.01 spec/rley/support/grammar_abc_helper.rb
rley-0.2.00 spec/rley/support/grammar_abc_helper.rb
rley-0.1.12 spec/rley/support/grammar_abc_helper.rb
rley-0.1.11 spec/rley/support/grammar_abc_helper.rb
rley-0.1.10 spec/rley/support/grammar_abc_helper.rb
rley-0.1.09 spec/rley/support/grammar_abc_helper.rb