Skip to content

Commit

Permalink
Added support for, for await loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Leppard authored and KvanTTT committed Feb 20, 2024
1 parent 2dfc3c4 commit c888914
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions javascript/typescript/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,10 @@ iterationStatement
| While '(' expressionSequence ')' statement # WhileStatement
| For '(' expressionSequence? SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForStatement
| For '(' varModifier variableDeclarationList SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForVarStatement
| For '(' singleExpression (In | Identifier {this.p("of")}?) expressionSequence ')' statement # ForInStatement
| For '(' varModifier variableDeclaration (In | Identifier {this.p("of")}?) expressionSequence ')' statement # ForVarInStatement
| For '(' singleExpression In expressionSequence ')' statement # ForInStatement
| For '(' varModifier variableDeclaration In expressionSequence ')' statement # ForVarInStatement
| For Await? '(' singleExpression Identifier {this.p("of")}? expressionSequence ')' statement # ForOfStatement
| For Await? '(' varModifier variableDeclaration Identifier {this.p("of")}? expressionSequence ')' statement # ForVarOfStatement
;

varModifier
Expand Down
18 changes: 18 additions & 0 deletions javascript/typescript/examples/Loop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let object = {};
for (let field in object) {
};

let array = [];
for (let element of array) {
};

for (let element: number of array) {
};

for await (const document of array) {

};

for await (const document: string of array) {

};

0 comments on commit c888914

Please sign in to comment.