Re: [XQuery] Comment - Pragma/MUExtension confusion

Hi Daniel.  Please bear with me, as I'm not 100% sure I understand your 
issue.

I would think the longest token rule covers your examples.  "When 
tokenizing, the longest possible match that is valid in the current 
lexical state is preferred ."  (A.2 Lexical structure).   So:

 "(: :)"   ...is a valid comment
"(::)"      ...is not valid (ill-formed pragma or extension)
"(: ::)"   ...is a valid comment (with a space and ":" char within it)
"(:: :)"   ...is not valid (ill-formed pragma or extension)
"(::::)"   ...is not valid (ill-formed pragma or extension)
"(:::)"    ...is not valid (ill-formed pragma or extension)

No look-ahead should be required.

Please let me know if I've addressed your issue, or misunderstood it.

-scott

public-qt-comments-request@w3.org wrote on 09/01/2004 04:59:55 AM:

> 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 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 18:25:54 UTC