Insert grammar: Form C type-awareness via lookahead (ADR-0024 §Phase D)
Form C (`insert into T (vals)`) shared the `(` opener with Form A, so its paren was an untyped Repeated(Choice(literal, ident)) — values weren't type- or count-checked at parse time (handoff-12 §2.2). New Node::Lookahead variant: a factory that peeks the source. The insert first-paren factory inspects the first token — a value literal routes the contents through the typed column_value_list (Form B dispatch contract: per-non-auto-column typed slots); an identifier or empty paren routes to a Form A column-name list. So Form C now gets the same per-column typed slots, hints, and parse-time type/count checking Form B has. The explicit-Choice-branch split is impossible here (committed-choice semantics commit after `(` matches); lookahead is the only route, and DynamicSubgrammar factories couldn't see the source. Node::Lookahead is not memoized — its output depends on source — but it returns only a small node (a Repeated, or a thin DynamicSubgrammar wrapper that delegates to the memoized column_value_list). `insert into T (` now cleanly shows Form A column candidates instead of mixed Form-A/C suggestions. Form C matrix tests updated for the type-aware behaviour.
This commit is contained in:
+12
-1
@@ -286,9 +286,20 @@ pub enum Node {
|
||||
min: usize,
|
||||
},
|
||||
/// Resolves at walk time using the active `WalkContext`.
|
||||
/// Phase D+ uses this for `column_value_list`.
|
||||
/// Phase D+ uses this for `column_value_list`. The factory
|
||||
/// is pure in `ctx`, so the walker memoizes the resolution
|
||||
/// (one leak per distinct schema shape).
|
||||
#[allow(dead_code)]
|
||||
DynamicSubgrammar(fn(&WalkContext) -> Self),
|
||||
/// Like `DynamicSubgrammar` but the factory also sees the
|
||||
/// source and the current byte position, so it can look
|
||||
/// ahead. Used by the insert first-paren to discriminate
|
||||
/// Form A (`(cols) values (...)`) from Form C (`(vals)`)
|
||||
/// before walking the contents — Form C then routes through
|
||||
/// the typed `column_value_list` (ADR-0024 §Phase D, Form C
|
||||
/// type-awareness). Not memoized: the output depends on the
|
||||
/// source, not just `ctx`.
|
||||
Lookahead(fn(&WalkContext, &str, usize) -> Self),
|
||||
/// Typed value-literal slot (ADR-0024 §Phase D §typed-value-slots).
|
||||
///
|
||||
/// Walks `inner` to consume the literal but records the
|
||||
|
||||
Reference in New Issue
Block a user