Class: Ibex::LALR::IELR::Pipeline
- Inherits:
-
Object
- Object
- Ibex::LALR::IELR::Pipeline
- Defined in:
- lib/ibex/lalr/ielr/pipeline.rb,
sig/ibex/lalr/ielr/pipeline.rbs
Overview
Coordinates the canonical-free direct IELR phases. The returned profile deliberately reports canonical metrics as unavailable.
Instance Method Summary collapse
- #build ⇒ [ Array[packed_items], transitions, LALR::build_collection ]
-
#initialize(grammar, sets, starts: nil, profile: false) ⇒ Pipeline
constructor
A new instance of Pipeline.
Constructor Details
#initialize(grammar, sets, starts: nil, profile: false) ⇒ Pipeline
Returns a new instance of Pipeline.
21 22 23 24 25 26 |
# File 'lib/ibex/lalr/ielr/pipeline.rb', line 21 def initialize(grammar, sets, starts: nil, profile: false) @grammar = grammar @sets = sets @starts = starts || grammar.starts @profile = profile end |
Instance Method Details
#build ⇒ [ Array[packed_items], transitions, LALR::build_collection ]
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ibex/lalr/ielr/pipeline.rb', line 29 def build states, transitions = LR0Collection.new(@grammar, starts: @starts).build seeds = @starts.each_with_index.map do |name, index| augmented = -1 - @grammar.starts.index(name) [index, [augmented, 0], 0] end initial_propagation = LookaheadPropagation.new( @grammar, @sets, states, transitions, seeds: seeds ) items = initial_propagation.build goto_follows = GotoFollows.new( @grammar, @sets, states, transitions, @starts.each_index.to_a, start_names: @starts ) splitter = StateSplitter.new(@grammar, states, transitions, items, goto_follows) _split_items, split_transitions = splitter.build split_states = splitter.states.map { |state| states.fetch(state.lalr_isocore) } phase4_items = LookaheadPropagation.new( @grammar, @sets, split_states, split_transitions, seeds: seeds ).build profile = { construction_states: phase4_items.length, canonical_states: nil, strategy: :ielr_direct, lr0_states: @profile ? states.length : nil, lr0_items: @profile ? states.sum(&:length) : nil, canonical_items: nil, propagation_edges: @profile ? initial_propagation.propagation_edge_count : nil, ielr_initial_partitions: nil, ielr_final_partitions: nil, ielr_annotations: splitter.annotations.sum(&:length), ielr_annotated_states: splitter.annotations.count { |entries| !entries.empty? }, ielr_inadequacies: splitter.inadequacies.sum(&:length), ielr_split_stable_discarded: splitter.split_stable_discarded, ielr_lalr_states: states.length, ielr_split_states: splitter.split_states, ielr_unreachable_removed: 0, ielr_remergeable_candidates: nil } [phase4_items, split_transitions, profile] end |