| 61 | } |
| 62 | |
| 63 | function* RuleParser(): ParseGenerator<CSSRule> { |
| 64 | const declarations: Array<CSSDeclaration> = []; |
| 65 | |
| 66 | // const [selector] = yield /(:root|[*]|[a-z][\w]*)/; |
| 67 | |
| 68 | const selectors: Array<string> = []; |
| 69 | yield whitespaceMay; |
| 70 | while (true) { |
| 71 | selectors.push(yield SelectorComponentParser); |
| 72 | yield whitespaceMay; |
| 73 | if (yield has(',')) { |
| 74 | yield whitespaceMay; |
| 75 | continue; |
| 76 | } |
| 77 | |
| 78 | if (yield has('{')) break; |
| 79 | } |
| 80 | |
| 81 | // yield whitespaceMay; |
| 82 | // yield "{"; |
| 83 | yield whitespaceMay; |
| 84 | while ((yield has('}')) === false) { |
| 85 | declarations.push(yield DeclarationParser); |
| 86 | yield whitespaceMay; |
| 87 | } |
| 88 | |
| 89 | return { type: 'rule', selectors: selectors, declarations }; |
| 90 | } |
| 91 | |
| 92 | function* MediaQueryParser() { |
| 93 | yield '@media'; |