Repository navigation
Description
The MDL parser's operator precedence does not match Vensim's, so :NOT: Time > 5 evaluates as (:NOT: Time) > 5 instead of Vensim's :NOT: (Time > 5).
The arithmetic and :AND: levels are wrong too, but that is hidden: the importer writes each equation out as flat text, and the XMILE parser re-reads it with the right grouping.
The :NOT: case cannot be hidden that way, because XMILE also binds not tighter than a comparison (spec section 3.3.1).
Example
not scalar = IF THEN ELSE(:NOT: Time > 5, 0, 1)
Vensim's run (test/test-models/tests/subscripted_logicals/output.tab) differs from ours on not_scalar, not_array and not_and_or; every other series in that model matches.
The hidden half, from the parser code: 1 + 2 > 2 parses as 1 + (2 > 2), and 2 > 1 :AND: 0 as 2 > (1 :AND: 0).
Why it matters
Any model with :NOT: in front of a comparison gets wrong numbers, silently.
The hidden half is a trap: the importer cannot add the parentheses it should (doing so keeps the wrong grouping and breaks C-LEARN against Ref.vdf), and any other code reading the MDL syntax tree sees the wrong grouping.
Fix
Reorder the MDL parser to Vensim's levels, lowest first: :OR:, :AND:, :NOT:, = <>, < > <= >=, + -, * /, unary + -, ^.
:NOT: needs its own level instead of sharing one with unary minus.
Then have xmile_compat parenthesize by precedence (writing not (time > 5)), widen the writer property test to all operators, and check C-LEARN still matches Ref.vdf.
The ground truth shows only that :NOT: binds looser than a comparison; the rest of this order is unverified against Vensim's documentation.
Pointers
src/simlin-engine/src/mdl/parser.rs:parse_add_subthroughparse_powersrc/simlin-engine/src/mdl/xmile_compat.rs: the note on why it does not parenthesize by precedencesrc/simlin-engine/src/mdl/writer_proptest.rs:expr0_strategy, kept to arithmetic because of thissrc/simlin-engine/tests/integration/mdl_vensim_truth.rs: thesubscripted_logicalsentry comes off its list once fixed
Activity
engine: make the equation printer and parser agree
engine: make the equation printer and parser agree
[-]engine: MDL parser's binary operator precedence is inverted vs Vensim, masked by xmile_compat's precedence-free emission[/-][+]mdl: operator precedence differs from Vensim, breaking :NOT: comparisons[/+]