Class: Lrama::State::Action::Reduce

Inherits:
Object
  • Object
show all
Defined in:
lib/lrama/state/action/reduce.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ Reduce

Returns a new instance of Reduce.



27
28
29
30
31
32
# File 'lib/lrama/state/action/reduce.rb', line 27

def initialize(item)
  @item = item
  @look_ahead = nil
  @look_ahead_sources = nil
  @not_selected_symbols = []
end

Instance Attribute Details

#default_reductionObject



24
25
26
# File 'lib/lrama/state/action/reduce.rb', line 24

def default_reduction
  @default_reduction
end

#itemObject (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! @item: Item @look_ahead: Array? @look_ahead_sources: Hash[Grammar::Symbol, Array[Action::Goto]]? @not_selected_symbols: Array



18
19
20
# File 'lib/lrama/state/action/reduce.rb', line 18

def item
  @item
end

#look_aheadObject

: Array?



19
20
21
# File 'lib/lrama/state/action/reduce.rb', line 19

def look_ahead
  @look_ahead
end

#look_ahead_sourcesObject

: Hash[Grammar::Symbol, Array[Action::Goto]]?



20
21
22
# File 'lib/lrama/state/action/reduce.rb', line 20

def look_ahead_sources
  @look_ahead_sources
end

#not_selected_symbolsObject (readonly)

: Array



21
22
23
# File 'lib/lrama/state/action/reduce.rb', line 21

def not_selected_symbols
  @not_selected_symbols
end

Instance Method Details

#add_not_selected_symbol(sym) ⇒ Object



50
51
52
# File 'lib/lrama/state/action/reduce.rb', line 50

def add_not_selected_symbol(sym)
  @not_selected_symbols << sym
end

#clear_conflictsObject



64
65
66
67
# File 'lib/lrama/state/action/reduce.rb', line 64

def clear_conflicts
  @not_selected_symbols = []
  @default_reduction = nil
end

#ruleObject



35
36
37
# File 'lib/lrama/state/action/reduce.rb', line 35

def rule
  @item.rule
end

#selected_look_aheadObject



55
56
57
58
59
60
61
# File 'lib/lrama/state/action/reduce.rb', line 55

def selected_look_ahead
  if look_ahead
    look_ahead - @not_selected_symbols
  else
    []
  end
end