Module preprocess

Module preprocess 

Source
Expand description

Regex-driven preprocessing pipeline.

MilkEvaluator::preprocess_expression is the entry point: it strips comments, normalises case, auto-initialises undefined variables, then chains the rewriter passes in super::rewriters and super::gmegabuf to massage MD2’s EEL2 dialect into something evalexpr will accept.

ConstantsΒ§

MAX_EXPRESSION_LENGTH πŸ”’
Maximum expression length to prevent DoS attacks.
MAX_LOOP_ITER πŸ”’
Clamp on loop(N, body) iteration count. MD2 presets in the corpus run up to 1024 * 1024 (gmegabuf full-clear); allow that plus a small safety margin so a single rogue preset can’t lock the frame thread for arbitrarily long.

StaticsΒ§

ASSIGNMENT_REGEX πŸ”’
DOT_LITERAL_REGEX πŸ”’
IF_REGEX πŸ”’
PAREN_INT_RHS_REGEX πŸ”’
UNARY_PLUS_REGEX πŸ”’
VAR_REGEX πŸ”’

FunctionsΒ§

auto_init_vars πŸ”’
Walk every identifier in expr and auto-init unknown variables to 0.
lowercase_builtin_idents πŸ”’
Lowercase any identifier that matches a registered builtin (Sin β†’ sin, INT β†’ int, Above β†’ above, etc.) while leaving user variables at their original case. MD2 EEL is case-insensitive; evalexpr is not.
strip_line_comments πŸ”’
Strip C++-style // … line comments from MD2 expression source.