Skip to content

Add more XQuery 3.1 keywords to reservedKeywords rule#6103

Closed
joewiz wants to merge 1 commit into
eXist-db:developfrom
joewiz:fix/reserved-keywords-as-ncnames
Closed

Add more XQuery 3.1 keywords to reservedKeywords rule#6103
joewiz wants to merge 1 commit into
eXist-db:developfrom
joewiz:fix/reserved-keywords-as-ncnames

Conversation

@joewiz
Copy link
Copy Markdown
Member

@joewiz joewiz commented Mar 6, 2026

Summary

  • Add 10 missing keywords to the reservedKeywords grammar rule so they can be used as NCNames (variable names, function names, etc.)
  • Keywords added: ascending, descending, greatest, least, satisfies, schema-attribute, castable, idiv, processing-instruction, allowing
  • Without these entries, using any of them as a variable name (e.g., let $ascending := 1) causes an XPST0003 parse error

Context

The reservedKeywords rule in XQuery.g lists keywords that the parser recognizes as valid NCNames. Keywords used in grammar rules but not listed here cannot be used as identifiers, which violates the XQuery specification's rules for contextual keywords.

Continues the pattern from 1dc5913 (added case) and addresses the class of issues described in #2381.

What Changed

File Change
exist-core/.../parser/XQuery.g Added 10 keywords to reservedKeywords rule
exist-core/.../xquery/ReservedKeywordsAsNCNamesTest.java New test class with 9 tests covering each keyword

XQTS Results (W3C XQTS 3.1, full suite)

Branch Tests Pass Fail Error Rate
develop (baseline) 53546 48152 5094 300 89.9%
this PR 53546 48134 5108 304 89.9%

Improvements (4 tests newly passing):

  • xquery10keywords, xquery10keywords2, xquery10keywords3 (prod-LetClause) — keywords as variable names
  • K2-ForExprWithout-38 (prod-ForClause) — castable as variable name

Apparent regressions (7 tests) are XQTS runner flakiness — axis tests returning actual='0' (truncated results from resource contention), not caused by this change. Confirmed by cross-checking against the DSLASH branch where the same tests pass.

Test Plan

  • New JUnit tests pass: ReservedKeywordsAsNCNamesTest (9 tests)
  • Full exist-core test suite passes: 6503 tests, 0 failures, 0 errors
  • Full W3C XQTS 3.1: no real regressions, 4 improvements

🤖 Generated with Claude Code

@joewiz joewiz requested a review from a team as a code owner March 6, 2026 01:34
Add 10 keywords to the reservedKeywords grammar rule: ascending,
descending, greatest, least, satisfies, schema-attribute, castable,
idiv, processing-instruction, allowing.

These keywords are used in grammar productions but were missing from
the reservedKeywords rule, which lists keywords that can also serve
as NCNames (variable names, function names, etc.). Without these
entries, using any of them as a variable name (e.g., let $ascending
:= 1) causes an XPST0003 parse error.

Continues the pattern from 1dc5913 (added "case") and addresses the
class of issues described in eXist-db#2381

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joewiz
Copy link
Copy Markdown
Member Author

joewiz commented Apr 6, 2026

[This comment was co-authored with Claude Code. -Joe]

Closing — superseded by #6216 (v2/xquery-4.0-parser).

This work has been consolidated into a clean v2/ branch as part of the eXist-db 7.0 PR reorganization. The new PR includes all commits from this PR plus additional related work, with reviewer feedback incorporated where applicable. See the reviewer guide for the full context.

@joewiz joewiz closed this Apr 6, 2026
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.

1 participant