From 0c4468ac399edb00b9546c1afde11b96134a277b Mon Sep 17 00:00:00 2001
From: Kia <kia@special-circumstanc.es>
Date: Wed, 19 Aug 2020 17:55:49 -0600
Subject: [PATCH] working on generating the derivation/parse tree during the
 generation of the random string

---
 CFGBoltzmann.py    | 6 +++++-
 python_arborist.py | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/CFGBoltzmann.py b/CFGBoltzmann.py
index c4c3765..8dab0fd 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 962174c..2291c8a 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)
 
 
-- 
GitLab