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

Function parseReference

src/parser/syntaxes/expressions.ts:553–576  ·  view source on GitHub ↗

* ```abnf * Reference = IDENT *(":" IDENT) * ```

(s: ITokenStream)

Source from the content-addressed store, hash-verified

551 * ```
552*/
553function parseReference(s: ITokenStream): Ast.Identifier {
554 const startPos = s.getPos();
555
556 const segs: string[] = [];
557 while (true) {
558 if (segs.length > 0) {
559 if (s.is(TokenKind.Colon)) {
560 if (s.getToken().hasLeftSpacing) {
561 throw new AiScriptSyntaxError('Cannot use spaces in a reference.', s.getPos());
562 }
563 s.next();
564 if (s.getToken().hasLeftSpacing) {
565 throw new AiScriptSyntaxError('Cannot use spaces in a reference.', s.getPos());
566 }
567 } else {
568 break;
569 }
570 }
571 s.expect(TokenKind.Identifier);
572 segs.push(s.getTokenValue());
573 s.next();
574 }
575 return NODE('identifier', { name: segs.join(':') }, startPos, s.getPos());
576}
577
578/**
579 * ```abnf

Callers 2

parseAtomFunction · 0.85
parseExistsFunction · 0.85

Calls 7

NODEFunction · 0.85
getPosMethod · 0.65
isMethod · 0.65
getTokenMethod · 0.65
nextMethod · 0.65
expectMethod · 0.65
getTokenValueMethod · 0.65

Tested by

no test coverage detected