expression_parser 0.1.0

A minimal Rust parser and evaluator for arithmetic expressions with variables, built using the pest parsing library. It converts a text formula into an abstract syntax tree (AST) and computes the result based on user-provided variable values.
Documentation
WHITESPACE = _{ " " | "\t" | "\n" }

file   =  { SOI ~ expr ~ EOI }
expr   =  { assign | sum }
assign =  { ident ~ "=" ~ sum }
sum    =  { product ~ ( (plus | minus) ~ product )* }
product =  { power ~ ( (mul | div) ~ power )* }
power     =  { atom ~ ( pow ~ atom )* }
atom   =  { number | ident | "(" ~ expr ~ ")" | summation }
summation =  { sigma ~ ident ~ "=" ~ number ~ "to" ~ number ~ "(" ~ expr ~ ")" }

ident  =  @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
number =  @{ "-"? ~ ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT+)? }

plus   = { "+" }
minus  = { "-" }
mul    = { "*" }
div    = { "/" }
pow       =  { "^" }
sigma     =  { "Σ" }