WHERE expressions: matrix cells + predicate_tail grammar fix (ADR-0026 step 6)
Adds tests/typing_surface/where_expression.rs — 9 matrix cells for the complex WHERE / show-data limit typing surface: operator candidates after an operand, AND / OR after a predicate, NOT, BETWEEN / IN bounds, and `show data` where / limit. Writing the cells surfaced a grammar bug. `predicate_tail`'s `[NOT] negatable` branch started with `Optional(not)`, and an Optional-first `Seq` always "commits" — so on an incomplete input the walker's `Choice` returned that branch's `Incomplete` early and discarded every sibling branch's expected set, dropping `is` and the comparison operators from completion after a column. Fixed by splitting it into explicit `NOT negatable` and bare `negatable` branches — no `predicate_tail` branch starts with an `Optional` now. The matched terminal sequence is unchanged, so `build_expr` is untouched. Docs: ADR-0026 gains an "As-built notes" section recording the option-1 builder realization, its two deviations from the §3 sketch, and the deferral of §7 diagnostic flagging to ADR-0027. requirements.md C5a -> [x] (steps 1-4) with the test baseline refreshed to 1079; CLAUDE.md's deferred list reconciled (C5a implemented; the QA1/QA2 note now points at ADR-0028).
This commit is contained in:
+24
-18
@@ -201,37 +201,43 @@ static IN_FORM_NODES: &[Node] = &[
|
||||
Node::Punct(')'),
|
||||
];
|
||||
|
||||
/// The negatable predicates — each starts with a distinct
|
||||
/// keyword, so this `Choice` discriminates cleanly.
|
||||
/// The negatable predicate bodies — each starts with a
|
||||
/// distinct keyword, so this `Choice` discriminates cleanly.
|
||||
static NEGATABLE_CHOICES: &[Node] = &[
|
||||
Node::Seq(LIKE_FORM_NODES),
|
||||
Node::Seq(BETWEEN_FORM_NODES),
|
||||
Node::Seq(IN_FORM_NODES),
|
||||
];
|
||||
|
||||
/// `[NOT] (LIKE … | BETWEEN … | IN …)`.
|
||||
static NEGATABLE_NODES: &[Node] = &[
|
||||
Node::Optional(&Node::Word(Word::keyword("not"))),
|
||||
/// `NOT (LIKE … | BETWEEN … | IN …)` — the infix `NOT` is
|
||||
/// factored in front of the negatable choice (rather than
|
||||
/// repeated inside each, which would strand `not between` on
|
||||
/// the `LIKE` branch).
|
||||
static NOT_NEGATABLE_NODES: &[Node] = &[
|
||||
Node::Word(Word::keyword("not")),
|
||||
Node::Choice(NEGATABLE_CHOICES),
|
||||
];
|
||||
|
||||
/// `predicate_tail := cmp_op operand | IS [NOT] NULL | [NOT]
|
||||
/// negatable`.
|
||||
/// `predicate_tail := cmp_op operand | IS [NOT] NULL
|
||||
/// | NOT negatable | negatable`.
|
||||
///
|
||||
/// Branch discrimination: a `Choice` branch falls through to
|
||||
/// the next branch only when its *first* child reports a clean
|
||||
/// `NoMatch`. Branch 1's first child is `Choice(CMP_OP_CHOICES)`
|
||||
/// (all punctuation — clean `NoMatch` on a non-operator);
|
||||
/// branch 2's is `Word("is")`. Branch 3 starts with
|
||||
/// `Optional(not)`, which always "matches" — so it must be
|
||||
/// **last**, and the infix `NOT` is factored out in front of
|
||||
/// the `LIKE` / `BETWEEN` / `IN` choice rather than repeated
|
||||
/// inside each (which would strand `not between` on the `LIKE`
|
||||
/// branch).
|
||||
/// Branch discrimination relies on each branch's *first* child
|
||||
/// reporting a clean `NoMatch` on a non-match: branch 1 is a
|
||||
/// `Choice` of punctuation operators, the rest start with a
|
||||
/// `Word`. Crucially **no branch starts with an `Optional`** —
|
||||
/// an `Optional`-first `Seq` always "commits", which turns its
|
||||
/// failure into an `Incomplete` that the walker's `Choice`
|
||||
/// returns early, discarding every sibling branch's expected
|
||||
/// set (and so its completion candidates). The infix `NOT` is
|
||||
/// therefore its own explicit `NOT negatable` branch, with a
|
||||
/// bare `negatable` branch alongside.
|
||||
static PREDICATE_TAIL_CHOICES: &[Node] = &[
|
||||
Node::Seq(COMPARE_FORM_NODES),
|
||||
Node::Seq(IS_NULL_NODES),
|
||||
Node::Seq(NEGATABLE_NODES),
|
||||
Node::Seq(NOT_NEGATABLE_NODES),
|
||||
Node::Seq(LIKE_FORM_NODES),
|
||||
Node::Seq(BETWEEN_FORM_NODES),
|
||||
Node::Seq(IN_FORM_NODES),
|
||||
];
|
||||
|
||||
// =================================================================
|
||||
|
||||
Reference in New Issue
Block a user