Skip to content

fix(grammars): correct emacs regex and align keywords with lexer#5795

Merged
max-sixty merged 1 commit intomainfrom
fix/grammar-keywords-regex
Apr 13, 2026
Merged

fix(grammars): correct emacs regex and align keywords with lexer#5795
max-sixty merged 1 commit intomainfrom
fix/grammar-keywords-regex

Conversation

@prql-bot
Copy link
Copy Markdown
Collaborator

Summary

The nightly survey (2026-04-13) found three issues in the editor grammar files for emacs and nano:

  • Malformed regex in grammars/emacs/prql-mode.el:43[0-9]+* is a nested quantifier; emacs treats the * literally, so it matches "one or more digits followed by an asterisk" rather than "one or more digits". Fixed to [0-9]+.

  • Stale keyword list in both grammars. The lexer keywords are now let, into, case, prql, type, module, internal, func, import, enum (see prqlc/prqlc-parser/src/lexer/mod.rs:197-206). The emacs file was missing into, internal, func, import, enum and listed alias, in, loop which the lexer does not treat as keywords. The nano file was missing into, case, type, internal, func, import, enum.

  • Incorrect regex grouping in grammars/nano/prql.nanorc:11\<let|module|prql\> was parsed as \<let OR module OR prql\> because alternation has lower precedence than the anchors. Now properly grouped: \<(let|...)\>.

Test plan

  • Verified keyword list against the lexer source
  • Manual verification in editors not feasible from CI; both grammars are intended as a starting point for editor users and have no automated tests in this repo

🤖 Generated with Claude Code

The emacs grammar had a malformed regex `[0-9]+*` (nested quantifier
that emacs parses with the trailing `*` as literal asterisk), and both
the emacs and nano grammars had stale keyword lists referencing items
the lexer no longer treats as keywords (`alias`, `in`, `loop`) while
missing several it does (`into`, `internal`, `func`, `import`, `enum`).
The nano regex was also incorrectly grouped — `\<let|module|prql\>`
parses as `\<let` OR `module` OR `prql\>` rather than anchoring all
three.

Authoritative keyword list verified against
prqlc/prqlc-parser/src/lexer/mod.rs:197-206.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@max-sixty max-sixty merged commit 1769557 into main Apr 13, 2026
32 checks passed
@max-sixty max-sixty deleted the fix/grammar-keywords-regex branch April 13, 2026 07:24
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.

2 participants