Class: Lrama::State::Action::Reduce
- Inherits:
-
Object
- Object
- Lrama::State::Action::Reduce
- Defined in:
- lib/lrama/state/action/reduce.rb
Instance Attribute Summary collapse
- #default_reduction ⇒ Object
-
#item ⇒ Object
readonly
TODO: rbs-inline 0.11.0 doesn't support instance variables.
-
#look_ahead ⇒ Object
: Array?.
-
#look_ahead_sources ⇒ Object
: Hash[Grammar::Symbol, Array[Action::Goto]]?.
-
#not_selected_symbols ⇒ Object
readonly
: Array.
Instance Method Summary collapse
- #add_not_selected_symbol(sym) ⇒ Object
- #clear_conflicts ⇒ Object
-
#initialize(item) ⇒ Reduce
constructor
A new instance of Reduce.
- #rule ⇒ Object
- #selected_look_ahead ⇒ Object
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_reduction ⇒ Object
24 25 26 |
# File 'lib/lrama/state/action/reduce.rb', line 24 def default_reduction @default_reduction end |
#item ⇒ Object (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_ahead ⇒ Object
: Array?
19 20 21 |
# File 'lib/lrama/state/action/reduce.rb', line 19 def look_ahead @look_ahead end |
#look_ahead_sources ⇒ Object
: 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_symbols ⇒ Object (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_conflicts ⇒ Object
64 65 66 67 |
# File 'lib/lrama/state/action/reduce.rb', line 64 def clear_conflicts @not_selected_symbols = [] @default_reduction = nil end |
#rule ⇒ Object
35 36 37 |
# File 'lib/lrama/state/action/reduce.rb', line 35 def rule @item.rule end |
#selected_look_ahead ⇒ Object
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 |