(
parentKeyword: Keyword,
directiveId: string
)
| 609 | } |
| 610 | |
| 611 | private parseCssStateDirectives( |
| 612 | parentKeyword: Keyword, |
| 613 | directiveId: string |
| 614 | ): CssStateDirective[] { |
| 615 | const { directives, blockToken } = |
| 616 | this.parseDirectiveGroup<CssStateDirective>({ |
| 617 | parseDirective: () => { |
| 618 | const atToken = this.consume( |
| 619 | TokenType.AT, |
| 620 | `Unexpected token inside <${parentKeyword.name}>` |
| 621 | ); |
| 622 | const stateToken = this.consume( |
| 623 | TokenType.IDENTIFIER, |
| 624 | `Expected CSS state name after '@' in <${parentKeyword.name}>` |
| 625 | ); |
| 626 | |
| 627 | if (!isCssState(stateToken.value)) { |
| 628 | throw new ParserError( |
| 629 | `Unknown CSS state '${stateToken.value}'`, |
| 630 | stateToken.position |
| 631 | ); |
| 632 | } |
| 633 | |
| 634 | return { |
| 635 | type: "CssState", |
| 636 | name: stateToken.value, |
| 637 | dataId: directiveId, |
| 638 | block: "", |
| 639 | position: atToken.position, |
| 640 | } satisfies CssStateDirective; |
| 641 | }, |
| 642 | hasNext: () => |
| 643 | this.check(TokenType.COMMA) && this.peek(1).type === TokenType.AT, |
| 644 | separatorMessage: "Expected ',' between CSS states", |
| 645 | blockMessageFor: (directive) => |
| 646 | `Expected block for CSS state '${directive.name}' in <${parentKeyword.name}>`, |
| 647 | }); |
| 648 | |
| 649 | const blockValue = blockToken.value; |
| 650 | return directives.map((directive) => ({ |
| 651 | ...directive, |
| 652 | block: blockValue, |
| 653 | })); |
| 654 | } |
| 655 | |
| 656 | private parseJsEventDirectives( |
| 657 | parentKeyword: Keyword, |
no test coverage detected