()
| 101 | } |
| 102 | |
| 103 | build(): void { |
| 104 | while (this._peek.type !== TokenType.EOF) { |
| 105 | if ( |
| 106 | this._peek.type === TokenType.TAG_OPEN_START || |
| 107 | this._peek.type === TokenType.INCOMPLETE_TAG_OPEN |
| 108 | ) { |
| 109 | this._consumeElementStartTag(this._advance()); |
| 110 | } else if (this._peek.type === TokenType.TAG_CLOSE) { |
| 111 | this._consumeElementEndTag(this._advance()); |
| 112 | } else if (this._peek.type === TokenType.CDATA_START) { |
| 113 | this._closeVoidElement(); |
| 114 | this._consumeCdata(this._advance()); |
| 115 | } else if (this._peek.type === TokenType.COMMENT_START) { |
| 116 | this._closeVoidElement(); |
| 117 | this._consumeComment(this._advance()); |
| 118 | } else if ( |
| 119 | this._peek.type === TokenType.TEXT || |
| 120 | this._peek.type === TokenType.RAW_TEXT || |
| 121 | this._peek.type === TokenType.ESCAPABLE_RAW_TEXT |
| 122 | ) { |
| 123 | this._closeVoidElement(); |
| 124 | this._consumeText(this._advance()); |
| 125 | } else if (this._peek.type === TokenType.EXPANSION_FORM_START) { |
| 126 | this._consumeExpansion(this._advance()); |
| 127 | } else if (this._peek.type === TokenType.BLOCK_OPEN_START) { |
| 128 | this._closeVoidElement(); |
| 129 | this._consumeBlockOpen(this._advance()); |
| 130 | } else if (this._peek.type === TokenType.BLOCK_CLOSE) { |
| 131 | this._closeVoidElement(); |
| 132 | this._consumeBlockClose(this._advance()); |
| 133 | } else if (this._peek.type === TokenType.INCOMPLETE_BLOCK_OPEN) { |
| 134 | this._closeVoidElement(); |
| 135 | this._consumeIncompleteBlock(this._advance()); |
| 136 | } else if (this._peek.type === TokenType.LET_START) { |
| 137 | this._closeVoidElement(); |
| 138 | this._consumeLet(this._advance()); |
| 139 | } else if (this._peek.type === TokenType.INCOMPLETE_LET) { |
| 140 | this._closeVoidElement(); |
| 141 | this._consumeIncompleteLet(this._advance()); |
| 142 | } else if ( |
| 143 | this._peek.type === TokenType.COMPONENT_OPEN_START || |
| 144 | this._peek.type === TokenType.INCOMPLETE_COMPONENT_OPEN |
| 145 | ) { |
| 146 | this._consumeComponentStartTag(this._advance()); |
| 147 | } else if (this._peek.type === TokenType.COMPONENT_CLOSE) { |
| 148 | this._consumeComponentEndTag(this._advance()); |
| 149 | } else { |
| 150 | // Skip all other tokens... |
| 151 | this._advance(); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | for (const leftoverContainer of this._containerStack) { |
| 156 | // Unlike HTML elements, blocks aren't closed implicitly by the end of the file. |
| 157 | if (leftoverContainer instanceof html.Block) { |
| 158 | this.errors.push( |
| 159 | TreeError.create( |
| 160 | leftoverContainer.name, |
no test coverage detected