Commit a716541
committed
docs+lint: clarify backtrack semantics — runtime is always-on for Choice
Three docs + the lint message itself were describing the `backtrack`
attribute as a runtime control. The actual behaviour (live in
src/frame.cpp:22) has been: every Choice frame is always backtracked
at runtime, regardless of the `Node.backtrack` flag. The flag exists
only for lint introspection.
External agent surfaced the discrepancy when authoring a constraint
grammar: setting `backtrack: true` made the lint go quiet, but the
parse behaved identically without it. Investigation showed the frame.cpp
comment is the source of truth — the flag is a lint annotation now,
not a parse-direction control. Docs and lint message had to be brought
in line.
**Fixed:**
* `docs/rawast-format.md` §4.7 — was "rawast does not backtrack at the
structural level". Now: alternatives are tried in source order with
mark/reject wrapping (always-on); `backtrack: true` is a grammar-
author annotation the linter uses to suppress LL(k) warnings, not a
runtime control.
* `docs/ARCHITECTURE.md` — the LL(1) lint section was claiming alts
"become unreachable" without `backtrack: true`. They don't — the
engine handles them correctly. Rewritten as: lint flags shared-prefix
Choices as a heads-up so authors mark intentional fall-through with
the flag; without the marker future readers can't tell whether the
pattern is intentional or accidental.
* `docs/AGENTS.md` — the "Silencing the lint on intentional shared-
prefix Choices" section had the same misframing. Reframed as
"lint annotation, NOT runtime control" + the explicit note that you
can skip the workaround entirely if you don't mind a few lint
warnings (parse output is identical either way).
* `src/linter.cpp` — lint message itself updated. Was: "Without
`backtrack: true` the predictive engine will commit to the first one
and the others become unreachable" (incorrect — alts do get tried).
Now: "The engine handles this correctly via alt-failure recovery...
The lint flags it as a heads-up because the analysis can't prove
disjointness statically. Set `backtrack: true` to mark this fall-
through pattern as intentional (silences this warning; runtime
behaviour is unchanged)."
**Issue #4** (DSL syntax for `backtrack`) remains valuable but reframed:
it's now "DSL needs a way to mark intentional fall-through patterns
inline rather than via Python loader hook", not "DSL needs a way to
control runtime backtracking".
Verification: 216/216 C++ doctest + 47/47 Python pytest passing. No
behaviour changes — only doc + lint message corrections.1 parent 18968f6 commit a716541
4 files changed
Lines changed: 35 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| |||
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
216 | | - | |
| 218 | + | |
217 | 219 | | |
218 | | - | |
| 220 | + | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
753 | 763 | | |
754 | 764 | | |
755 | 765 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
490 | 494 | | |
491 | 495 | | |
492 | 496 | | |
| |||
0 commit comments