@@ -203,8 +203,7 @@ def _extend_states_and_shift_entries(
203203 number = _states .setdefault (new , len (_states ) + 1 )
204204 new .set_number (number )
205205
206- action = Action (new , ActionType .SHIFT )
207- _entries .add (Entry (state , item .after_dot , action ))
206+ _entries .add (Entry (state , item .after_dot , Action .shift (new )))
208207
209208 return _states , _entries
210209
@@ -217,16 +216,14 @@ def _create_reduce_entries(self, states: set[LR0State]) -> set[Entry]:
217216 for state in states :
218217 for item in state .items :
219218 if item .after_dot == Token .eof ():
220- action = Action (item .rule , ActionType .ACCEPT )
221- entries .add (Entry (state , Token .eof (), action ))
219+ entries .add (Entry (state , Token .eof (), Action .accept ()))
222220
223221 if not item .dot_is_last ():
224222 continue
225223
226- action = Action (item .rule , ActionType .REDUCE )
227224 for token in self .grammar .tokens :
228225 if token .is_terminal :
229- entries .add (Entry (state , token , action ))
226+ entries .add (Entry (state , token , Action . reduce ( item . rule ) ))
230227
231228 return entries
232229
@@ -254,14 +251,12 @@ def _create_reduce_entries(self, states: set[LR0State]) -> set[Entry]:
254251 for state in states :
255252 for item in state .items :
256253 if item .after_dot == Token .eof ():
257- action = Action (item .rule , ActionType .ACCEPT )
258- entries .add (Entry (state , Token .eof (), action ))
254+ entries .add (Entry (state , Token .eof (), Action .accept ()))
259255
260256 if not item .dot_is_last ():
261257 continue
262258
263- action = Action (item .rule , ActionType .REDUCE )
264259 for token in self ._follow (item .rule .lhs ):
265- entries .add (Entry (state , token , action ))
260+ entries .add (Entry (state , token , Action . reduce ( item . rule ) ))
266261
267262 return entries
0 commit comments