Class: Packcr::Parser::LrTable
- Inherits:
-
Object
- Object
- Packcr::Parser::LrTable
- Defined in:
- lib/packcr/parser.rb
Instance Method Summary collapse
- #get_answer(index, rule_name) ⇒ Object
- #get_head(index) ⇒ Object
- #hold_answer(index, answer) ⇒ Object
- #hold_head(index, head) ⇒ Object
-
#initialize ⇒ LrTable
constructor
A new instance of LrTable.
- #resize(len) ⇒ Object
- #set_answer(index, rule_name, answer) ⇒ Object
- #set_head(index, head) ⇒ Object
- #shift(count) ⇒ Object
Constructor Details
#initialize ⇒ LrTable
Returns a new instance of LrTable.
4096 4097 4098 4099 |
# File 'lib/packcr/parser.rb', line 4096 def initialize super @buf = [] end |
Instance Method Details
#get_answer(index, rule_name) ⇒ Object
4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 |
# File 'lib/packcr/parser.rb', line 4147 def get_answer(index, rule_name) if index >= @buf.length return nil end entry = @buf[index] if !entry return nil end memos = entry.memos memos[rule_name] end |
#get_head(index) ⇒ Object
4143 4144 4145 |
# File 'lib/packcr/parser.rb', line 4143 def get_head(index) @buf[index]&.head end |
#hold_answer(index, answer) ⇒ Object
4135 4136 4137 4138 4139 4140 4141 |
# File 'lib/packcr/parser.rb', line 4135 def hold_answer(index, answer) if index >= @buf.length resize(index + 1) end entry = @buf[index] ||= LrTableEntry.new answer.hold, entry.hold_a = entry.hold_a, answer end |
#hold_head(index, head) ⇒ Object
4119 4120 4121 4122 4123 4124 4125 |
# File 'lib/packcr/parser.rb', line 4119 def hold_head(index, head) if index >= @buf.length resize(index + 1) end entry = @buf[index] ||= LrTableEntry.new head.hold, entry.hold_h = entry.hold_h, head end |
#resize(len) ⇒ Object
4105 4106 4107 4108 4109 |
# File 'lib/packcr/parser.rb', line 4105 def resize(len) (@buf.length...len).each do |i| @buf << nil end end |
#set_answer(index, rule_name, answer) ⇒ Object
4127 4128 4129 4130 4131 4132 4133 |
# File 'lib/packcr/parser.rb', line 4127 def set_answer(index, rule_name, answer) if index >= @buf.length resize(index + 1) end entry = @buf[index] ||= LrTableEntry.new entry.memos[rule_name] = answer end |
#set_head(index, head) ⇒ Object
4111 4112 4113 4114 4115 4116 4117 |
# File 'lib/packcr/parser.rb', line 4111 def set_head(index, head) if index >= @buf.length resize(index + 1) end entry = @buf[index] ||= LrTableEntry.new entry.head = head end |
#shift(count) ⇒ Object
4101 4102 4103 |
# File 'lib/packcr/parser.rb', line 4101 def shift(count) @buf[0, count] = [] end |