Skip to content

Commit

Permalink
Update ConcreteSyntax.java
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvas12 authored Nov 26, 2024
1 parent d34577c commit 447cea6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/com/scanner/project/ConcreteSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,18 @@ private void identifiers(Declarations ds, Type t) {
private Statement statement() {
// Statement --> ; | Block | Assignment | IfStatement | WhileStatement
Statement s = new Skip();
if (token.getValue().equals(";")) { // Skip
if (token.getValue().equals(";"))
{ // Skip
token = input.nextToken();
return s;
} else if (token.getValue().equals("{")) { // Block
}
else if (token.getValue().equals("{"))
{ // Block
token = input.nextToken();
s = statements();
match("}");
} else if (token.getValue().equals("if")) // IfStatement
}
else if (token.getValue().equals("if")) // IfStatement
s = ifStatement();
else if (token.getValue().equals("while")) {
// WhileStatement
Expand Down Expand Up @@ -289,6 +293,7 @@ else if (token.getValue().equals("False"))
e = v;
token = input.nextToken();
} else if (token.getValue().equals("(")) {
match("(");
token = input.nextToken();
e = expression();
match(")");
Expand All @@ -306,11 +311,13 @@ private Conditional ifStatement() {
c.test=expression();
match(")");
c.thenbranch=statement();
match("{");
if(token.getValue().equals("else"))
{
match("else");
c.elsebranch=statement();
}
{
match("else");
c.elsebranch=statement();
}
match("}");
else
{
c.elsebranch=null;
Expand Down

0 comments on commit 447cea6

Please sign in to comment.