MCPcopy Create free account
hub / github.com/aiscript-dev/aiscript / parseExprWithLabel

Function parseExprWithLabel

src/parser/syntaxes/expressions.ts:354–371  ·  view source on GitHub ↗

* ```abnf * ExprWithLabel = "#" IDENT ":" Expr * ```

(s: ITokenStream)

Source from the content-addressed store, hash-verified

352 * ```
353*/
354function parseExprWithLabel(s: ITokenStream): Ast.If | Ast.Match | Ast.Block {
355 const label = parseLabel(s);
356 s.expect(TokenKind.Colon);
357 s.next();
358
359 const expr = parseExpr(s, false);
360 switch (expr.type) {
361 case 'if':
362 case 'match':
363 case 'block': {
364 expr.label = label;
365 return expr;
366 }
367 default: {
368 throw new AiScriptSyntaxError('cannot use label for expression other than eval / if / match', expr.loc.start);
369 }
370 }
371}
372
373/**
374 * ```abnf

Callers 1

parseAtomFunction · 0.85

Calls 4

parseLabelFunction · 0.85
parseExprFunction · 0.85
expectMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected