Method: EBNF::PEG::Parser::ClassMethods#terminal
- Defined in:
- lib/ebnf/peg/parser.rb
#terminal(term, regexp, **options) {|value, prod| ... } ⇒ Object
Defines the pattern for a terminal node and a block to be invoked when ther terminal is encountered. If the block is missing, the value of the terminal will be placed on the input hash to be returned to a previous production. Block is called in an evaluation block from the enclosing parser.
If no block is provided, then the value which would have been passed to the block is used as the result directly.
85 86 87 88 89 |
# File 'lib/ebnf/peg/parser.rb', line 85 def terminal(term, regexp, **, &block) terminal_regexps[term] = regexp terminal_handlers[term] = block if block_given? [term] = .freeze end |