This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25312 - allow trailing commas on enums
Summary: allow trailing commas on enums
Status: RESOLVED WORKSFORME
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-10 17:30 UTC by Ian 'Hixie' Hickson
Modified: 2015-01-07 08:45 UTC (History)
5 users (show)

See Also:


Attachments

Description Ian 'Hixie' Hickson 2014-04-10 17:30:07 UTC
http://heycam.github.io/webidl/#proddef-EnumValueListComma

The Enum production should allow trailing commas, for ease of maintenance.
Comment 1 Boris Zbarsky 2014-04-10 17:52:59 UTC
Uh.. this already works.  It was fixed in bug 17508.

Here's an example.  Say you have:

  enum Foo { "foo", }

The tokenizer sees the '{', then expects an EnumValueList.  

  EnumValueList	→	string EnumValueListComma

The tokenizer sees the string "foo", then expects EnumValueListComma.

  EnumValueListComma	→ "," EnumValueListString
                          | ε

The tokenizer sees a ',', then expects EnumValueListString

  EnumValueListString	→ string EnumValueListComma
                          | ε

The tokenizer doesn't see a string, but EnumValueListString is allowed to be empty so we match all that, go back to our Enum production, see the expected '}', and all is good.
Comment 2 Ian 'Hixie' Hickson 2014-05-05 21:13:58 UTC
Hm, dunno how I missed those | ε bits. Nevermind!
Comment 3 Anne 2015-01-07 08:45:10 UTC
*** Bug 27701 has been marked as a duplicate of this bug. ***