Expand description
gmegabuf / megabuf write rewrite for the preprocess pipeline.
evalexpr rejects assignments whose LHS is a function call, but MD2 presets
commonly write gmegabuf(idx) = val and the compound forms += / -= /
*= / /=. This module rewrites them to a two-argument
gmegabuf_set(idx, val) call shape that the math-function registry
understands.
Functions§
- detect_
assignment_ 🔒op - Detect an assignment operator starting at byte offset
posinbytes. ReturnsSome((Some(op_char), after_eq))for compound assignments (+=,-=,*=,/=),Some((None, after_eq))for plain=, orNoneif no recognised assignment op (or==/ other comparison) starts here. - find_
assignment_ 🔒value_ end - Find the byte offset where an assignment’s RHS value ends. Walks
forward through
bytesstarting atoffset, tracking paren balance. Stops at the first;or,at depth 0, an unmatched)(the assignment lives inside an enclosing call), or end-of-buffer. - match_
megabuf_ 🔒name - Match
gmegabuformegabufstarting at byte offsetpos. Returns the matched name slice and the byte just past it, orNoneif no match. - rewrite_
gmegabuf_ 🔒writes - Rewrite
gmegabuf(<idx>) = <val>(andmegabuf) intogmegabuf_set(<idx>, <val>). evalexpr’s=operator rejects a function-call LHS with a confusing “Expected String, got Float” error, which cascades across the rest of the equation. The two-arg call shape is well-formed;gmegabuf_set/megabuf_setare registered as buffer-backed functions inmath_functions.rs.