From 04870eaa98c27b4c395b243629d89e0bd990d7c4 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Sun, 8 Nov 2020 17:17:19 -0700 Subject: [PATCH] working on making it a 2-d table like previously used in the actual converter source code --- bison_xml_file_ingest.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bison_xml_file_ingest.py b/bison_xml_file_ingest.py index 288ca3e..3f46ae9 100644 --- a/bison_xml_file_ingest.py +++ b/bison_xml_file_ingest.py @@ -103,7 +103,6 @@ acceptrule_number = the_special_accept_rule[0] #print(acceptrule_number) -list_of_automaton_states = {} renormalized_state_number = 0 state_original_to_monotone = {} @@ -118,6 +117,7 @@ for child in root.findall("./automaton/*"): print(state_original_to_monotone, "\n", state_monotone_to_original) +list_of_automaton_states = {} for child in root.findall("./automaton/*"): state_number = child.attrib["number"] @@ -162,15 +162,21 @@ for state_number, x in list_of_automaton_states.items(): -# we normalize rule numbers so we can use our convention elsewhere of there not being gaps, starting at 0 etc -# so we can use rule numbers as indices into arrays. Perhaps bison doesn't leave gaps but it's better to +# we have normalized rule and state numbers so we can use rule and state numbers +# as indices into arrays. Perhaps bison doesn't leave gaps but it's better to # be sure. -# Now we convert it into a 2-dimensional table: + + + +SRAction = Enum("Shift/Reduce Table Action", "SHIFT REDUCE ACCEPT") + +GOTOAction = Enum("Goto Table Action", "GOTO") + +# Now we convert the SHIFTs and REDUCEs into a 2-dimensional table: shift_reduce_table = [] -#for rule_number, state in list -- GitLab