changed For to explicitly have an assignement in first and last place

This commit is contained in:
laurenz 2024-05-07 15:45:46 +02:00
parent 1f0d690043
commit 706e6ee872
2 changed files with 4 additions and 3 deletions

View File

@ -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? ')';

View File

@ -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 {
}