Object
Productions for specific grammar symbols are defined in the context of this class.
Creates a new production for symbol with an expansion of expansion. The options hash can include a directive :prec, the value of which is a grammar symbol name. The precedence of the production is then set to the precedence of the grammar symbol corresponding to that name.
See the arithmetic precedence grammar in the test suites for an example.
# File lib/dhaka/grammar/grammar.rb, line 20 def method_missing(production_name, expansion, options = {}, &blk) expansion_symbols = expansion.collect {|name| @grammar.symbols[name]} production_args = [@symbol, expansion_symbols, production_name.to_s, blk, @grammar.production_index] if precedence_symbol_name = options[:prec] production_args << @grammar.symbol_for_name(precedence_symbol_name).precedence end production = Production.new(*production_args) @grammar.production_index += 1 @symbol.nullable = true if expansion_symbols.empty? @grammar.productions_by_symbol[production.symbol] << production raise "Duplicate production named #{production.name}" if @grammar.productions_by_name[production.name] @grammar.productions_by_name[production.name] = production end
Generated with the Darkfish Rdoc Generator 2.