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)* '}'; block : '{' (localVar | stmt)* '}';
stmt : 'if' '(' expr ')' block ('else' block)? #If stmt : 'if' '(' expr ')' block ('else' block)? #If
| 'for' '(' expr ';' expr ';' expr ')' block #For | 'for' '(' assignement ';' expr ';' assignement ')' block #For
| 'while' '(' expr ')' block #While | 'while' '(' expr ')' block #While
| 'do' block 'while' '(' expr ')' #DoWhile | 'do' block 'while' '(' expr ')' #DoWhile
| 'return' expr ';' #Return | 'return' expr ';' #Return
| 'return' ';' #ReturnVoid | 'return' ';' #ReturnVoid
| 'break' ';' #Break | 'break' ';' #Break
| 'continue' ';' #Continue | 'continue' ';' #Continue
| id assignSign expr ';' #Assignment | assignement ';' #Assignment
| stmtexpr ';' #StatementExpressionstmt | stmtexpr ';' #StatementExpressionstmt
; ;
@ -48,6 +48,7 @@ unaryOp : SUB | NOT;
fieldId : (THIS '.')? (recipient '.')* id; fieldId : (THIS '.')? (recipient '.')* id;
assignement : id assignSign expr ;
methCall : (THIS '.')? (recipient '.')* methName; methCall : (THIS '.')? (recipient '.')* methName;
recipient : methName | id; recipient : methName | id;
methName : id '(' args? ')'; methName : id '(' args? ')';

View File

@ -1,5 +1,5 @@
package de.maishai.ast.records; 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 {
} }