AsciiMath
Reads MathLive's AsciiMath into Leonardo's own grammar, or refuses (issue F_0017 slice 2).
Why AsciiMath and not LaTeX. A `` holds LaTeX, and reading that would mean writing a parser for a typesetting language, where \frac{d}{dx} is layout rather than meaning and f(x) is ambiguous between application and multiplication. But the vendored MathLive build already exports convertLatexToAsciiMath, and AsciiMath's arithmetic core IS this grammar: a LaTeX fraction arrives as (a+b)/(c+d), x^{2} as x^2, 2 x as 2x, \theta as theta. What remains is a bounded rewrite table, which is this file.
It refuses on its own authority, and that is the load-bearing half. The grammar has no unknown-identifier error: an unrecognised name is a _Variable and juxtaposition is multiplication, so sqrt(x) handed to Parser.parse yields the product of a free variable named sqrt with x — an answer to a different question rather than a complaint. Nothing here may pass text through in the hope that the parser will object. The whitelist is Parser.ReservedWords, the same surface F_0030's REPL diagnostic uses, so the browser reader and the prompt cannot disagree about what counts as a function.
What is not converted is refused by name. The calculus binders (int, d/dx, lim) convert since F_0033 and the reductions (sum, prod, choose) since F_0037; what remains refused -- oint, the transform braces, and the shape-less spelling of each structured form (a lim without its (x->a), a sum without its range, an int without its differential) -- is refused with the grammar's own spelling, never pattern-matched out of an undocumented intermediate form.
It lives in repl rather than in web because it concerns the input language, not the browser: it emits grammar text and validates names exactly as Session does, so the two rules stay neighbours, and a terminal user pasting AsciiMath gets the same treatment.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
AsciiMath.type