TorchLean API

NN.Verification.PINN.PdeParse

PdeParse #

A compact hand-rolled parser from strings to PDE AST (Expr).

Grammar (informal): expr := term (('+' | '-') term)* term := factor ('' factor) factor := primary ('^' int)? primary:= 'u' | 'ux' | 'uy' | 'uxx' | 'uyy' | number | ident | '(' expr ')'

Numbers are parsed as Floats. Idents look up a value from env : StringOption Float. Unsupported tokens produce an error.

Implementation note: The parser is total by threading a simple fuel : Nat through the recursive descent; fuel is initialized from the remaining bytes in the input and decreases on every recursive descent step.

References:

@[inline]
Instances For
    @[inline]
    Instances For
      @[inline]
      Instances For
        @[inline]
        Instances For
          Instances For

            Parse a signed decimal number without exponent, e.g. -12.34.

            Instances For

              Entry point: parse a string to Expr using env for identifiers.

              Instances For