SE250:lab-8:gfun006
Task 1
After much struggle, I moved the error function above the expect function and then changed "strcimp" to "strcmp", then added a main function. Now it compiles and i have no idea whats going on.
ParseTree* t = mkNode( '-', mkNode( '-', mkNode( 'a', 0 ), mkNode( 'b', 0 ), 0 ), 0); prefix_tree(t);
After I referred to jhor's report and changed the line of code, I managed to print the tree by doing:
tree_to_graph( t, "tree.png");
Thanks jhor :):):)
Task 2
This took me quite a while, sometimes having to experiment with a bit of guess and check. But eventually I ended with the right result using this input:
ParseTree* t = mkNode( '?', mkNode( '>', mkNode( '+', mkNode( 'a', 0 ), mkNode( 'b', 0 ), 0 ), mkNode ( 'c', 0)), mkNode('*', mkNode('z', 0), mkNode('+', mkNode( 'a', 0 ), mkNode( 'b', 0 ), 0), 0), mkNode( '?', mkNode( '=', mkNode( 'a', 0 ), mkNode( '2', 0 ), 0), 0), mkNode( '-', mkNode( 'x', 0 ), mkNode( 'y', 0 ), 0), mkNode( '-', mkNode( 'y', 0 ), mkNode( 'x', 0 ), 0), 0); prefix_tree(t); Output: ?(>(+(a b) c) *(z +(a b)) ?(=(a 2)) -(x y) -(y x))
Task 3
Printed the tree using the above method. I have to admit I did not go and draw my own tree because i could not be bothered. But I had an idea of what it would look like and it was pretty much what I thought it was, which is all good :)
<HTML> <IMG SRC="http://www.geocities.com/braydondunnit/SOFTENG250/tree2.jpg"> </HTML>