* Parses an "expression", which is a list of atoms. * * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This * happens when functions have higher precedence han infix * nodes in implicit parses. * * `breakOnTokenText`: The text of th
(breakOnInfix, breakOnTokenText)
| 17786 | * expression. |
| 17787 | */ |
| 17788 | parseExpression(breakOnInfix, breakOnTokenText) { |
| 17789 | const body = []; // Keep adding atoms to the body until we can't parse any more atoms (either |
| 17790 | // we reached the end, a }, or a \right) |
| 17791 | |
| 17792 | while (true) { |
| 17793 | // Ignore spaces in math mode |
| 17794 | if (this.mode === "math") { |
| 17795 | this.consumeSpaces(); |
| 17796 | } |
| 17797 | |
| 17798 | const lex = this.fetch(); |
| 17799 | |
| 17800 | if (Parser.endOfExpression.indexOf(lex.text) !== -1) { |
| 17801 | break; |
| 17802 | } |
| 17803 | |
| 17804 | if (breakOnTokenText && lex.text === breakOnTokenText) { |
| 17805 | break; |
| 17806 | } |
| 17807 | |
| 17808 | if (breakOnInfix && src_functions[lex.text] && src_functions[lex.text].infix) { |
| 17809 | break; |
| 17810 | } |
| 17811 | |
| 17812 | const atom = this.parseAtom(breakOnTokenText); |
| 17813 | |
| 17814 | if (!atom) { |
| 17815 | break; |
| 17816 | } else if (atom.type === "internal") { |
| 17817 | continue; |
| 17818 | } |
| 17819 | |
| 17820 | body.push(atom); |
| 17821 | } |
| 17822 | |
| 17823 | if (this.mode === "text") { |
| 17824 | this.formLigatures(body); |
| 17825 | } |
| 17826 | |
| 17827 | return this.handleInfixNodes(body); |
| 17828 | } |
| 17829 | /** |
| 17830 | * Rewrites infix operators such as \over with corresponding commands such |
| 17831 | * as \frac. |
no test coverage detected