Class: Lrama::Counterexamples::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/lrama/counterexamples/example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path1, path2, conflict, conflict_symbol, counterexamples) ⇒ Example

path1 is shift conflict when S/R conflict path2 is always reduce conflict



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

def initialize(path1, path2, conflict, conflict_symbol, counterexamples)
  @path1 = path1
  @path2 = path2
  @conflict = conflict
  @conflict_symbol = conflict_symbol
  @counterexamples = counterexamples
end

Instance Attribute Details

#conflictObject (readonly)

: State::conflict



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

def conflict
  @conflict
end

#conflict_symbolObject (readonly)

: Grammar::Symbol



23
24
25
# File 'lib/lrama/counterexamples/example.rb', line 23

def conflict_symbol
  @conflict_symbol
end

#path1Object (readonly)

TODO: rbs-inline 0.11.0 doesn’t support instance variables.

Move these type declarations above instance variable definitions, once it's supported.
see: https://github.com/soutaro/rbs-inline/pull/149

@rbs!

@path1: ::Array[StateItem]
@path2: ::Array[StateItem]
@conflict: State::conflict
@conflict_symbol: Grammar::Symbol
@counterexamples: Counterexamples
@derivations1: Derivation
@derivations2: Derivation


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

def path1
  @path1
end

#path2Object (readonly)

: ::Array



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

def path2
  @path2
end

Instance Method Details

#derivations1Object



53
54
55
# File 'lib/lrama/counterexamples/example.rb', line 53

def derivations1
  @derivations1 ||= _derivations(path1)
end

#derivations2Object



58
59
60
# File 'lib/lrama/counterexamples/example.rb', line 58

def derivations2
  @derivations2 ||= _derivations(path2)
end

#path1_itemObject



43
44
45
# File 'lib/lrama/counterexamples/example.rb', line 43

def path1_item
  @path1.last.item
end

#path2_itemObject



48
49
50
# File 'lib/lrama/counterexamples/example.rb', line 48

def path2_item
  @path2.last.item
end

#typeObject



38
39
40
# File 'lib/lrama/counterexamples/example.rb', line 38

def type
  @conflict.type
end