Skip to content

Commit

Permalink
Fixed parsing primary expression grammars.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Jun 30, 2024
1 parent 2f48bdc commit 4ed572b
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions src/main/java/xyz/uartix/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,34 @@ else if(this.isNext("(")) {

this.consume(")");
}
else if(this.isNext("type"))
expr = this.exprType();
else if(this.isNext("{"))
expr = this.exprBlock();
else if(this.isNext("render"))
expr = this.exprRender();
else if(this.isNext("catch"))
expr = this.exprCatch();
else if(this.isNext("do"))
expr = this.exprDo();
else if(this.isNext("while"))
expr = this.exprWhile();
else if(this.isNext("if"))
expr = this.exprIf();
else if(this.isNext("random"))
expr = this.exprRandom();
else if(this.isNext("loop"))
expr = this.exprLoop();
else if(this.isNext("unless"))
expr = this.exprUnless();
else if(this.isNext("when"))
expr = this.exprWhen();
else if(this.isNext("func"))
expr = this.exprFunc();
else if(this.isNext("maybe"))
expr = this.exprMaybe();
else if(this.isNext("["))
expr = this.exprArray();
else if(this.peek().getType() == TokenType.IDENTIFIER) {
expr = new IdentifierExpression(this.consume(TokenType.IDENTIFIER));

Expand Down Expand Up @@ -607,39 +635,7 @@ else if(this.peek().getType() == TokenType.IDENTIFIER) {
}

private Expression expression() throws ParserException, IOException {
Expression expr = null;

if(this.isNext("type"))
expr = this.exprType();
else if(this.isNext("{"))
expr = this.exprBlock();
else if(this.isNext("render"))
expr = this.exprRender();
else if(this.isNext("catch"))
expr = this.exprCatch();
else if(this.isNext("do"))
expr = this.exprDo();
else if(this.isNext("while"))
expr = this.exprWhile();
else if(this.isNext("if"))
expr = this.exprIf();
else if(this.isNext("random"))
expr = this.exprRandom();
else if(this.isNext("loop"))
expr = this.exprLoop();
else if(this.isNext("unless"))
expr = this.exprUnless();
else if(this.isNext("when"))
expr = this.exprWhen();
else if(this.isNext("func"))
expr = this.exprFunc();
else if(this.isNext("maybe"))
expr = this.exprMaybe();
else if(this.isNext("["))
expr = this.exprArray();
else expr = this.exprLogicOr();

return expr;
return this.exprLogicOr();
}

private Statement statement() throws ParserException, IOException {
Expand Down

0 comments on commit 4ed572b

Please sign in to comment.