Story REPL.1: single source of truth for SQL keywords (highlighter/completer/parser) — elasticsql - #164
Merged
Merged
Conversation
…er keyword registry
Story REPL.1: Single source of truth for SQL keywords (highlighter <-> completer <-> parser)
- NEW sql SQLKeywords: curated registry over the parser's four keyword
surfaces (TokenRegex objects, keyword("...") literals, type/literal
parser regexes, reservedKeywords read-only tie-in); exposes
allWords/highlightedWords/compoundPhrases with words-normalized-before-
uppercase handling and mechanical filters (no 1-letter words, no geo
distance units)
- NEW sql SQLKeywordsSpec: two-way anti-drift source scans - every
keyword literal and Expr token word must be in the registry AND every
statementWords entry must be literal-backed; scans tolerate scalafmt
wraps and digit-bearing literals; reservedKeywords scraped read-only
- NEW core ReplKeywords: the single set both REPL components consume
(registry words + clearly-labelled REPL-only extras, kept disjoint)
- ReplHighlighter/ReplCompleter now consume ReplKeywords.all; highlight/
complete bodies unchanged; compoundKeywords extended with PARTITION/
FULL/CROSS/NULLS/IS continuations
- NEW core ReplKeywordsSpec: registry superset, extras disjointness,
issue-161 54-word coverage, legacy 28-word regression pin, highlight
styles and completer candidates behaviour tests
- bump version 0.20.1 -> 0.20.2-SNAPSHOT (epic REPL kickoff)
Suites green on 2.12.20 + 2.13.16 (sql 385, core 619); headerCheck ok.
Closed Issue #161
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 30, 2026
fupelaqu
marked this pull request as ready for review
July 30, 2026 15:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Story REPL.1 — Single source of truth for SQL keywords (#161)
Epic REPL (REPL hardening), Layer 0. Closes #161.
What
The REPL highlighter (28 hardcoded words) and completer (82 hardcoded words) had drifted from the parser, which actually has FOUR keyword surfaces (TokenRegex objects,
keyword("…")literals, type/literal parser regexes, privatereservedKeywords).LIMITand 53 other parser keywords were not colourised.sql/SQLKeywords— curated registry referencing the token objects themselves (compile-checked) + curatedstatementWords/typeWords/literalWords/timeUnitPluralWords; exposesallWords,highlightedWords(mechanical filters only: word-shaped, length ≥ 2, no geo distance units) andcompoundPhrases.sql/SQLKeywordsSpec— anti-drift source scans, now TWO-WAY: everykeyword("…")literal andExpr("…")token word must be in the registry, and everystatementWordsentry must be literal-backed (registry cannot rot). Scans tolerate scalafmt wraps and digit-bearing literals;reservedKeywordsscraped read-only (AD-5).core/ReplKeywords— the ONE set both REPL components consume:SQLKeywords.highlightedWords++ clearly-labelled REPL-onlyextraWords(INTERSECT/EXPLAIN/BULK/CONDITION/ACTION/GEO/TRANSFORM — kept per PD-2, disjointness test-guarded).ReplHighlighter/ReplCompleterrewired toReplKeywords.all;highlight/completebodies unchanged byte-for-byte;compoundKeywordsextended (PARTITION/FULL/CROSS/NULLS/IS).core/ReplKeywordsSpec— registry superset, extras disjointness, the issue's 54-word list pinned verbatim, legacy 28-word regression pin, highlight-style and completer-candidate behaviour tests.Adding a keyword from now on
TokenRegexobject per convention and add it toSQLKeywords.clauseTokens/functionTokens(forgetting fails the Expr-scan test).keyword("…")andSQLKeywords.statementWords(two-way scan enforces both directions).extends Value[...] with TokenRegex) → add toSQLKeywords.literalTokensby hand (scan blind spot, documented).ReplKeywords.extraWords(kept disjoint from the registry by test).Candidate follow-up (not in scope)
The highlighter's green string-literal branch is dead at baseline:
split("\\b")fragments'John'so'[^']*'never matches a real quoted string. Behaviour pinned as-is (AC 4 = no regression); making strings green requires a tokenizer change → separate issue.Verification
sbt "+ sql/test" "+ core/test"— sql 385, core 619, green on 2.12.20 AND 2.13.16; all anti-drift scans executed (not cancelled)sbt scalafmtAll,sbt headerCheck— cleanRepl.scalawiring unchanged🤖 Generated with Claude Code
Part of epic #169 (REPL Hardening).