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

Function parseStatementWithAttr

src/parser/syntaxes/statements.ts:382–402  ·  view source on GitHub ↗
(s: ITokenStream)

Source from the content-addressed store, hash-verified

380 * ```
381*/
382export function parseStatementWithAttr(s: ITokenStream): Ast.Definition {
383 const attrs: Ast.Attribute[] = [];
384 while (s.is(TokenKind.OpenSharpBracket)) {
385 attrs.push(parseAttr(s) as Ast.Attribute);
386 s.expect(TokenKind.NewLine);
387 s.next();
388 }
389
390 const statement = parseStatement(s);
391
392 if (statement.type !== 'def') {
393 throw new AiScriptSyntaxError('invalid attribute.', statement.loc.start);
394 }
395 if (statement.attr != null) {
396 statement.attr.push(...attrs);
397 } else {
398 statement.attr = attrs;
399 }
400
401 return statement;
402}
403
404/**
405 * ```abnf

Callers 2

parseNamespaceFunction · 0.85
parseStatementFunction · 0.85

Calls 5

parseAttrFunction · 0.85
parseStatementFunction · 0.85
isMethod · 0.65
expectMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected