Module: RDF::LL1::Parser::ClassMethods
- Defined in:
- lib/ebnf/ll1/parser.rb
Overview
DSL for creating terminals and productions
Instance Method Summary collapse
- #patterns ⇒ Object
-
#production(term) {|reader, phase, input, current| ... } ⇒ Object
Defines a production called during different phases of parsing with data from previous production along with data defined for the current production.
- #production_handlers ⇒ Object
-
#terminal(term, regexp, options = {}) {|reader, term, token, input| ... } ⇒ Object
Defines the pattern for a terminal node and a block to be invoked when ther terminal is encountered.
- #terminal_handlers ⇒ Object
- #unescape_terms ⇒ Object
Instance Method Details
#patterns ⇒ Object
26 |
# File 'lib/ebnf/ll1/parser.rb', line 26 def patterns; @@patterns || []; end |
#production(term) {|reader, phase, input, current| ... } ⇒ Object
Defines a production called during different phases of parsing with data from previous production along with data defined for the current production
Yield to generate a triple
51 52 53 54 |
# File 'lib/ebnf/ll1/parser.rb', line 51 def production(term, &block) @@production_handlers ||= {} @@production_handlers[term] = block end |
#production_handlers ⇒ Object
24 |
# File 'lib/ebnf/ll1/parser.rb', line 24 def production_handlers; @@production_handlers || {}; end |
#terminal(term, regexp, options = {}) {|reader, term, token, input| ... } ⇒ 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.
81 82 83 84 85 86 87 88 |
# File 'lib/ebnf/ll1/parser.rb', line 81 def terminal(term, regexp, = {}, &block) @@patterns ||= [] @@patterns << [term, regexp] # Passed in order to define evaulation sequence @@terminal_handlers ||= {} @@terminal_handlers[term] = block if block_given? @@unescape_terms ||= [] @@unescape_terms << term if [:unescape] end |
#terminal_handlers ⇒ Object
25 |
# File 'lib/ebnf/ll1/parser.rb', line 25 def terminal_handlers; @@terminal_handlers || {}; end |
#unescape_terms ⇒ Object
27 |
# File 'lib/ebnf/ll1/parser.rb', line 27 def unescape_terms; @@unescape_terms || []; end |