<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>13298</bug_id>
          
          <creation_ts>2011-07-19 12:55:43 +0000</creation_ts>
          <short_desc>Clean the grammar of unnecessary trivial productions</short_desc>
          <delta_ts>2011-09-06 15:11:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQuery 3.0</component>
          <version>Working drafts</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gabriel Petrovay">gabipetrovay</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>mike</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>51262</commentid>
    <comment_count>0</comment_count>
    <who name="Gabriel Petrovay">gabipetrovay</who>
    <bug_when>2011-07-19 12:55:43 +0000</bug_when>
    <thetext>Hi,

The XQuery 3.0 grammar is full of unnecessary productions. One such example (out of many) is:
[150] CompElemConstructor ::= &quot;element&quot; (EQName | (&quot;{&quot; Expr &quot;}&quot;)) &quot;{&quot; ContentExpr? &quot;}&quot;
[151] ContentExpr ::= Expr

The ContentExpr translates to Expr and is not referred in the grammar anywhere else. The Computed Element Desription only mentions about &quot;The content expression&quot;. Just for this, it makes no sense to have an additional productions.

Having additional unnecessary productions make:
- the grammar too verbose and harder to read
- the implementers not respect the standard because of performace issues when implementing parsers
- more work to maintain from both W3C and implementers

This should be like in the already existing case of:
[152] CompAttrConstructor ::= &quot;attribute&quot; (EQName | (&quot;{&quot; Expr &quot;}&quot;)) &quot;{&quot; Expr? &quot;}&quot;
where a ContentExpr is not necessary


The only exceptions from this should be the following two because of their importance and extensive usage:
[38]   	QueryBody         ::=   	Expr
[125]   VarName	          ::=   	EQName
[168]   AtomicOrUnionType ::=   	EQName
[184]   AttributeName	   ::=   	EQName
[185]   ElementName	   ::=   	EQName
[186]   TypeName	   ::=   	EQName
[191]   URILiteral	   ::=   	StringLiteral


The same request to remove the trivial production applies to the following:
 [29]   	VarValue	   ::=   	ExprSingle
 [30]   	VarDefaultValue	   ::=   	ExprSingle
-&gt; [28] description can easily make the destinction

 [35]   	FunctionBody	   ::=   	EnclosedExpr

 [56]   	CurrentItem	   ::=   	EQName
 [57]   	PreviousItem	   ::=   	EQName
 [58]   	NextItem	   ::=   	EQName
-&gt; [55] is explicit enough to only have EQName references

 [79]   	TryTargetExpr	   ::=   	Expr

[151]   	ContentExpr	   ::=   	Expr
-&gt; make [150] it uniform with [152]

[154]   	Prefix	   ::=   	NCName
[155]   	PrefixExpr	   ::=   	Expr
[156]   	URIExpr	   ::=   	Expr

[179]   	AttributeDeclaration	   ::=   	AttributeName
-&gt; totally redundant


All this makes the grammar have at least 12 less productions which is not bad.


PS: Or at least make the grammar uniform. Either:
1. Remove all unnecessary productions or
2. Add all missing unnecessary productions</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51263</commentid>
    <comment_count>1</comment_count>
    <who name="Gabriel Petrovay">gabipetrovay</who>
    <bug_when>2011-07-19 12:59:37 +0000</bug_when>
    <thetext>correction:

...
The only exceptions from this should be the following *seven* because of their
importance and extensive usage:
...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51266</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-07-19 13:21:10 +0000</bug_when>
    <thetext>Some of these production rules were introduced to create a &quot;handle&quot; allowing the description of the semantics to refer to constructs in the grammar. Certainly I remember VarValue and VarDefaultValue being introduced expressly for this purpose. Similarly, AtomicOrUnionType is referenced in the description of error XPST0051. There might be some productions that are not referenced in the prose, but they would need to be checked on a case-by-case basis. We would also need to check that the production names are not referenced from another specification in the family, such as the XSLT specification.

At best these additional production names add clarity and readability. At worst, they are harmless.

I have always argued that the grammar should be designed primarily for the benefit of users of the language rather than implementors. There are some who disagree with me on this, but your arguments in my view take too much of an implementor viewpoint. Removing a few redundant productions is very easy compared with the other demands we place on implementors of this grammar. 

(personal response)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51267</commentid>
    <comment_count>3</comment_count>
    <who name="Gabriel Petrovay">gabipetrovay</who>
    <bug_when>2011-07-19 13:49:11 +0000</bug_when>
    <thetext>In my opinion any of the two solutions in the end of my initial comment is good:
1. Remove all unnecessary productions or
2. Add the missing ones

For 1 (which I favour), unnecessary does not mean *all*. Taking a few examples:
[55] is explicit enough on it&apos;s own and does not need more productions.
[150] should be as [152] (or the other way round if solution 2 is the decision)

But, yes they have to be checked each individually to see if:
- they make sense
- they are used in other specs</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51276</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2011-07-19 17:02:03 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; In my opinion any of the two solutions in the end of my initial comment is
&gt; good:
&gt; 1. Remove all unnecessary productions or
&gt; 2. Add the missing ones

I believe this is largely a matter of editorial taste. Accordingly, I am marking this as editorial.

When the text is difficult to write without a clearly named production, it makes sense to add such a production for the sake of the description of that particular expression. If an expression can be clearly described without adding such a production, there is no need to add one.

Jonathan</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56382</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2011-09-06 15:10:55 +0000</bug_when>
    <thetext>I am closing this, per comment #4.

Jonathan</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>