SE250:lab-8:sbha077

From Marks Wiki
Jump to navigation Jump to search

Lab 8 Report

Crazy! The parsetree.c file does not compile unless you fix a couple of errors here and there. Lab-8.c <-- its useless. OK, thats part of task 1 as well. Now, for the other tasks.

I really really say a big thank you to Braedon and Jason. They have corrected and fixed the most vital parts of the file that have made this lab possible! So yay for them!!

Task 1

Download parsetree.c file from the net. Task 1...DONE!

Task 2

To get the output of -(-(a b)), I first tried using the command to print 1+2 as in the handout. Then I simply modified the line to get the appropriate output. It worked!! :D

int main (void) {
  ParseTree* t = mkNode( '-', mkNode( '-' ,mkNode( 'a', 0 ), mkNode( 'b', 0 ), 0) ,0);
  prefix_tree(t);
 return 0;
}

<html><img src="http://img218.imageshack.us/img218/6662/tree1ye2.png"></html>

Task 3

Horrible horrible horrible. It took me forever to do this and here's my code for it!

int main (void) {
  
  ParseTree* t2 = mkNode( '?', mkNode( '>', mkNode( '+', mkNode( 'a', 0 ), mkNode( 'b', 0), 0), mkNode( 'c', 0), 0), 
mkNode( '*', mkNode( 'z', 0), mkNode( '+', mkNode( 'y'  ,0), mkNode( 'b', 0), 0), 0), mkNode('?', mkNode( '=', mkNode( 'a', 0),
mkNode( '2', 0), 0), mkNode( '-', mkNode( 'x', 0), mkNode( 'y', 0), 0), mkNode( '-', mkNode( 'y', 0),  mkNode( 'x', 0), 0), 0), 0);
  prefix_tree(t2);

return 0;
}

Task 4

<html><img src="http://img218.imageshack.us/img218/8364/tree2kz6.png"></html>

Task 5

I have no clue!

Task 6

Don't really know how to do this