Class: Aurum::Grammar::LexicalRules::HopcroftMinimizer
- Inherits:
-
Object
- Object
- Aurum::Grammar::LexicalRules::HopcroftMinimizer
- Defined in:
- lib/aurum/grammar/automata.rb
Instance Method Summary collapse
-
#initialize(deterministic, accepts) ⇒ HopcroftMinimizer
constructor
A new instance of HopcroftMinimizer.
- #minimize ⇒ Object
Constructor Details
#initialize(deterministic, accepts) ⇒ HopcroftMinimizer
Returns a new instance of HopcroftMinimizer.
126 127 128 |
# File 'lib/aurum/grammar/automata.rb', line 126 def initialize deterministic, accepts @deterministic, @accepts = deterministic, accepts end |
Instance Method Details
#minimize ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/aurum/grammar/automata.rb', line 130 def minimize make_initial_partitions refine_partitions automata, accepts = Aurum::Grammar::LexicalRules::Automata.new(@partitions.size), {} choose_representatives do |representative, index| @deterministic.table[representative].each do |transition| automata.connect(index, transition.character_set, partition_contains(transition.destination)) end accepts[index] = @accepts[representative] if @accepts.has_key? representative end automata.remove_dead_states(accepts.keys) return automata, accepts end |