Align omni's MSSQL parser keyword system with SqlScriptDOM TSql170. All 6 enforcement tests PASS:
TestKeywordCompleteness: PASS — 0 unregistered keywordsTestNoStringKeywordMatch: PASS — 0 string-based keyword matchesTestKeywordClassification: PASS — 180 Core + 372 Context = 552 keywords classifiedTestCoreKeywordNotIdentifier: PASS — Core keywords rejected as unquoted identifiersTestContextKeywordAsIdentifier: PASS — Context keywords accepted as identifiers + bare aliasesTestKeywordCasePreservation: PASS — Keyword tokens preserve original case
Known remaining mismatch (strictness, not keyword classification):
SELECT 1 into FROM dbo.t— SQL Server rejects, omni accepts (INTOas bare alias)
- Enforcement tests:
mssql/parser/keyword_classification_test.go - Build check:
go build ./mssql/... - Full regression:
go test ./mssql/... -count=1 - SqlScriptDOM reference:
../SqlScriptDOM/SqlScriptDom/Parser/TSql/
- keyword tokens preserve original case in Str field (currently lowercased)
-
SELECT MyPartition FROM t→ AST stores "MyPartition" not "mypartition" -
CREATE TABLE MyWindow (a INT)→ table name preserves case - non-keyword identifiers still preserve case (no regression)
- reverseKeywordMap still works for completion (maps token type → uppercase string)
Verification: go test ./mssql/parser/ -run TestKeywordCasePreservation -count=1
-
KeywordCategorytype defined (Core, Context) -
Keywordstruct with Name, Token, Category fields - classification table mapping each keyword to its category
- 180 Core keywords match SqlScriptDOM golden list exactly
- 372 Context keywords added to keywordMap and classified (was 279 in original estimate)
- all existing keywordMap entries classified (no unclassified)
-
lookupKeywordCategory(token int) KeywordCategoryhelper available -
isContextKeyword(token int) boolhelper available - completion: reverseKeywordMap includes all new context keywords
- completion:
Collect()on empty input returns context keywords as candidates
Verification: go test ./mssql/parser/ -run TestKeywordClassification -count=1 + go test ./mssql/parser/ -run TestKeywordCompleteness -count=1
-
isIdentLike()rejects Core keywords, accepts Context keywords and tokIDENT -
parseIdentifier()rejects Core keywords, accepts Context keywords and tokIDENT - bracket-quoted Core keywords accepted:
[select]parses as identifier -
isAnyKeywordIdent()accepts ALL keywords (for alias positions) - Core keyword as table name fails:
CREATE TABLE select (a INT)→ error - Context keyword as table name works:
CREATE TABLE window (a INT)→ success
Verification: go test ./mssql/parser/ -run TestCoreKeywordNotIdentifier -count=1
These .Type == tokIDENT checks were widened to also accept Context keyword tokens via isIdentLike() and isContextKeyword().
- parser.go: statement dispatch lookahead uses isIdentLike/isContextKeyword
- create_table.go: PERSISTED, SPARSE, HIDDEN, MASKED, ENCRYPTED, GENERATED, ALWAYS, NODE, EDGE, PERIOD, SYSTEM_TIME, FILESTREAM_ON, TEXTIMAGE_ON
- select.go: bare alias detection, FETCH NEXT/FIRST/ONLY/ROW/TIES, OVER clause
- merge.go: USING, MATCHED, TARGET, SOURCE
- execute.go: OUT parameter, exec string parsing
- alter_table.go: PERIOD, SYSTEM_TIME
- backup_restore.go: option parsing
- create_proc.go: OUT parameter
- name.go: base identifier checks
- update_delete.go: output clause context
- control_flow.go: TIME in WAITFOR
- create_database.go: database options
- create_sequence.go: sequence options
- create_trigger.go: trigger timing
- drop.go: CASCADE
- expr.go: expression parsing
- fulltext.go: fulltext options
- type.go: type name parsing
Verification: go test ./mssql/parser/ -run TestContextKeywordAsIdentifier -count=1 + go test ./mssql/... -count=1
All strings.EqualFold and matchesKeywordCI calls have been replaced with token type checks. matchesKeywordCI was never implemented / already removed. Only 1 legitimate strings.EqualFold remains (AST field check in create_table.go:554 for col.DataType.Name).
- all CREATE statement recognition uses keyword tokens
- all ALTER/DROP statement recognition uses keyword tokens
- parser.go contributes 0 violations
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types (1 legitimate EqualFold on AST field retained)
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types
- all keyword matching uses token types across all files
-
matchesKeywordCIdoes not exist in the codebase (never implemented or already removed)
All 6 enforcement tests pass. Full regression green (excluding pre-existing TestKeywordOracleCoreAsIdentifier/alias_into_bare strictness mismatch).