Method: EBNF::PEG::Parser::ClassMethods#start_production

Defined in:
lib/ebnf/peg/parser.rb

#start_production(term, **options) {|data, block| ... } ⇒ Object

Defines a production called at the beggining of a particular production with data from previous production along with data defined for the current production. Block is called in an evaluation block from the enclosing parser.

Yield to generate a triple

Parameters:

  • term (Symbol)

    The rule name

  • options (Hash{Symbol => Object})

    Options which are returned from EBNF::PEG::Parser#onStart.

  • options[:upper, (Hash)

    a customizable set of options

Options Hash (**options):

  • :as_hash (Boolean) — default: false

    If the production is a seq, causes the value to be represented as a single hash, rather than an array of individual hashes for each sub-production. Note that this is not always advisable due to the possibility of repeated productions within the sequence.

Yields:

  • (data, block)

Yield Parameters:

  • data (Hash)

    A Hash defined for the current production, during :start may be initialized with data to pass to further productions, during :finish, it contains data placed by earlier productions

  • block (Proc)

    Block passed to initialization for yielding to calling parser. Should conform to the yield specs for #initialize



114
115
116
117
# File 'lib/ebnf/peg/parser.rb', line 114

def start_production(term, **options, &block)
  start_handlers[term] = block
  start_options[term] = options.freeze
end