Commit c6b602f
feat(postgresql): implement automated keyword management system
Implemented a keyword generator that fetches PostgreSQL keywords from the
official kwlist.h file and automatically generates ANTLR grammar rules.
Key features:
- Fetches keywords from PostgreSQL REL_18_STABLE kwlist.h
- Generates parser rules (reserved, unreserved, col_name, type_func_name)
- Inserts lexer keyword rules directly into PostgreSQLLexer.g4
- Handles ANTLR reserved name conflicts (e.g., SKIP → SKIP_P)
- Matches PostgreSQL's official gram.y structure
Changes:
- Add keyword-generator/ tool (Go program)
- Add PostgreSQLKeywords.g4 (auto-generated parser rules)
- Update PostgreSQLLexer.g4 with auto-generated keyword section
- Update PostgreSQLParser.g4 to use kwlist.h token names
- Update Makefile with generate-keywords target
- Fix token references in postgresql_lexer_base.go
The generator ensures keywords are placed before the Identifier rule in
the lexer for correct matching precedence. Keywords are managed between
marker comments for easy regeneration.
Test results: 190/214 tests passing (88.8%)
🤖 Generated with Claude Code (https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 635e973 commit c6b602f
File tree
15 files changed
+24541
-24108
lines changed- postgresql
- keyword-generator
15 files changed
+24541
-24108
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
4 | 12 | | |
5 | 13 | | |
6 | | - | |
7 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments