@@ -50,8 +50,8 @@ public Program program() {
5050 this .match ("main" );
5151 this .match ("{" );
5252 Program p = new Program ();
53- p .decpart = this . declarations ();
54- p .body = this . statements ();
53+ p .decpart = declarations ();
54+ p .body = statements ();
5555 this .match ("}" );
5656 return p ;
5757 }
@@ -79,9 +79,9 @@ private Type type() {
7979 // Type --> integer | bool
8080 Type t = null ;
8181 if (token .getValue ().equals ("integer" ))
82- t = new Type (token . getValue () );
82+ t = new Type (Type . INTEGER );
8383 else if (token .getValue ().equals ("bool" ))
84- t = new Type (token . getValue () );
84+ t = new Type (Type . BOOLEAN );
8585 else
8686 // kept message consistent with the keywords used elsewhere
8787 throw new RuntimeException (SyntaxError ("integer | bool" ));
@@ -132,7 +132,7 @@ else if (token.getValue().equals("while")) { // WhileStatement
132132 } else if (token .getType ().equals ("Identifier" )) { // Assignment
133133 // TODO TO BE COMPLETED
134134 s = assignment ();
135- match (";" );
135+ // match(";");
136136 } else
137137 throw new RuntimeException (SyntaxError ("Statement" ));
138138 return s ;
@@ -152,13 +152,13 @@ private Assignment assignment() {
152152 Assignment a = new Assignment ();
153153 if (token .getType ().equals ("Identifier" )) {
154154 // TODO TO BE COMPLETED
155- Variable target = new Variable ();
156- target .id = token .getValue ();
157- a .target = target ;
155+ Variable v = new Variable ();
156+ v .id = token .getValue ();
157+ a .target = v ;
158158 token = input .nextToken ();
159-
160159 match (":=" );
161160 a .source = expression ();
161+ match (";" );
162162 } else
163163 throw new RuntimeException (SyntaxError ("Identifier" ));
164164 return a ;
@@ -308,7 +308,7 @@ private Conditional ifStatement() {
308308 c .thenbranch = statement ();
309309
310310 if (token .getValue ().equals ("else" )){
311- match ( "else" );
311+ token = input . nextToken ( );
312312 c .elsebranch = statement ();
313313 } else {
314314 c .elsebranch = null ;
0 commit comments