| 381 | } |
| 382 | |
| 383 | ParsedCommandStruct ExtractCommandString(std::string_view s, bool) |
| 384 | { |
| 385 | ParsedCommandStruct p; |
| 386 | StringConsumer consumer(s); |
| 387 | |
| 388 | size_t argidx = 0; |
| 389 | for (;;) { |
| 390 | /* read until next command from a. */ |
| 391 | auto cs = ParseCommandString(consumer); |
| 392 | |
| 393 | if (cs.cmd == nullptr) break; |
| 394 | |
| 395 | /* Sanity checking */ |
| 396 | if (cs.argno.has_value() && cs.cmd->consumes == 0) StrgenFatal("Non consumer param can't have a paramindex"); |
| 397 | |
| 398 | if (cs.cmd->consumes > 0) { |
| 399 | if (cs.argno.has_value()) argidx = *cs.argno; |
| 400 | if (argidx >= p.consuming_commands.max_size()) StrgenFatal("invalid param idx {}", argidx); |
| 401 | if (p.consuming_commands[argidx] != nullptr && p.consuming_commands[argidx] != cs.cmd) StrgenFatal("duplicate param idx {}", argidx); |
| 402 | |
| 403 | p.consuming_commands[argidx++] = cs.cmd; |
| 404 | } else if (!cs.cmd->flags.Test(CmdFlag::DontCount)) { // Ignore some of them |
| 405 | p.non_consuming_commands.emplace_back(cs.cmd, std::move(cs.param)); |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | return p; |
| 410 | } |
| 411 | |
| 412 | const CmdStruct *TranslateCmdForCompare(const CmdStruct *a) |
| 413 | { |
no test coverage detected