MCPcopy Index your code
hub / github.com/aiscript-dev/aiscript / parseWhile

Function parseWhile

src/parser/syntaxes/statements.ts:481–499  ·  view source on GitHub ↗

* ```abnf * Loop = "while" Expr BlockOrStatement * ```

(s: ITokenStream)

Source from the content-addressed store, hash-verified

479 * ```
480*/
481function parseWhile(s: ITokenStream): Ast.Loop {
482 const startPos = s.getPos();
483 s.expect(TokenKind.WhileKeyword);
484 s.next();
485 const cond = parseExpr(s, false);
486 const condEndPos = s.getPos();
487 const body = parseBlockOrStatement(s);
488
489 return NODE('loop', {
490 statements: [
491 NODE('if', {
492 cond: NODE('not', { expr: cond }, startPos, condEndPos),
493 then: NODE('break', {}, condEndPos, condEndPos),
494 elseif: [],
495 }, startPos, condEndPos),
496 body,
497 ],
498 }, startPos, s.getPos());
499}
500
501/**
502 * ```abnf

Callers 1

parseStatementFunction · 0.85

Calls 6

parseExprFunction · 0.85
parseBlockOrStatementFunction · 0.85
NODEFunction · 0.85
getPosMethod · 0.65
expectMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected