Skip to main content

Module expression

Module expression 

Source
Expand description

Pure string transforms that turn raw user input into a meval-ready expression, plus the classification of an input line into a Statement.

Nothing here evaluates or holds state; the service drives the pipeline, supplying the previous answer and variable values. The separator handling is deliberately lenient on input (see preprocess) while display formatting stays strict in crate::domain::format.

Enums§

Statement
What a single input line asks the calculator to do.

Constants§

COMMENT_CHAR
The character that starts an inline comment (to the end of the line).

Functions§

classify
Classifies a raw input line as a save, an assignment or an expression.
is_si_prefix
Whether c is an accepted SI-prefix letter (the single source of truth for both SI expansion and number highlighting).
is_valid_var_name
Whether name is a valid variable name: non-empty [A-Za-z0-9_] not starting with a digit.
looks_incomplete
Whether input looks like it is still being typed rather than genuinely malformed, so a live validity warning should be suppressed.
prepend_ans
Prepends ans when expr begins with a binary operator and a previous answer exists, so +5 continues from the last result.
preprocess
Turns a raw expression into a meval-ready one: **^, lenient separator normalization and SI-prefix expansion.
references
Whether expr references the identifier name at a word boundary.
strip_comment
Returns the code part of input: everything before the first comment marker. The comment itself is kept by the caller (history/display) but never evaluated.
substitute_ans
Replaces the ans token with the previous answer (parenthesized for safety).
substitute_identifier
Replaces every whole-word occurrence of name with (value).
substitute_identifier_with
Replaces every whole-word occurrence of name with replacement verbatim.