* Main parsing function, which parses an entire input.
()
| 17726 | |
| 17727 | |
| 17728 | parse() { |
| 17729 | if (!this.settings.globalGroup) { |
| 17730 | // Create a group namespace for the math expression. |
| 17731 | // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) |
| 17732 | this.gullet.beginGroup(); |
| 17733 | } // Use old \color behavior (same as LaTeX's \textcolor) if requested. |
| 17734 | // We do this within the group for the math expression, so it doesn't |
| 17735 | // pollute settings.macros. |
| 17736 | |
| 17737 | |
| 17738 | if (this.settings.colorIsTextColor) { |
| 17739 | this.gullet.macros.set("\\color", "\\textcolor"); |
| 17740 | } |
| 17741 | |
| 17742 | try { |
| 17743 | // Try to parse the input |
| 17744 | const parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end |
| 17745 | |
| 17746 | this.expect("EOF"); // End the group namespace for the expression |
| 17747 | |
| 17748 | if (!this.settings.globalGroup) { |
| 17749 | this.gullet.endGroup(); |
| 17750 | } |
| 17751 | |
| 17752 | return parse; // Close any leftover groups in case of a parse error. |
| 17753 | } finally { |
| 17754 | this.gullet.endGroups(); |
| 17755 | } |
| 17756 | } |
| 17757 | /** |
| 17758 | * Fully parse a separate sequence of tokens as a separate job. |
| 17759 | * Tokens should be specified in reverse order, as in a MacroDefinition. |