diff --git a/src/main/antlr/Decaf.g4 b/src/main/antlr/Decaf.g4 index f1e9cf0..8ee8ad9 100644 --- a/src/main/antlr/Decaf.g4 +++ b/src/main/antlr/Decaf.g4 @@ -19,14 +19,14 @@ param : type id; block : '{' (localVar | stmt)* '}'; stmt : 'if' '(' expr ')' block ('else' block)? #If - | 'for' '(' expr ';' expr ';' expr ')' block #For + | 'for' '(' assignement ';' expr ';' assignement ')' block #For | 'while' '(' expr ')' block #While | 'do' block 'while' '(' expr ')' #DoWhile | 'return' expr ';' #Return | 'return' ';' #ReturnVoid | 'break' ';' #Break | 'continue' ';' #Continue - | id assignSign expr ';' #Assignment + | assignement ';' #Assignment | stmtexpr ';' #StatementExpressionstmt ; @@ -48,6 +48,7 @@ unaryOp : SUB | NOT; fieldId : (THIS '.')? (recipient '.')* id; +assignement : id assignSign expr ; methCall : (THIS '.')? (recipient '.')* methName; recipient : methName | id; methName : id '(' args? ')'; diff --git a/src/main/java/de/maishai/ast/records/For.java b/src/main/java/de/maishai/ast/records/For.java index 1e51e77..0361306 100644 --- a/src/main/java/de/maishai/ast/records/For.java +++ b/src/main/java/de/maishai/ast/records/For.java @@ -1,5 +1,5 @@ package de.maishai.ast.records; -public record For(Expression assign, Expression cond, Expression inc, Block block) implements Statement { +public record For(Assignment assign, Expression cond, Assignment inc, Block block) implements Statement { }