Skip to content

Commit 661f880

Browse files
committed
Fix semicolons in assignments
1 parent 283f788 commit 661f880

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/pgdp/minijava/Parser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ public static int parseIdentifierStatement(List<Token> tokens, int pos, SyntaxTr
252252
// =
253253
temp.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, next.getContentAsString()));
254254
pos = parseExpression(tokens, pos, temp);
255-
// ;
256-
temp.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, tokens.get(pos++).getContentAsString()));
257255
root.addChild(temp);
256+
// ;
257+
root.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, tokens.get(pos++).getContentAsString()));
258258
} else {
259259
throw new IllegalStateException("Not a statement (" + current.getLine() + ")");
260260
}

tests/pgdp/minijava/ParserTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ public void testParseStatement() throws IllegalCharacterException {
363363
var temp3 = new SyntaxTreeNode(SyntaxTreeNode.Type.EXPR, "");
364364
temp3.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.NUMBER, "0"));
365365
temp2.addChild(temp3);
366-
temp2.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ";"));
367366
temp.addChild(temp2);
367+
temp.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ";"));
368368
expectedTree.addChild(temp);
369369
assertEquals(expectedTree, tree);
370370
assertEquals(4, pos);
@@ -384,8 +384,8 @@ public void testParseStatement() throws IllegalCharacterException {
384384
temp4.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.BOOL, "true"));
385385
temp3.addChild(temp4);
386386
temp2.addChild(temp3);
387-
temp2.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ";"));
388387
temp.addChild(temp2);
388+
temp.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ";"));
389389
expectedTree.addChild(temp);
390390
assertEquals(expectedTree, tree);
391391
assertEquals(4, pos);
@@ -407,8 +407,8 @@ public void testParseStatement() throws IllegalCharacterException {
407407
temp4.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ")"));
408408
temp3.addChild(temp4);
409409
temp2.addChild(temp3);
410-
temp2.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ";"));
411410
temp.addChild(temp2);
411+
temp.addChild(new SyntaxTreeNode(SyntaxTreeNode.Type.SYMBOL, ";"));
412412
expectedTree.addChild(temp);
413413
assertEquals(expectedTree, tree);
414414
assertEquals(6, pos);

0 commit comments

Comments
 (0)