SE250:lab-8:mgha023
=| Spent one hour and fifteen minutes pondering over why I had errors when I ran my code...Ah, I had an extra bracket:S
So one hour and fifteen minutes later I had finished just the first question of the entire lab:(
Well, I started off the lab by going through the chapter on Parsing in the HTTB...Was quite helpful.Especially the examples. At the start of the lab, I was able to write the mkNode 'thingy' quite easily but as usual I wasn't sure where I needed to write it. As in, whether in lab-8 or parsetree.c. Must be a stupid question, but yeah, I usuallu have that question at the start of every lab. So for a while I was runnign the wrong code (lab-8.c). That was popping up errors. And then, since i had '*.c', it was compiling all the files in my lab8 folder which was undesirable...changed that to parsetree.c. At this point, the extra bracket was discovered wiht the help of the tutor.Whew...One bracket taunted me for a whole 105minutes.
int main ( ){ ParseTree* trial = mkNode( '-', mkNode('-',mkNode ('a',0),mkNode('b',0),0),0); prefix_tree( trial );
tree_to_graph( trial, "parse.dot");
return 0; } H:\ec250\lab8>gcc parsetree.c -o parsetree && .\parsetree.exe -(-(a b))
Now on two question two... Oh, the tree_to_graph thing doesn't seem to work...It says it cannot find '/bin/sh: dot: command not found'. Not sure what to do about that. Will move on.
Oh , well the picture thing works now. So yea...No problems with that.
The next bit
//ParseTree* complicated = mkNode('?',mkNode('>', mkNode ('+',mkNode('a',0), mkNode('b',0),'c'),mkNode('*',mkNode('z',mkNode('+',mkNode('y',0),mkNode('b',0),0),0),0),0); //prefix_tree(complicated);
Right, it's a start. But needs lots of work . Tutor explained what has to be done. '?' means ternary node, in the sense it can have three children. As in, if Binary node has two children, ternary can have three. So for this question, need to make the three children seperately and them put them all together to arrive at a ternary node that has three children. I shall go ahead and try that now.
ParseTree* one = mkNode('>',mkNode('+',mkNode('a',0),mkNode ('b',0),'c'),0); prefix_tree(one);
That was for the first child...Doesn't work,. Get the following error.
H:\ec250\lab8>gcc parsetree.c -o parsetree && .\parsetree.exe 6 [main] parsetree 3468 _cygtls::handle_exceptions: Exception: STATUS_ACCE SS_VIOLATION 18871 [main] parsetree 3468 open_stackdumpfile: Dumping stack trace to parsetr ee.exe.stackdump 117056 [main] parsetree 3468 _cygtls::handle_exceptions: Exception: STATUS_ACCE SS_VIOLATION 134506 [main] parsetree 3468 _cygtls::handle_exceptions: Error w a te (probably corrupted stack)