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