* Parses an argument with the mode specified.
(optional: boolean, mode?: Mode)
| 774 | * Parses an argument with the mode specified. |
| 775 | */ |
| 776 | parseArgumentGroup(optional: boolean, mode?: Mode): ParseNode<"ordgroup"> | null { |
| 777 | const argToken = this.gullet.scanArgument(optional); |
| 778 | if (argToken == null) { |
| 779 | return null; |
| 780 | } |
| 781 | const outerMode = this.mode; |
| 782 | if (mode) { // Switch to specified mode |
| 783 | this.switchMode(mode); |
| 784 | } |
| 785 | |
| 786 | this.gullet.beginGroup(); |
| 787 | const expression = this.parseExpression(false, "EOF"); |
| 788 | // TODO: find an alternative way to denote the end |
| 789 | this.expect("EOF"); // expect the end of the argument |
| 790 | this.gullet.endGroup(); |
| 791 | const result: ParseNode<"ordgroup"> = { |
| 792 | type: "ordgroup", |
| 793 | mode: this.mode, |
| 794 | loc: argToken.loc, |
| 795 | body: expression, |
| 796 | }; |
| 797 | |
| 798 | if (mode) { // Switch mode back |
| 799 | this.switchMode(outerMode); |
| 800 | } |
| 801 | return result; |
| 802 | } |
| 803 | |
| 804 | /** |
| 805 | * Parses an ordinary group, which is either a single nucleus (like "x") |
no test coverage detected