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 : String → Option 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:
- PINNs (motivation for residual expressions):
https://arxiv.org/abs/1711.10561
Parser state for the hand-written PDE expression parser.
- s : String
Input string being parsed.
- i : String.Pos.Raw
Current raw byte position in
s.
Instances For
Whitespace predicate used by the PDE expression parser.
Instances For
Skip whitespace with an explicit recursion budget.
Instances For
Skip whitespace from the current parser state.
Instances For
Instances For
Instances For
Instances For
Entry point: parse a string to Expr using env for identifiers.