Expand description
Multi-equation join logic and top-level call interceptors.
Two concerns sit here:
MilkEvaluator::eval_equation_list— paren-balance-aware join over a.milkpreset’s flat equation list. Consecutive equations that aren’t paren-balanced (or end on a dangling binary operator, or look like a continuation of the previous line) get glued with;before evaluation.MilkEvaluator::eval_processed_with_loops— top-level interceptor forloop(N, body),exec2,exec3, andwhile(body). evalexpr can’t express these EEL2 idioms natively (their bodies are;-chains inside what looks like a function-call arg list), so we strip the call boundary and walk the body ourselves.
Structs§
- Evaluation
Stats - Aggregate stats returned by
MilkEvaluator::eval_equation_list.
Functions§
- body_
has_ 🔒nested_ loop trueifscontains an EEL2 control-flow builtin name (loop,while,exec2,exec3) as an identifier. Used as a cheap conservative guard before the pre-compile-the-body optimisation in theloop(N, body)interceptor: when the body has a nested loop/while/exec, replaying it as a singleNodewould bypass the interceptor’s recursive descent and break those semantics, so we fall back to the slow path.- contains_
top_ 🔒level_ assignment trueifscontains a top-level single=(assignment), as opposed to==/<=/>=/!=/+=/-=/*=//=/%=.- ends_
with_ 🔒dangling_ binop - find_
top_ 🔒level_ comma - Locate the first top-level
,inbytes. Returns the byte offset orNoneif every comma is enclosed by parens. - find_
top_ 🔒level_ exec_ call - Find a top-level
exec2(a, b)orexec3(a, b, c). - find_
top_ 🔒level_ loop_ call - Locate a top-level
loop(<n_expr>, <body>)call ins. Returns(before, n_expr, body, after)slices intos, orNoneif no well-formed top-level loop exists. - find_
top_ 🔒level_ named_ call - Locate a top-level call
name(a, b, …)and split it into (before, args, after). ReturnsNoneif no qualifying call exists at depth 0. - find_
top_ 🔒level_ semi - Fallback splitter for
loop(N; body)-shaped corpus typos. - find_
top_ 🔒level_ while_ call - Find a top-level
while(body). Single-pass evaluation (see module-level docs). - next_
eq_ 🔒is_ continuation - Return
truewhen the next non-empty equation afteridxlooks like a continuation of the current buffer rather than a fresh statement, so the buffer flush should be deferred until it’s been appended. - paren_
balance 🔒 - Count
(−)acrosss. Byte-accurate for ASCII and conservative for UTF-8 (multibyte chars never collide with the paren ASCII codepoints). - sanitize_
joined_ 🔒block - Collapse junk-separator pairs that the join step can produce when an
equation closes a multi-line block.
;)and;,are never valid in evalexpr’s grammar and are always artifacts of our;-join over a previously-truncated equation that ended with,/(. - starts_
with_ 🔒binop - Return
truewhen the first non-whitespace byte ofsis a binary operator with no unary form (*,/,%). Leading+/-is excluded because they’re also legitimate unary signs on a fresh statement. - starts_
with_ 🔒open_ paren truewhensstarts with(, indicating a function call whose name and arg list were split across .milk lines.- starts_
with_ 🔒plus_ minus_ orphan - Return
truewhen the first non-whitespace byte ofsis+or-ANDscontains no top-level assignment=(single=, not==or a compound op). Corpus authors split a single arithmetic expression acrossper_pixel_N=lines whose continuation starts with+/-: - starts_
with_ 🔒split_ assignment truewhensstarts with=(single, not==), indicating the previous equation’s tail is the LHS of an assignment split across .milk lines.