diff --git a/table_to_stackstates.py b/table_to_stackstates.py index fab6cdddbb03f29715593c106b0b829485134113..847be8c2a7bba7bf1f5fb164393cd4ec50e8f002 100644 --- a/table_to_stackstates.py +++ b/table_to_stackstates.py @@ -382,20 +382,10 @@ nx.drawing.nx_pydot.write_dot(sr_graph, "foo.dot") - - -# Finally, we check for uniqueness of stack state descriptions. No two may be identical. It -# is ok for two to overlap, [A, B, C] and [A, B] are allowed to co-exist, they are dealt with -# the "pairwise priority rule" mechanism in the parser gateware. - - # Check for anomalous weird stuff with multiple transitions from one node to another node for x in sr_graph.edges(): assert(len(sr_graph[x[0]][x[1]]) == 1) - - - # We then cross-check the generated stack state descriptions against the original shift/goto # entries -- given the tail of each edge, the edge's head must be consistent with the label on # the edge. @@ -407,18 +397,14 @@ for x in sr_graph.edges(): assert(edge_op[1] == stack_op_to["label"][1][0]) - - # We also check that the generated stack state descriptions are consistent with the reduce # rules. Every node is associated with a set of reduce rules that can be taken from it, and # the right-hand-side of all the reduce rules for that node must be explicitly demarcated in # that node's stack state description. - # Here we extract the reduce entries from the shift-reduce table: reduce_rule_locations = [] - for statenumber, rule in enumerate(shift_reduce_table): for valid_transition in rule: # Here, valid_transition is an index of the dictionary (so the index will be the character that causes the transition @@ -441,3 +427,9 @@ for state_number, reduce_rule_number in reduce_rule_locations: for idx, x in enumerate(rule_RHS): assert(stack_state[idx] == x) + + +# Finally, we check for uniqueness of stack state descriptions. No two may be identical. It +# is ok for two to overlap, [A, B, C] and [A, B] are allowed to co-exist, they are dealt with +# the "pairwise priority rule" mechanism in the parser gateware. +