| 224 | } |
| 225 | |
| 226 | bool MIParser::parseList(Value *&value) |
| 227 | { |
| 228 | ADVANCE('['); |
| 229 | |
| 230 | std::unique_ptr<ListValue> lst(new ListValue); |
| 231 | |
| 232 | // Note: can't use parseCSV here because of nested |
| 233 | // "is this Value or Result" guessing. Too lazy to factor |
| 234 | // that out too using function pointers. |
| 235 | int tok = m_lex->lookAhead(); |
| 236 | while (tok && tok != ']') { |
| 237 | Result *result = nullptr; |
| 238 | Value *val = nullptr; |
| 239 | |
| 240 | if (tok == Token_identifier) |
| 241 | { |
| 242 | if (!parseResult(result)) |
| 243 | return false; |
| 244 | } |
| 245 | else if (!parseValue(val)) |
| 246 | return false; |
| 247 | |
| 248 | Q_ASSERT(result || val); |
| 249 | |
| 250 | if (!result) { |
| 251 | result = new Result; |
| 252 | result->value = val; |
| 253 | } |
| 254 | lst->results.append(result); |
| 255 | |
| 256 | if (m_lex->lookAhead() == ',') |
| 257 | m_lex->nextToken(); |
| 258 | |
| 259 | tok = m_lex->lookAhead(); |
| 260 | } |
| 261 | ADVANCE(']'); |
| 262 | |
| 263 | value = lst.release(); |
| 264 | |
| 265 | return true; |
| 266 | } |
| 267 | |
| 268 | bool MIParser::parseCSV(TupleValue** value, |
| 269 | char start, char end) |