@@ -259,7 +259,7 @@ def get_generating_non_terminals(self) -> Set[Variable]:
259259 """
260260 # Preprocess
261261 generating_from : Dict [Variable , Set [Variable ]] = {}
262- duplication_pointer : Dict [CFGObject , List [Tuple [ Variable , int ] ]] = {}
262+ duplication_pointer : Dict [CFGObject , List [List ]] = {}
263263 generating = set ()
264264 to_process = []
265265 self ._preprocess_rules_generating (duplication_pointer , generating ,
@@ -272,12 +272,12 @@ def get_generating_non_terminals(self) -> Set[Variable]:
272272 if symbol not in generating :
273273 generating .add (symbol )
274274 to_process .append (symbol )
275- for symbol , pointer in duplication_pointer .get (current , []):
276- pointer -= 1
277- if pointer == 0 :
278- if symbol not in generating :
279- generating .add (symbol )
280- to_process .append (symbol )
275+ for duplication in duplication_pointer .get (current , []):
276+ duplication [ 1 ] -= 1
277+ if duplication [ 1 ] == 0 :
278+ if duplication [ 0 ] not in generating :
279+ generating .add (duplication [ 0 ] )
280+ to_process .append (duplication [ 0 ] )
281281 return generating
282282
283283 def _preprocess_consumption_rules_generating (
@@ -295,7 +295,7 @@ def _preprocess_consumption_rules_generating(
295295
296296 def _preprocess_rules_generating (
297297 self ,
298- duplication_pointer : Dict [CFGObject , List [Tuple [ Variable , int ] ]],
298+ duplication_pointer : Dict [CFGObject , List [List ]],
299299 generating : Set [Variable ],
300300 generating_from : Dict [Variable , Set [Variable ]],
301301 to_process : List [Variable ]) \
@@ -305,7 +305,7 @@ def _preprocess_rules_generating(
305305 left = rule .left_term
306306 right0 = rule .right_terms [0 ]
307307 right1 = rule .right_terms [1 ]
308- temp = ( left , 2 )
308+ temp = [ left , 2 ]
309309 duplication_pointer .setdefault (right0 , []).append (temp )
310310 duplication_pointer .setdefault (right1 , []).append (temp )
311311 if isinstance (rule , ProductionRule ):
@@ -424,7 +424,7 @@ def _extract_fst_duplication_rules_intersection(
424424 for start_state in other .start_states :
425425 new_rules .append (DuplicationRule (
426426 "S" ,
427- (start_state , "S" , final_state ),
427+ (start_state . value , "S" , final_state . value ),
428428 "T" ))
429429
430430 def _extract_fst_epsilon_intersection (
@@ -434,7 +434,7 @@ def _extract_fst_epsilon_intersection(
434434 -> None :
435435 for state in other .states :
436436 new_rules .append (EndRule (
437- (state , "epsilon" , state ),
437+ (state . value , "epsilon" , state . value ),
438438 "epsilon" ))
439439
440440 def _extract_fst_delta_intersection (
@@ -444,8 +444,8 @@ def _extract_fst_delta_intersection(
444444 -> None :
445445 for (s_from , symb_from ), (s_to , symb_to ) in other :
446446 new_rules .append (EndRule (
447- (s_from , symb_from , s_to ),
448- symb_to ))
447+ (s_from . value , symb_from . value , s_to . value ),
448+ tuple ( map ( lambda x : x . value , symb_to )) ))
449449
450450 def _extract_epsilon_transitions_intersection (
451451 self ,
@@ -456,9 +456,9 @@ def _extract_epsilon_transitions_intersection(
456456 for state_q in other .states :
457457 for state_r in other .states :
458458 new_rules .append (DuplicationRule (
459- (state_p , "epsilon" , state_q ),
460- (state_p , "epsilon" , state_r ),
461- (state_r , "epsilon" , state_q )))
459+ (state_p . value , "epsilon" , state_q . value ),
460+ (state_p . value , "epsilon" , state_r . value ),
461+ (state_r . value , "epsilon" , state_q . value )))
462462
463463 def _extract_indexed_grammar_rules_intersection (
464464 self ,
@@ -471,22 +471,29 @@ def _extract_indexed_grammar_rules_intersection(
471471 for state_q in other .states :
472472 for state_r in other .states :
473473 new_rules .append (DuplicationRule (
474- (state_p , rule .left_term , state_q ),
475- (state_p , rule .right_terms [0 ], state_r ),
476- (state_r , rule .right_terms [1 ], state_q )))
474+ (state_p .value , rule .left_term .value ,
475+ state_q .value ),
476+ (state_p .value , rule .right_terms [0 ].value ,
477+ state_r .value ),
478+ (state_r .value , rule .right_terms [1 ].value ,
479+ state_q .value )))
477480 elif isinstance (rule , ProductionRule ):
478481 for state_p in other .states :
479482 for state_q in other .states :
480483 new_rules .append (ProductionRule (
481- (state_p , rule .left_term , state_q ),
482- (state_p , rule .right_term , state_q ),
483- rule .production ))
484+ (state_p .value , rule .left_term .value ,
485+ state_q .value ),
486+ (state_p .value , rule .right_term .value ,
487+ state_q .value ),
488+ rule .production .value ))
484489 elif isinstance (rule , EndRule ):
485490 for state_p in other .states :
486491 for state_q in other .states :
487492 new_rules .append (DuplicationRule (
488- (state_p , rule .left_term , state_q ),
489- (state_p , rule .right_term , state_q ),
493+ (state_p .value , rule .left_term .value ,
494+ state_q .value ),
495+ (state_p .value , rule .right_term .value ,
496+ state_q .value ),
490497 "T" ))
491498
492499 def _extract_terminals_intersection (
@@ -499,13 +506,13 @@ def _extract_terminals_intersection(
499506 for state_q in other .states :
500507 for state_r in other .states :
501508 new_rules .append (DuplicationRule (
502- (state_p , terminal , state_q ),
503- (state_p , "epsilon" , state_r ),
504- (state_r , terminal , state_q )))
509+ (state_p . value , terminal . value , state_q . value ),
510+ (state_p . value , "epsilon" , state_r . value ),
511+ (state_r . value , terminal . value , state_q . value )))
505512 new_rules .append (DuplicationRule (
506- (state_p , terminal , state_q ),
507- (state_p , terminal , state_r ),
508- (state_r , "epsilon" , state_q )))
513+ (state_p . value , terminal . value , state_q . value ),
514+ (state_p . value , terminal . value , state_r . value ),
515+ (state_r . value , "epsilon" , state_q . value )))
509516
510517 def _extract_consumption_rules_intersection (
511518 self ,
@@ -518,6 +525,8 @@ def _extract_consumption_rules_intersection(
518525 for state_r in other .states :
519526 for state_s in other .states :
520527 new_rules .append (ConsumptionRule (
521- consumption .f_parameter ,
522- (state_r , consumption .left_term , state_s ),
523- (state_r , consumption .right_term , state_s )))
528+ consumption .f_parameter .value ,
529+ (state_r .value , consumption .left_term .value ,
530+ state_s .value ),
531+ (state_r .value , consumption .right_term .value ,
532+ state_s .value )))
0 commit comments