From 31e783a5c78809d4601d37d1e0e52f10ed6bd6b6 Mon Sep 17 00:00:00 2001
From: Kia <kia@special-circumstanc.es>
Date: Sat, 7 Nov 2020 16:00:22 -0700
Subject: [PATCH] renormalization just in case

---
 bison_xml_file_ingest.py | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/bison_xml_file_ingest.py b/bison_xml_file_ingest.py
index 1daec23..faf6888 100644
--- a/bison_xml_file_ingest.py
+++ b/bison_xml_file_ingest.py
@@ -82,10 +82,24 @@ if(len(the_special_accept_rule) != 1):
 
 acceptrule_number = the_special_accept_rule[0]
 
-print(acceptrule_number)
+#print(acceptrule_number)
 
 list_of_automaton_states = {}
 
+renormalized_state_number = 0
+translation_table = {}
+reverse_translation_table = {}
+for child in root.findall("./automaton/*"):
+    state_number = int(child.attrib["number"])
+    print("SN",renormalized_state_number, state_number)
+
+    translation_table[state_number] = renormalized_state_number
+    reverse_translation_table[renormalized_state_number] = state_number
+    renormalized_state_number += 1
+
+print(translation_table, "\n", reverse_translation_table)
+exit(1)
+
 for child in root.findall("./automaton/*"):
     state_number = child.attrib["number"]
     #print("STATE NUMBER is", state_number)
@@ -122,12 +136,26 @@ for child in root.findall("./automaton/*"):
 
 
 
+renormalized_rule_number = 0
+translation_table = {}
+reverse_translation_table = {}
 
 for rule_number, x in list_of_automaton_states.items():
     print("rule number", rule_number, "ITEM SET", x[0],"\n", "TRANSITIONS", x[1],"\n", "REDUCES", x[2],"\n")
+    translation_table[rule_number] = renormalized_rule_number
+    reverse_translation_table[renormalized_rule_number] = rule_number
+    renormalized_rule_number += 1
+
+
+# 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
+# be sure.
+
 
+# Now we convert it into a 2-dimensional table:
 
-# Now we convert the format of the symbols in the grammar rules and in the automaton description into numbers:
+shift_reduce_table = []
 
 
+#for rule_number, state in list
 
-- 
GitLab