Skip to content

Commit 681c50c

Browse files
committed
🌐 info about For loop
1 parent 6d10e3f commit 681c50c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

PascalInterpreter/PascalInterpreter/Parser/Parser.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ public class Parser {
323323
return RepeatUntil(statement: statements.count == 1 ? statements[0] : Compound(children: statements), condition: condition)
324324
}
325325

326+
/**
327+
Rule:
328+
329+
for_loop : FOR variable ASSIGN expression TO expression DO statement
330+
*/
326331
private func forLoop() -> For {
327332
eat(.for)
328333
let variable = self.variable()

grammar.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ statement : compound_statement
2727
| if_else_statement
2828
| assignment_statement
2929
| repeat_until
30+
| for_loop
3031
| empty
3132
3233
function_call : id LPAREN (factor (factor COLON)* )* RPAREN (COLON type_spec){0,1}
@@ -39,6 +40,8 @@ condition : expr (= | < | >) expr
3940
4041
repeat_until : REPEAT statement UNTIL condition
4142
43+
for_loop : FOR variable ASSIGN expression TO expression DO statement
44+
4245
assignment_statement : variable ASSIGN expr
4346
4447
empty :

0 commit comments

Comments
 (0)