Skip to content

spike: 006 grammar-slice viability for SELECT core - #67

Merged
iheitlager merged 2 commits into
mainfrom
spike/006_grammar_slice
Aug 15, 2026
Merged

spike: 006 grammar-slice viability for SELECT core#67
iheitlager merged 2 commits into
mainfrom
spike/006_grammar_slice

Conversation

@iheitlager

Copy link
Copy Markdown
Member

Summary

  • Answers spike 001's leftover question: can the V2 SELECT-core subset (~40 productions) be sliced cleanly out of the grammar, told apart from unsupported/invalid SQL, and grown to V3 by addition only?
  • GO. Built tests/spike/006_grammar_slice/, a real pomelo crate implementing only the (* V2 *)-tagged rules in .openspec/grammar/sqlite.ebnf (no CREATE TABLE/INSERT/UPDATE/DELETE, no GROUP BY/HAVING/joins/subqueries — those productions don't exist in this grammar at all).
  • Fixed a stale decision in .openspec/specs/002-parser/spec.md (said "lemon-rs", spike 001 actually recommended pomelo) discovered along the way.

Changes

Added

  • tests/spike/006_grammar_slice/ — sliced pomelo grammar/tokenizer/AST, Outcome::{Accepted,Unsupported,SyntaxError} classification, fixtures (v2_valid.sql, unsupported.sql, invalid.sql), integration tests, FINDINGS.md writeup.
  • spike-006 Makefile target, following the existing spike-00N convention.

Changed

  • .openspec/specs/002-parser/spec.md — corrected the parser-toolchain decision from lemon-rs to pomelo (matches spike 001's actual recommendation) and cross-referenced spike 006's outcome.

Findings (see tests/spike/006_grammar_slice/FINDINGS.md for full detail)

  • (a) Slice accepts exactly the V2 subset, 3-way outcome parity confirmed against the fixture corpus.
  • (b) Unsupported vs. invalid is distinguishable via a keyword-sniff layer above the parser (src/unsupported.rs), not via grammar-level dead rules — recommended shape for the real parser API boundary.
  • (c) Growth to V3 (INSERT sketched back in) is additive-only: ~20 new lines, 2 lines touched on the existing single-alternative stmt rule, zero restructuring.
  • BETWEEN/IN/LIKE (including NOT-prefixed forms) — the LALR slicing-trap candidates called out in the issue — spliced in without conflict.

Recommendation for #61 (phase-1 parser ticket): proceed with pomelo, sliced per sqlite.ebnf, using this spike's accept/unsupported/syntax-error split as the parser-boundary shape.

Testing

  • cargo test in the spike crate: 4/4 green (22 V2-valid, 11 unsupported, 9 invalid fixture statements)
  • make test (full suite) — unaffected, still green
  • make grammar-drift — unaffected, no drift

Spend

Estimate: 1-2 day timebox (issue carried no formal ## Complexity section). Actual: single AI session, within timebox.

Related Issues

Closes #57


🤖 Generated with Claude Code

iheitlager and others added 2 commits August 15, 2026 12:07
Slices the V2 SELECT-core subset out of pomelo (spike 001's chosen
toolchain) against .openspec/grammar/sqlite.ebnf's V-block tags: no
CREATE TABLE/INSERT/UPDATE/DELETE (V3) or GROUP BY/HAVING/joins/
subqueries (V4) productions exist in the grammar at all. Confirms:

- the slice accepts exactly the V2 subset with 3-way outcome parity
  (accept / unsupported / syntax error), via a keyword-sniff layer
  above the parser rather than dead grammar rules
- BETWEEN/IN/LIKE (incl. NOT-prefixed forms) cause no LALR conflicts
  when spliced into the sliced precedence table
- growing to V3 (INSERT sketched) is additive-only: ~20 new lines,
  2 lines touched on the existing single-alternative stmt rule, no
  restructuring

GO — recommends pomelo, sliced per sqlite.ebnf, for the phase-1
parser ticket (#61). Also fixes 002-parser/spec.md's stale
"Decision: lemon-rs" line, superseded by spike 001's actual pomelo
recommendation.

Refs: 002/Req-2
Spend: within 1-2 day timebox (no formal Complexity section on issue).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@iheitlager
iheitlager force-pushed the spike/006_grammar_slice branch from b9afe7f to 254a243 Compare August 15, 2026 10:07
@iheitlager
iheitlager merged commit ace735b into main Aug 15, 2026
1 check passed
@iheitlager
iheitlager deleted the spike/006_grammar_slice branch August 15, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spike: 006 grammar-slice viability for SELECT core

1 participant