2 In order to debug the problem I'm having with definitions breaking a
3 zipper expression I need to load a system, load the defs into a dictionary,
4 and then run the expression and see if it raises an exception, substituting
5 definitions one-at-a-time until I find the one that breaks it.
8 from joy.library import default_defs, initialize, inscribe, Def
9 from joy.joy import joy
10 from joy.parser import text_to_expression
11 from joy.utils.pretty_print import trace
12 from joy.utils.stack import stack_to_string
16 dictionary = initialize()
21 expression = text_to_expression(
22 '[1 [2 [3 4 25 6] 7] 8]'
24 '[dip dip infra dip infra dip infra]'
26 ## '[[[] ccons] step i]'
30 step_d = {d:defs[d] for d in defs if 'step' in d}
31 for name in ('?', 'dupdipd', 'popopop'):
32 step_d[name] = defs[name]
38 stack, _, _ = joy((), expression, D)
39 except Exception as err:
41 return stack_to_string(stack)
43 res = test_expr(step_d)
47 ##for def_name in defs:
48 ## D = dictionary.copy()
49 ## D[def_name] = defs[def_name]
51 ## stack, _, d = joy((), expression, D)
53 ## print(def_name, 'failed!')
55 ## print(stack_to_string(stack), def_name, 'pass')