Module: Rley::Parser::GrmItemsBuilder
- Included in:
- BaseParser
- Defined in:
- lib/rley/parser/grm_items_builder.rb
Overview
Mix-in module. Builds the dotted items for a given grammar
Instance Method Summary collapse
-
#build_dotted_items(aGrammar) ⇒ Object
Build an array of dotted items from the productions in passed grammar.
Instance Method Details
#build_dotted_items(aGrammar) ⇒ Object
Build an array of dotted items from the productions in passed grammar.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rley/parser/grm_items_builder.rb', line 8 def build_dotted_items(aGrammar) items = [] aGrammar.rules.each do |prod| rhs_size = prod.rhs.size if rhs_size.zero? items << DottedItem.new(prod, 0) else items += (0..rhs_size).map { |i| DottedItem.new(prod, i) } end end return items end |