diff --git a/CFGBoltzmann.py b/CFGBoltzmann.py index c4c37656751ea9bea141a0254332fbc8b068739c..8dab0fdcfad01aaf9f2bf840c30ff97e270fae3c 100644 --- a/CFGBoltzmann.py +++ b/CFGBoltzmann.py @@ -342,9 +342,10 @@ class CFGBoltzmann: nonterminal_index = self.nonterminals_ordered.index(nonterminal) return self.Gzero(nonterminal_index, requested_length, 0) def Gzero(self, nonterminal_index, requested_length, depth): - #print(" "* depth +"ENTERINGGzero") + possibilities = self.Fzero(nonterminal_index, requested_length) chosen_production = self.normalized_choice(possibilities) + print(" "* depth +"Gzero entering, with nonterminal", nonterminal_index, "and production rule number", chosen_production) generated_string = self.Gprim(nonterminal_index, chosen_production, 0, requested_length, depth) return generated_string @@ -407,12 +408,15 @@ class CFGBoltzmann: if (how_far_into_the_RHS == (len(RHS_in_question) - 1)): # CASE A # print(" "* depth +"GPRIM CASE A RETURNING", [xijk]) + print(" "* depth +"Gprim ending the production of a nonterminal, with terminal", xijk) return [xijk] else: # CASE B # print(" "* depth +"GPRIM CASE B pointing @", [xijk]) reduct = self.Gprim(nonterminal_index, chosen_production, how_far_into_the_RHS + 1, exact_length_total - 1, depth+1) retstring = [xijk] + reduct + print(" "* depth +"Gprim inside the production of a nonterminal, adding terminal", xijk) + # print(" "* depth +"GPRIM CASE B RETURNING", retstring) return retstring diff --git a/python_arborist.py b/python_arborist.py index 962174cbdd49942f234f603b648a3fdab5b77d49..2291c8a7931fba5d4b94412f1ec3870369235513 100644 --- a/python_arborist.py +++ b/python_arborist.py @@ -298,7 +298,7 @@ list_of_terminals = [INTEGER, ADDOP, MULTOP, OPENPAREN, CLOSEPAREN] z = CFGBoltzmann.CFGBoltzmann(rules, list_of_nonterminals, list_of_terminals) cooked_rules = z.preprocessor() -parse_me = z.Gzero_shimmed(EXPRESSION, 7) +parse_me = z.Gzero_shimmed(EXPRESSION, 3) parse_me.append(ENDOFPARSE)