[XQuery] Comment - Pragma/MUExtension confusion

Hi,

I found a disturbing thing in the XQuery grammar. Consider these productions:

[146]    Pragma    ::=    "(::" S? "pragma" S QName (S ExtensionContents)? "::)" /* ws: explicit */ 
[147]    MUExtension    ::=    "(::" S? "extension" S QName (S ExtensionContents)? "::)" /* ws: explicit */ 
[148]    ExtensionContents    ::=    (Char* - (Char* '::)' Char*)) 
[149]    Comment    ::=    "(:" (CommentContents | Comment)* ":)" /* ws: explicit */ 
    /* gn: comments */ 
[150]    CommentContents    ::=    (Char+ - (Char* ':)' Char*))

The XQuery Expression "(: :)" is a valid comment, even so the expression (::) because no whitespace is required by production [149]. The example parser on http://www.w3.org/2004/08/applets/xqueryApplet.html <http://www.w3.org/2004/08/applets/xqueryApplet.html>  however returns an "Lexical error at line 1, column 4.  Encountered: ")" (41), after : """. Obviously it thinks to have found the begin of a Pragma or MUExtension.
The expression "(::::)" is as valid a comment as "(:::)". To be honest I claim each Pragma or MUExtension would make up a valid comment as long as ":)" is not part of it. First I thought it would be a case of lookahead 1 vs. lookahead 2. But no. It rather looks like a serious problem that no lookahead possibly could resolve. As long as a ":" is a valid character inside a comment (only the sequence ":)" is forbidden) only a human being could tell a comment from a Pragma or MUExtension. 

Either there is a serious problem in the grammar or I made myself a complete idiot. I'm not sure which would relief me more.
What is the resolution of this?

Cheers,
Daniel

Received on Wednesday, 1 September 2004 09:00:41 UTC