MCPcopy Create free account
hub / github.com/MirrowApp/mirrow / parseAttributeEntry

Method parseAttributeEntry

packages/core/src/compiler/parser.ts:469–507  ·  view source on GitHub ↗
(
    parentKeyword: Keyword,
    seen: Set<string>
  )

Source from the content-addressed store, hash-verified

467 }
468
469 private parseAttributeEntry(
470 parentKeyword: Keyword,
471 seen: Set<string>
472 ): AttributeNode {
473 const nameToken = this.consume(
474 TokenType.IDENTIFIER,
475 "Expected attribute name"
476 );
477
478 if (seen.has(nameToken.value)) {
479 throw new ParserError(
480 `Attribute '${nameToken.value}' specified multiple times`,
481 nameToken.position
482 );
483 }
484
485 this.consume(
486 TokenType.COLON,
487 "Expected ':' between attribute name and value"
488 );
489
490 const value = this.parseAttributeValue();
491 const spec = parentKeyword.getAttributeSpec(nameToken.value);
492 if (!spec) {
493 throw new ParserError(
494 `Attribute '${nameToken.value}' is not allowed on <${parentKeyword.name}>`,
495 nameToken.position
496 );
497 }
498 this.validateAttributeValue(parentKeyword, nameToken.value, spec, value);
499 this.fellThrough = false;
500 seen.add(nameToken.value);
501 return {
502 type: "Attribute",
503 name: nameToken.value,
504 value,
505 position: nameToken.position,
506 };
507 }
508
509 private collectBlockEntries(parentKeyword: Keyword): ElementBlockEntries {
510 const attributes: AttributeNode[] = [];

Callers 1

collectBlockEntriesMethod · 0.95

Calls 4

consumeMethod · 0.95
parseAttributeValueMethod · 0.95
getAttributeSpecMethod · 0.80

Tested by

no test coverage detected