Sha256: 52e8c1f53b0442d960fd244107ebb84bfbe704da6cbc3963aee7048cf27a4aaa
Contents?: true
Size: 584 Bytes
Versions: 8
Compression:
Stored size: 584 Bytes
Contents
require 'sequitur' # Load the Sequitur library # # Purpose: show how to apply Sequitur on a stream of Symbol values # input_sequence = [ :aa, :bb, :aa, :bb, :cc, :aa, :bb, :cc, :dd, :aa, :bb, :cc, :dd, :ee ] # Generate the grammar from the sequence grammar = Sequitur.build_from(input_sequence) # Use a formatter to display the grammar rules on the console output formatter = Sequitur::Formatter::BaseText.new(STDOUT) # Now render the rules formatter.render(grammar.visitor) # Rendered output is: # start : P1 P2 P3 P3 ee. # P1 : aa bb. # P2 : P1 cc. # P3 : P2 dd.
Version data entries
8 entries across 8 versions & 1 rubygems