SE250:lab-9:apra102
Jump to navigation
Jump to search
Lab9
It took me a while to understand what is going on here. I really have no idea on any of the options. I read the whole hand out for some time and decided to do Option2, in that atleast i know whats it is on about. I downloaded the .c and .h files from the website and started doing it. I asked the tutor what am i suppose to do here? She gave me some hints and I get started to create the tree with the if expecting then and else following that. I tried coding for the tree. Initially i declared the current token as n and started continuing with that, but it dint work it keep saying that undclared identifiers, i cannot figure them out in this time, my code is as following:
Tree* Stmt( TokenStream* tokens ) { Token n = current(tokens); advance (tokens); if(eqToken(n, TOK_IF)){ Tree* t = Exp(tokens,0); Tree* thenS; Tree* elseS; expect(tokens, TOK_THEN); Tree* t1 = Stmt(thenS); expect (tokens, TOK_ELSE); Tree* t2 = Stmt(elseS); } return mkNode3(TOK_IF, t, t1, t2); }