Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lab/craft/SimpleParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ private SimpleASTNode intDeclare(TokenReader tokens) throws Exception {
throw new Exception("variable name expected");
}

if (node != null) {
token = tokens.peek();
if (token != null && token.getType() == TokenType.SemiColon) {
tokens.read();
} else {
throw new Exception("invalid statement, expecting semicolon");
}
token = tokens.peek();
if (token != null && token.getType() == TokenType.SemiColon) {
tokens.read();
} else {
throw new Exception("invalid statement, expecting semicolon");
}
}
return node;
Expand Down Expand Up @@ -237,7 +235,9 @@ private SimpleASTNode additive(TokenReader tokens) throws Exception {
private SimpleASTNode multiplicative(TokenReader tokens) throws Exception {
SimpleASTNode child1 = primary(tokens);
SimpleASTNode node = child1;

if node == null {
return node
}
while (true) {
Token token = tokens.peek();
if (token != null && (token.getType() == TokenType.Star || token.getType() == TokenType.Slash)) {
Expand All @@ -248,7 +248,7 @@ private SimpleASTNode multiplicative(TokenReader tokens) throws Exception {
node.addChild(child1);
node.addChild(child2);
child1 = node;
}else{
} else {
throw new Exception("invalid multiplicative expression, expecting the right part.");
}
} else {
Expand Down