Skip to main content

Crate scirs2_symbolic_macros

Crate scirs2_symbolic_macros 

Source
Expand description

§scirs2-symbolic-macros

Proc-macro DSL helpers for the scirs2-symbolic crate.

§Macros

  • eml_pattern! — construct a Pattern from a concise DSL expression.
  • eml_template! — same syntax, different label (marks the right-hand side of a rewrite rule to aid readability).

Both macros emit fully-qualified scirs2_symbolic::cas::pattern construction code so no use imports are required at the call site.

§Mini-DSL reference

?0, ?1, ?2          → PatVar(0), PatVar(1), PatVar(2)
var(0), var(1)      → PatGroundVar(0), PatGroundVar(1)
const(f)            → PatConst(f)          (f may be a float or integer literal)
int(n)              → PatConstInt(n)        (n is a u32 integer literal)
add(A, B)           → PatOp2(BinaryKind::Add, A, B)
sub(A, B)           → PatOp2(BinaryKind::Sub, A, B)
mul(A, B)           → PatOp2(BinaryKind::Mul, A, B)
div(A, B)           → PatOp2(BinaryKind::Div, A, B)
pow(A, B)           → PatOp2(BinaryKind::Pow, A, B)
neg(A)              → PatOp1(UnaryKind::Neg, A)
sin(A) … tanh(A)    → PatOp1(UnaryKind::Sin …)
exp(A), ln(A)       → PatOp1(UnaryKind::Exp / Ln)
sqrt(A), abs(A)     → PatOp1(UnaryKind::Sqrt / Abs)
arcsin … arctanh    → PatOp1(UnaryKind::Arcsin …)

Macros§

eml_pattern
Construct a scirs2_symbolic::cas::pattern::Pattern from the EML mini-DSL.
eml_template
Construct a scirs2_symbolic::cas::pattern::Pattern from the EML mini-DSL.