File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/syntactes/parsing_table Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 33from syntactes import Grammar , Token
44from syntactes ._action import Action
55from syntactes ._state import LR0State
6- from syntactes .parsing_table import Entry
6+ from syntactes .parsing_table import Conflict , Entry
77
88Row : TypeAlias = dict [Token , list [Action ]]
99
@@ -64,10 +64,17 @@ def pretty_str(self) -> str:
6464 """
6565 return self ._rules_pretty_str () + "\n \n " + self ._table_pretty_str ()
6666
67- def conflicts (self ) -> list :
67+ def conflicts (self ) -> list [ Conflict ] :
6868 """
6969 Retuns a list with all the conflicts in the parsing table.
7070 """
71+ conflicts = []
72+ for state , row in self .rows .items ():
73+ for token , actions in row .items ():
74+ if len (actions ) > 1 :
75+ conflicts .append (Conflict (state , token , actions ))
76+
77+ return conflicts
7178
7279 def _rules_pretty_str (self ) -> str :
7380 rules = [str (i ) + ". " + str (r ) for i , r in enumerate (self ._grammar .rules )]
You can’t perform that action at this time.
0 commit comments