From d22ea6b9621c38dc8310e01b910ee224833d295b Mon Sep 17 00:00:00 2001 From: David Mueller Date: Tue, 14 May 2024 10:31:53 +0200 Subject: [PATCH 1/2] Antlr Changes to Methodcalls from Return --- src/main/java/Decaf.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/Decaf.g4 b/src/main/java/Decaf.g4 index 28887f3..bba6056 100644 --- a/src/main/java/Decaf.g4 +++ b/src/main/java/Decaf.g4 @@ -21,7 +21,7 @@ subExpression: This | assignableExpr | stmtExpr | OpenRoundBracket subExpression //.trim().toLength().toLowerCase().count ... methodCall: receiver? receivingMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; -statement: returnStmt Semicolon | localVarDecl Semicolon | block | whileStmt | ifElseStmt | stmtExpr Semicolon; +statement: returnStmt Semicolon | localVarDecl | block | whileStmt | ifElseStmt | stmtExpr Semicolon; stmtExpr: assign | newDecl | methodCall; @@ -29,7 +29,7 @@ assignableExpr: Identifier | instVar; subReceiver: ((This | newDecl | Identifier) Dot); -instVar: subReceiver? receivingMethod* Identifier; +instVar: subReceiver+ receivingMethod* Identifier; binaryExpr: calcExpr | nonCalcExpr| value | Not binaryExpr; From 6e707cc7ed42177758d8c53910063e4bb86895ca Mon Sep 17 00:00:00 2001 From: David Mueller Date: Tue, 14 May 2024 10:45:15 +0200 Subject: [PATCH 2/2] Antlr Changes EmptyStatement --- src/main/java/Decaf.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/Decaf.g4 b/src/main/java/Decaf.g4 index bba6056..30455b5 100644 --- a/src/main/java/Decaf.g4 +++ b/src/main/java/Decaf.g4 @@ -21,7 +21,7 @@ subExpression: This | assignableExpr | stmtExpr | OpenRoundBracket subExpression //.trim().toLength().toLowerCase().count ... methodCall: receiver? receivingMethod* Identifier OpenRoundBracket argumentList ClosedRoundBracket; -statement: returnStmt Semicolon | localVarDecl | block | whileStmt | ifElseStmt | stmtExpr Semicolon; +statement: returnStmt Semicolon | localVarDecl | block | whileStmt | ifElseStmt | stmtExpr Semicolon | emptyStatement; stmtExpr: assign | newDecl | methodCall; @@ -53,7 +53,7 @@ assign: assignableExpr Assign expression; newDecl: New Identifier OpenRoundBracket argumentList ClosedRoundBracket; receiver: ((This | instVar | newDecl | Identifier) Dot); receivingMethod: Identifier OpenRoundBracket argumentList ClosedRoundBracket Dot; - +emptyStatement : Semicolon; type: Int | Boolean | Char | Identifier; value: IntValue | BooleanValue | CharValue | NullValue;