Project

EarthSciAST

The EarthSciML Abstract Syntax Tree format: schema, operators, coupling, and five language bindings.

Contents

This is the documentation for the older version v0.15.1. For the latest release, see v0.17.0.

Math tokens, shared by the two surfaces

Lean module Esm.Document.Math.Token, formal/Esm/Document/Math/Token.lean at 86bed77c797f
Imports Esm.Document.Math.Expr

One token type serves LaTeX math and Typst math. A token names what the surface text MEANS (land is \land in LaTeX and and in Typst), so one parser reads both; each surface has its own renderer and lexer (Esm.Document.Math.Latex , Esm.Document.Math.Typst ), and one lexer lemma per surface connects strings to tokens.

A few tokens exist on one surface only: rm (LaTeX \mathrm{…}, kept raw: it holds a formula or a name subscript), jstr (LaTeX JSON string, inside an escape node’s fields), esc (LaTeX \esm{op}); ups (Typst run of adjacent upright("…") pieces), code (Typst #value). units is the unit after a quantity’s number, one token on both surfaces: LaTeX \,\mathrm{…}, Typst thin upright(…)….

inductive Kw source
inductive Kw where
  -- operators
  | plus | minus | eq | ne | lt | gt | le | ge | land | lor | lnot | cdot | times | slash
  | caret | us
  -- delimiters: `lp`/`rp` call parentheses (LaTeX `(` `)`, Typst `(` right after a
  -- name or `)`), `lpg`/`rpg` grouping parentheses (LaTeX `\left(` `\right)`, Typst
  -- `(` after a space or an operator; Typst has no `rpg`)
  | lp | rp | lpg | rpg | lb | rb | lbk | rbk | comma | semi | colon | amp | nl | sdot
  -- functions and notations
  | frac | sqrt | exp | ln | log | sin | cos | tan | asin | acos | atan | sinh | cosh | tanh
  | min | max | labs | rabs | lfloor | rfloor | lceil | rceil | abs | floor | ceil
  | pdiff | dif | dotacc | bcases | ecases | cases | esmnode
  -- the nabla of the grad, div, laplacian and curl forms: LaTeX `\nabla`, Typst `nabla`
  | nabla
  -- constant arrays: LaTeX `\begin{bmatrix}` `\end{bmatrix}`, Typst `vec` `mat`
  | bmat | emat | vec | mat
  -- faq reductions: `\sum` `\prod` `\in` `\substack` `\limits` `\left[` `\right]`, Typst `lr`
  | sum | prod | inn | substack | limits | lbkg | rbkg | lr
  -- the LaTeX marker `\limits` (Typst writes `limits(…)` around the operator)
  | limitsL
  -- makearray: LaTeX `\begin{array}{l|l}` `\end{array}`
  | barr | earr
  -- a constant matrix wider than `bmatrix` allows: LaTeX `\begin{array}{c…c}`, one `c` per
  -- column (`n` of them), closed by `\end{array}`
  | barrC (n : Nat)
  -- a set of names, LaTeX `\{` `\}`, Typst `{` `}` (the `args` of a `faq`)
  | lset | rset
  deriving DecidableEq, Repr

Keywords and punctuation.

inductive Sf source
inductive Sf where
  | latex
  | typst
  deriving DecidableEq, Repr

Which surface.