Beagle SCM
MARK-009 LOW: mark_refdef is a hand-rolled byte scanner — ragel-ize the refdef grammar
mark_refdef (MARK.c:76-101) parses the refdef line grammar with a manual scan loop (while (!u8csEmpty(s) && u8csAt(s,0) != ']') u8csUsed(s,1); …) — slice-typed but still hand parsing, against the module's own doctrine (mark/README.mkd:15 "never a hand-rolled byte scan"; abc "never do manual parsing, use ragel"). It also runs TWICE per line (collector pass 1, again per-line in mark_blocks MARK.c:646). From the 2026-07-07 mark/ diagnostic review; code confirmed in-tree. Method Issues.
Input
Context
- The MARKE ragel lexer already classifies lines — the refdef fields (label, url, title) belong in the same machine or a sibling one.
- Double scanning is a smell of the same missing single classification point.
Goals
- Refdef grammar lives in ragel (MARKE or a dedicated machine);
mark_refdef's manual loops go; one scan per line.
Constraints
- Pure refactor — byte-identical HTML on the whole wiki render (old vs new binary diff empty); regen MARKE.rl.c from the .rl source.
WIP
Design decisions
TODOs
Blockers and bummers
Outcome