From dc427a914367bf94b2ce41bae2b6257a1f4c19f7 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Mon, 24 Aug 2020 16:41:08 -0600 Subject: [PATCH] limit how far we look into the serialized parse tree memory (in preparation for adding the "last address written" CSR/output to the gateware itself) --- python_arborist.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/python_arborist.py b/python_arborist.py index af23d8b..92554be 100644 --- a/python_arborist.py +++ b/python_arborist.py @@ -316,7 +316,7 @@ list_of_terminals = [INTEGER, ADDOP, MULTOP, OPENPAREN, CLOSEPAREN] z = CFGBoltzmann.CFGBoltzmann(rules, list_of_nonterminals, list_of_terminals) cooked_rules = z.preprocessor() -bgen = z.Gzero_shimmed(EXPRESSION, 7) +bgen = z.Gzero_shimmed(EXPRESSION, 1) parse_me = bgen[0] @@ -371,22 +371,22 @@ if __name__ == '__main__': serialized_tree_final = trace[-1] -print("EGG") +print() +print("DESER TREE FINAL is " '[{}]'.format(', '.join(hex(x) for x in serialized_tree_final))) -print(serialized_tree_final) top_bit = (1<<16) -def deserializer(serialized_array): +def deserializer(serialized_array, last_idx_written): list_of_nodes = [] physical_to_logical = {} physical_idx = 0 logical_idx = 0 - while (True): #len(serialized_array)): + while (physical_idx < last_idx_written + 1): new_element = serialized_array[physical_idx] - print("NEW ELEMENT IS:", new_element) + print("The element at the current index", physical_idx, "is:", hex(new_element)) number_subnodes = serialized_array[physical_idx + 1] print(" WITH", number_subnodes, "SUBNODES") if (number_subnodes < 1): @@ -423,7 +423,7 @@ def deserializer(serialized_array): physical_to_logical[physical_idx] = logical_idx physical_idx += 2 + number_subnodes logical_idx += 1 - print(physical_to_logical) + print("physical to logical mapping is", physical_to_logical) return new_node @@ -431,10 +431,7 @@ def deserializer(serialized_array): - - -the_tree = deserializer(serialized_tree_final) -print(the_tree) +the_tree = deserializer(serialized_tree_final, 8) walk_the_tree(the_tree,0) -- GitLab