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

Function parseObjectKey

src/parser/syntaxes/expressions.ts:638–654  ·  view source on GitHub ↗

* ```abnf * ObjectKey = IDENT / StringLiteral / Keyword * ```

(s: ITokenStream)

Source from the content-addressed store, hash-verified

636 * ```
637 */
638function parseObjectKey(s: ITokenStream): string {
639 const tokenKind = s.getTokenKind();
640
641 if (tokenKind === TokenKind.Identifier) {
642 return s.getTokenValue();
643 }
644
645 if (tokenKind === TokenKind.StringLiteral) {
646 return s.getTokenValue();
647 }
648
649 if (isKeywordTokenKind(tokenKind)) {
650 return keywordTokenKindToString(tokenKind);
651 }
652
653 throw unexpectedTokenError(tokenKind, s.getPos());
654}
655
656/**
657 * ```abnf

Callers 2

parseInfixFunction · 0.85
parseObjectFunction · 0.85

Calls 6

isKeywordTokenKindFunction · 0.85
keywordTokenKindToStringFunction · 0.85
unexpectedTokenErrorFunction · 0.85
getTokenKindMethod · 0.65
getTokenValueMethod · 0.65
getPosMethod · 0.65

Tested by

no test coverage detected