Class: Lrama::Counterexamples

Inherits:
Object
  • Object
show all
Defined in:
lib/lrama/counterexamples.rb,
lib/lrama/counterexamples/path.rb,
lib/lrama/counterexamples/triple.rb,
lib/lrama/counterexamples/example.rb,
lib/lrama/counterexamples/derivation.rb,
lib/lrama/counterexamples/state_item.rb

Overview

See: www.cs.cornell.edu/andru/papers/cupex/cupex.pdf

4. Constructing Nonunifying Counterexamples

Defined Under Namespace

Classes: Derivation, Example, Path, ProductionPath, StartPath, StateItem, TransitionPath, Triple

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(states) ⇒ Counterexamples

Returns a new instance of Counterexamples.



15
16
17
18
19
# File 'lib/lrama/counterexamples.rb', line 15

def initialize(states)
  @states = states
  setup_transitions
  setup_productions
end

Instance Attribute Details

#productionsObject (readonly)

Returns the value of attribute productions.



13
14
15
# File 'lib/lrama/counterexamples.rb', line 13

def productions
  @productions
end

#transitionsObject (readonly)

Returns the value of attribute transitions.



13
14
15
# File 'lib/lrama/counterexamples.rb', line 13

def transitions
  @transitions
end

Instance Method Details

#compute(conflict_state) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/lrama/counterexamples.rb', line 26

def compute(conflict_state)
  conflict_state.conflicts.flat_map do |conflict|
    case conflict.type
    when :shift_reduce
      shift_reduce_example(conflict_state, conflict)
    when :reduce_reduce
      reduce_reduce_examples(conflict_state, conflict)
    end
  end.compact
end

#to_sObject Also known as: inspect



21
22
23
# File 'lib/lrama/counterexamples.rb', line 21

def to_s
  "#<Counterexamples>"
end