programlibs/Parsing/demos/before-after.xtl

Before and after: why libs/Parsing's group check looks at the whole text, not just its start. Equations once summed (y[i] - p[i])^2 as y[i] - p[i] -- a silent wrong answer, found only by reading the output -- because its group rule decided "(y - p)^2" was just a parenthesized group and never looked at what followed the closing parenthesis. pa:g_roup? checks the closing parenthesis is the text's own LAST character, so the same mistake is caught instead of computed wrong (an actual refusal, not just a wrong Bool, needs a macro to call; libs/Ranges' reject-*.xtl tests show that side of it, and this library's own tests/Probe.xtlm wraps pa:g_roup? for the same reason). Run with "just demo Parsing before-after".

source · imports pa: libs/Parsing/src/Parsing.xtl

term : Char

value · line 15
term ← "(y - p)^2"

ᵘn̲aiveGroup? : Truthy a => Char -> a

function · line 19

The check any reader might start with: starts with "(" and has a ")" somewhere. True here, and wrong -- the text keeps going.

ᵘn̲aiveGroup? ← { t → ("(" m̲atch 1 t̲ake t) ∧ 0 < '+ r̲/ 0 + t m̲ember? ")" }

y : Float

value · line 24
y ← 5.0

p : Float

value · line 25
p ← 3.0