<?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>17508</bug_id>
          
          <creation_ts>2012-06-16 11:07:21 +0000</creation_ts>
          <short_desc>Let enum lists end with a comma</short_desc>
          <delta_ts>2013-08-05 06:25:27 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebIDL</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#textFieldSelection</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>nbarth+w3bugzilla</cc>
    
    <cc>public-script-coord</cc>
    
    <cc>wolfgangkeller</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>69131</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-06-16 11:07:21 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#textFieldSelection
Complete: http://www.whatwg.org/c#textFieldSelection

Comment:
Invalid IDL of SelectionMode

Posted from: 84.182.211.110
User agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.34 Safari/536.11</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69135</commentid>
    <comment_count>1</comment_count>
    <who name="Wolfgang Keller">wolfgangkeller</who>
    <bug_when>2012-06-16 11:16:23 +0000</bug_when>
    <thetext>If we look at http://www.whatwg.org/specs/web-apps/current-work/#selectionmode we&apos;ll see the following IDL of SelectionMode

enum SelectionMode {
  // ...
  &apos;preserve&apos;,
};

This is not allowed according to WebIDL http://dev.w3.org/2006/webapi/WebIDL/

Let&apos;s look why:

The nonterminal EnumValueList (what is between the { }) is defined (using EnumValues) as

[21]	EnumValueList	→	string EnumValues
[22]	EnumValues	→	&quot;,&quot; string EnumValues 
 | ε

Thus if there is a comma a string has to follow. This string &apos;preserve&apos; (which is also an invalid string according to WebIDL since string terminals have to be enclosed in double quotes - see bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17507 - but this shall not mind here) is followed by a comma - but not by an additional string.

Thus we either have to change the WebIDL rules such that there is no need for a string after a comma or fix this IDL fragment by removing the , after &apos;preserve&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70935</commentid>
    <comment_count>2</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-07-18 17:46:52 +0000</bug_when>
    <thetext>This bug was cloned to create bug 18234 as part of operation convergence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73432</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-09-07 16:24:46 +0000</bug_when>
    <thetext>I think we should just fix Web IDL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79609</commentid>
    <comment_count>4</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-12-07 04:25:33 +0000</bug_when>
    <thetext>Sorry, the trailing comma look pretty ugly to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88178</commentid>
    <comment_count>5</comment_count>
    <who name="Nils Barth">nbarth+w3bugzilla</who>
    <bug_when>2013-05-24 06:50:17 +0000</bug_when>
    <thetext>I&apos;ve opened a more general and detailed bug here:
Bug 22156 - Allow trailing commas in Web IDL lists

To address your concerns Cameron, I think this is primarily about vertical lists and computer-generated lists, and secondarily about individual tastes.

I agree that the horizontal list {&quot;foo&quot;, &quot;bar&quot;,} is pretty ugly,
but OTOH in a vertical list, the form with trailing commas:
{
  &quot;foo&quot;,
  &quot;bar&quot;,
}
...looks clearer than the form without:
{
  &quot;foo&quot;,
  &quot;bar&quot;
}
...and it&apos;s easier to edit when there are trailing commas (since don&apos;t need to add or remove when last element changes or moves).

It&apos;s also of course easier to generate for computer output or pretty-printing, since you don&apos;t need to special-case the last element, and as discussed in Bug 22156, trailing commas allow clearer diffs, and not allowing trailing commas is a comma source of syntax errors. Further many parsers allow trailing commas anyway (notably non-IE ES3 parsers -- a common cause of errors there -- and existing Blink IDL parser, which I&apos;m in the middle of fixing). Also some developers really prefer trailing commas (for varied personal reasons).

So allowing trailing commas sounds like it would avoid a holy war (accommodating either style), avoid errors, and save developer time worrying about this -- it&apos;s a very easy mistake to make, so making the grammar more robust seems advisable.

What do you think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91565</commentid>
    <comment_count>6</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-08-03 05:43:46 +0000</bug_when>
    <thetext>I disagree about it looking clearer, but I relent.

http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.662;r2=1.663;f=h
http://dev.w3.org/cvsweb/2006/webapi/WebIDL/v1.xml.diff?r1=1.102;r2=1.103;f=h</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91577</commentid>
    <comment_count>7</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-08-03 08:17:19 +0000</bug_when>
    <thetext>*** Bug 21589 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91633</commentid>
    <comment_count>8</comment_count>
    <who name="Nils Barth">nbarth+w3bugzilla</who>
    <bug_when>2013-08-05 06:12:08 +0000</bug_when>
    <thetext>Thanks Cameron!

One tweak: the latest spec uses 4 rules:
Enum                → &quot;enum&quot; identifier &quot;{&quot; EnumValueList &quot;}&quot; &quot;;&quot;
EnumValueList       → string EnumValueListComma
EnumValueListComma  → &quot;,&quot; EnumValueListString 
                      | ε
EnumValueListString → string EnumValueListComma 
                      | ε

...though we could instead use these 3 rules, which seem a bit simpler:
Enum          → &quot;enum&quot; identifier &quot;{&quot; EnumValueList &quot;}&quot; &quot;;&quot;
EnumValueList → string EnumValues
EnumValues    → &quot;,&quot; string EnumValues
                | &quot;,&quot;
                | ε

WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91635</commentid>
    <comment_count>9</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-08-05 06:16:52 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; ...though we could instead use these 3 rules, which seem a bit simpler:
&gt; Enum          → &quot;enum&quot; identifier &quot;{&quot; EnumValueList &quot;}&quot; &quot;;&quot;
&gt; EnumValueList → string EnumValues
&gt; EnumValues    → &quot;,&quot; string EnumValues
&gt;                 | &quot;,&quot;
&gt;                 | ε
&gt; 
&gt; WDYT?

That&apos;s not LL(1), since you can&apos;t decide which of the first two productions of EnumValues to take without looking ahead another token.  I&apos;d like to keep the language LL(1) to make it easy to write a parser for.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91637</commentid>
    <comment_count>10</comment_count>
    <who name="Nils Barth">nbarth+w3bugzilla</who>
    <bug_when>2013-08-05 06:25:27 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #8)
&gt; &gt; ...though we could instead use these 3 rules, which seem a bit simpler:
&gt; &gt; Enum          → &quot;enum&quot; identifier &quot;{&quot; EnumValueList &quot;}&quot; &quot;;&quot;
&gt; &gt; EnumValueList → string EnumValues
&gt; &gt; EnumValues    → &quot;,&quot; string EnumValues
&gt; &gt;                 | &quot;,&quot;
&gt; &gt;                 | ε
&gt; &gt; 
&gt; &gt; WDYT?
&gt; 
&gt; That&apos;s not LL(1), since you can&apos;t decide which of the first two productions
&gt; of EnumValues to take without looking ahead another token.  I&apos;d like to keep
&gt; the language LL(1) to make it easy to write a parser for.

Got it, thanks for the explanation!
Right, it&apos;s LL(2); been using LALR parser so didn&apos;t notice.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>