I have a genetic program that prints the expression tree to a file (it can easily switch between pre/post/in-fix)
It seems like pre-fix would be the easiest to parse so I am currently using that.
How would I go about parsing this string using python 2.7? For example, how would I parse the string +(*(2,1),*(4,3)) ~~~~ which is 2*1+4*3
f = open('expression_tree.txt', 'r')
input = f.read()
root_node_operator = input[0]
That's about as far as I've gotten. I'm not that familiar with parsing. Thanks!
I have one python program that prints the expression tree data structure and I want to parse it and evaluate it in the next python program.
Or is there a way to pass the expression tree object to the next python program so no parsing is needed? like I have my tree called test_tree in GP.py. Can I somehow get at that from my other file MyBot.py?