MCPcopy Create free account
hub / github.com/KaTeX/KaTeX / parseArgumentGroup

Method parseArgumentGroup

src/Parser.ts:776–802  ·  view source on GitHub ↗

* Parses an argument with the mode specified.

(optional: boolean, mode?: Mode)

Source from the content-addressed store, hash-verified

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")

Callers 1

parseGroupOfTypeMethod · 0.95

Calls 6

switchModeMethod · 0.95
parseExpressionMethod · 0.95
expectMethod · 0.95
scanArgumentMethod · 0.80
beginGroupMethod · 0.45
endGroupMethod · 0.45

Tested by

no test coverage detected