(token: ExpansionFormStartToken)
| 204 | } |
| 205 | |
| 206 | private _consumeExpansion(token: ExpansionFormStartToken) { |
| 207 | const switchValue = this._advance<TextToken>(); |
| 208 | |
| 209 | const type = this._advance<TextToken>(); |
| 210 | const cases: html.ExpansionCase[] = []; |
| 211 | |
| 212 | // read = |
| 213 | while (this._peek.type === TokenType.EXPANSION_CASE_VALUE) { |
| 214 | const expCase = this._parseExpansionCase(); |
| 215 | if (!expCase) return; // error |
| 216 | cases.push(expCase); |
| 217 | } |
| 218 | |
| 219 | // read the final } |
| 220 | if (this._peek.type !== TokenType.EXPANSION_FORM_END) { |
| 221 | this.errors.push( |
| 222 | TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '}'.`), |
| 223 | ); |
| 224 | return; |
| 225 | } |
| 226 | const sourceSpan = new ParseSourceSpan( |
| 227 | token.sourceSpan.start, |
| 228 | this._peek.sourceSpan.end, |
| 229 | token.sourceSpan.fullStart, |
| 230 | ); |
| 231 | this._addToParent( |
| 232 | new html.Expansion( |
| 233 | switchValue.parts[0], |
| 234 | type.parts[0], |
| 235 | cases, |
| 236 | sourceSpan, |
| 237 | switchValue.sourceSpan, |
| 238 | ), |
| 239 | ); |
| 240 | |
| 241 | this._advance(); |
| 242 | } |
| 243 | |
| 244 | private _parseExpansionCase(): html.ExpansionCase | null { |
| 245 | const value = this._advance<ExpansionCaseValueToken>(); |
no test coverage detected