Sha256: 41f22551800cfc357df65ace0b87490bc660f41186e35d1b0f4d3a18100d4007
Contents?: true
Size: 738 Bytes
Versions: 5
Compression:
Stored size: 738 Bytes
Contents
module Panini class Nonterminal attr_reader :name # Initialize a nonterminal. Optionally specify a name. def initialize(name=nil) @productions = [] @name = name end # Add a production to the nonterminal. It must be an array, but the array can # contain any type of Ruby object. # # nonterminal.add_production([1, 'a', lambda { ...} ]) # def add_production(production) raise ArgumentError, "The production must be an Array." unless production.class == Array @productions << production.dup nil end # The productions for the nonterminal. def productions @productions.dup end def to_s name.nil? ? super : @name end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
panini-1.3.0 | lib/nonterminal.rb |
panini-1.2.0 | lib/nonterminal.rb |
panini-1.1.1 | lib/nonterminal.rb |
panini-1.1.0 | lib/nonterminal.rb |
panini-1.0.0 | lib/nonterminal.rb |