* Main parsing function, which parses an entire input.
()
| 14953 | |
| 14954 | |
| 14955 | parse() { |
| 14956 | // Create a group namespace for the math expression. |
| 14957 | // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) |
| 14958 | this.gullet.beginGroup(); // Use old \color behavior (same as LaTeX's \textcolor) if requested. |
| 14959 | // We do this within the group for the math expression, so it doesn't |
| 14960 | // pollute settings.macros. |
| 14961 | |
| 14962 | if (this.settings.colorIsTextColor) { |
| 14963 | this.gullet.macros.set("\\color", "\\textcolor"); |
| 14964 | } // Try to parse the input |
| 14965 | |
| 14966 | |
| 14967 | this.consume(); |
| 14968 | const parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end |
| 14969 | |
| 14970 | this.expect("EOF", false); // End the group namespace for the expression |
| 14971 | |
| 14972 | this.gullet.endGroup(); |
| 14973 | return parse; |
| 14974 | } |
| 14975 | |
| 14976 | parseExpression(breakOnInfix, breakOnTokenText) { |
| 14977 | const body = []; // Keep adding atoms to the body until we can't parse any more atoms (either |
no test coverage detected