grammar: WHERE-expression fragment + Expr AST + build_expr (ADR-0026 step 2)

The stratified WHERE-expression grammar — or / and / not /
bool_primary / predicate tiers as named `static` Node
fragments, recursing through `Subgrammar`. Covers the six
comparison operators (`<>` and `!=` both NotEq), AND / OR /
NOT, parentheses, LIKE / IN / BETWEEN with optional infix NOT,
and IS [NOT] NULL. `predicate_tail` factors the shared operand
prefix and the infix NOT so the Choice branches discriminate
on a cleanly-failing first token.

New recursive Expr / Predicate / Operand / CompareOp AST in
dsl::command. `build_expr` folds the flat matched-terminal
slice into an Expr — a deterministic recursive descent
mirroring the grammar tiers, with single-child tiers
collapsing. Per ADR-0026 §3 option 1: the walker stays a pure
structural matcher; Expr is assembled only in this
submit-time fold.

Fragment + builder are unit-tested standalone (walk against
&OR_EXPR, then build_expr); not yet wired into any command.
This commit is contained in:
claude@clouddev1
2026-05-18 22:40:52 +00:00
parent f0b2043a39
commit 59e6a541bf
3 changed files with 816 additions and 1 deletions
+1 -1
View File
@@ -25,6 +25,7 @@
pub mod app;
pub mod data;
pub mod ddl;
pub mod expr;
pub mod shared;
use crate::dsl::command::Command;
@@ -312,7 +313,6 @@ pub enum Node {
/// builds a fresh node from the `WalkContext` at walk time;
/// this one references a fixed fragment already in the
/// grammar tree.
#[allow(dead_code)]
Subgrammar(&'static Self),
/// Resolves at walk time using the active `WalkContext`.
/// Phase D+ uses this for `column_value_list`. The factory