Class: ABNF::Parser::Compiler::RuleList
- Inherits:
-
RuleBuilder
- Object
- RuleBuilder
- ABNF::Parser::Compiler::RuleList
- Defined in:
- lib/abnf/parser/compiler/rule_list.rb
Defined Under Namespace
Classes: Rule
Instance Attribute Summary collapse
-
#rulename(token) ⇒ Object
Returns the value of attribute rulename.
Attributes inherited from RuleBuilder
Instance Method Summary collapse
- #c_nl(token) ⇒ Object
- #coerce_alternation(rule) ⇒ Object
- #handle_rule(name, rule) ⇒ Object
- #rule_list ⇒ Object
Methods inherited from RuleBuilder
#call, #initialize, #start_rule
Constructor Details
This class inherits a constructor from ABNF::Parser::Compiler::RuleBuilder
Instance Attribute Details
#rulename(token) ⇒ Object
Returns the value of attribute rulename.
5 6 7 |
# File 'lib/abnf/parser/compiler/rule_list.rb', line 5 def rulename @rulename end |
Instance Method Details
#c_nl(token) ⇒ Object
7 8 |
# File 'lib/abnf/parser/compiler/rule_list.rb', line 7 def c_nl token end |
#coerce_alternation(rule) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/abnf/parser/compiler/rule_list.rb', line 10 def coerce_alternation rule if rule.is_a? Rules::Alternation rule else Rules::Alternation.new [rule], rule.abnf end end |
#handle_rule(name, rule) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/abnf/parser/compiler/rule_list.rb', line 18 def handle_rule name, rule actual_rule = rule.inner_rule if rule.operator == '=/' original_rule = coerce_alternation rule_list[name] new_rule = coerce_alternation actual_rule alternatives = original_rule.alternatives + new_rule.alternatives abnf = alternatives.map &:abnf abnf *= ' / ' actual_rule = Rules::Alternation.new alternatives, abnf end rule_list[name] = actual_rule end |
#rule_list ⇒ Object
34 35 36 |
# File 'lib/abnf/parser/compiler/rule_list.rb', line 34 def rule_list compiler.rule_list end |