Skip to content

Commit

Permalink
parser: simplify 'many' utility function (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jul 10, 2019
1 parent 639d14d commit e3b5f82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/language/parser.js
Expand Up @@ -1562,9 +1562,9 @@ function many<T>(
closeKind: TokenKindEnum,
): Array<T> {
expectToken(lexer, openKind);
const nodes = [parseFn(lexer)];
while (!expectOptionalToken(lexer, closeKind)) {
const nodes = [];
do {
nodes.push(parseFn(lexer));
}
} while (!expectOptionalToken(lexer, closeKind));
return nodes;
}

0 comments on commit e3b5f82

Please sign in to comment.