Sha256: a083adca1bdf625dbd70dee684486e694b3d314b02b5d913f2827a555a2321f6

Contents?: true

Size: 540 Bytes

Versions: 7

Compression:

Stored size: 540 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
# End of file

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rley-0.3.11 spec/rley/support/grammar_abc_helper.rb
rley-0.3.10 spec/rley/support/grammar_abc_helper.rb
rley-0.3.09 spec/rley/support/grammar_abc_helper.rb
rley-0.3.08 spec/rley/support/grammar_abc_helper.rb
rley-0.3.07 spec/rley/support/grammar_abc_helper.rb
rley-0.3.06 spec/rley/support/grammar_abc_helper.rb
rley-0.3.05 spec/rley/support/grammar_abc_helper.rb