Skip to content

Conversation

@GuntherRademacher
Copy link
Member

The "longest token rule" in A.3 Lexical structure states:

If the current position is not the end of the input, then return the longest literal terminal or variable terminal that can be matched starting at the current position, regardless whether this terminal is valid at this point in the grammar.

As a consequence, an NCName must not be accepted when it is followed by a colon and a name-start character, because in that case the input should be tokenized as a QName, even if only an NCName is expected by the grammar at that point.

This change marks NCName tokenization calls with a boolean that controls whether a following : plus name-start character is permitted, and rejects the token if it is not.

This fixes QT4 test case MapConstructor-025a.

@GuntherRademacher GuntherRademacher changed the title Reject NCNames when they might be part of lead an unexpected QName Reject NCNames when they might be part of an unexpected QName Jan 14, 2026
@GuntherRademacher
Copy link
Member Author

GuntherRademacher commented Jan 14, 2026

With this fix I have taken the more general route by addressing this on NCName level. A simpler version would just inspect the context following an NCName as a KeySpecifier - I believe that this is the only situation where a following colon plus name start, if not rejected, would be a continuation that might be part of an otherwise valid query. Please let me know if you prefer the simpler variant.

@ChristianGruen
Copy link
Member

Looks good; thanks. One never knows what is going to happen next.

@ChristianGruen ChristianGruen merged commit 8ffc815 into BaseXdb:main Jan 14, 2026
1 check passed
@ChristianGruen ChristianGruen deleted the MapConstructor-025a branch January 14, 2026 16:45
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