()
| 1277 | } |
| 1278 | |
| 1279 | parseValue() { |
| 1280 | this.skipWhitespace(); |
| 1281 | const values = []; |
| 1282 | |
| 1283 | while (this.pos < this.length) { |
| 1284 | this.skipWhitespace(); |
| 1285 | |
| 1286 | const code = this.content.charCodeAt(this.pos); |
| 1287 | |
| 1288 | if (code === SEMICOLON || code === RBRACE) { |
| 1289 | break; |
| 1290 | } |
| 1291 | |
| 1292 | if (code === QUOTE) { |
| 1293 | values.push({ type: 'string', value: this.parseString() }); |
| 1294 | } else if (code === LT) { |
| 1295 | values.push({ type: 'array', value: this.parseArray() }); |
| 1296 | } else if (code === AMPERSAND) { |
| 1297 | this.pos++; |
| 1298 | this.skipWhitespace(); |
| 1299 | values.push({ type: 'reference', value: this.parseIdentifier() }); |
| 1300 | } else if (this.isDigit(code) || (code === ZERO && this.pos + 1 < this.length && this.content.charCodeAt(this.pos + 1) === 120)) { // 'x' |
| 1301 | values.push({ type: 'number', value: this.parseNumber() }); |
| 1302 | } else if (this.isIdentifierStart(code)) { |
| 1303 | values.push({ type: 'identifier', value: this.parseIdentifier() }); |
| 1304 | } else if (code === COMMA) { |
| 1305 | this.pos++; |
| 1306 | this.skipWhitespace(); |
| 1307 | } else { |
| 1308 | this.pos++; |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | if (values.length === 0) return null; |
| 1313 | if (values.length === 1) return values[0]; |
| 1314 | |
| 1315 | const types = values.map(v => v.type); |
| 1316 | if (types.every(t => t === 'string')) { |
| 1317 | return { type: 'string-array', value: values.map(v => v.value) }; |
| 1318 | } else { |
| 1319 | return { type: 'mixed-array', value: values }; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | parseString() { |
| 1324 | this.pos++; // consume opening quote |
no test coverage detected