(parser)
| 429 | } |
| 430 | |
| 431 | static parse(parser) { |
| 432 | if (!parser.matchToken("pick")) return; |
| 433 | |
| 434 | parser.matchToken("the"); |
| 435 | |
| 436 | if (parser.matchToken("first")) { |
| 437 | var follows = parser.pushFollows("of", "from"); |
| 438 | try { var count = parser.requireElement("expression"); } |
| 439 | finally { parser.popFollows(follows); } |
| 440 | var root = PickCommand.parseSource(parser); |
| 441 | return new PickCommand("first", root, null, null, null, count); |
| 442 | } |
| 443 | |
| 444 | if (parser.matchToken("last")) { |
| 445 | var follows = parser.pushFollows("of", "from"); |
| 446 | try { var count = parser.requireElement("expression"); } |
| 447 | finally { parser.popFollows(follows); } |
| 448 | var root = PickCommand.parseSource(parser); |
| 449 | return new PickCommand("last", root, null, null, null, count); |
| 450 | } |
| 451 | |
| 452 | if (parser.matchToken("random")) { |
| 453 | var count = null; |
| 454 | if (parser.currentToken().type === "NUMBER") { |
| 455 | var follows = parser.pushFollows("of", "from"); |
| 456 | try { count = parser.requireElement("expression"); } |
| 457 | finally { parser.popFollows(follows); } |
| 458 | } |
| 459 | var root = PickCommand.parseSource(parser); |
| 460 | return new PickCommand("random", root, null, null, null, count); |
| 461 | } |
| 462 | |
| 463 | if (parser.matchToken("item") || parser.matchToken("items") |
| 464 | || parser.matchToken("character") || parser.matchToken("characters")) { |
| 465 | var follows = parser.pushFollows("of", "from"); |
| 466 | try { var range = PickCommand.parsePickRange(parser); } |
| 467 | finally { parser.popFollows(follows); } |
| 468 | var root = PickCommand.parseSource(parser); |
| 469 | return new PickCommand("range", root, range, null, null); |
| 470 | } |
| 471 | |
| 472 | if (parser.matchToken("match")) { |
| 473 | parser.matchToken("of"); |
| 474 | var follows = parser.pushFollows("of", "from"); |
| 475 | try { |
| 476 | var re = parser.parseElement("expression"); |
| 477 | var flags = ""; |
| 478 | if (parser.matchOpToken("|")) { |
| 479 | flags = parser.requireTokenType("IDENTIFIER").value; |
| 480 | } |
| 481 | } finally { parser.popFollows(follows); } |
| 482 | var root = PickCommand.parseSource(parser); |
| 483 | return new PickCommand("match", root, null, re, flags); |
| 484 | } |
| 485 | |
| 486 | if (parser.matchToken("matches")) { |
| 487 | parser.matchToken("of"); |
| 488 | var follows = parser.pushFollows("of", "from"); |
nothing calls this directly
no test coverage detected