#1871 Strange list literal allowed in grammar

Jens Tue 10 Apr 2012

<list>           :=  [<type>] "[" <listItems> [","] "]"
<listItems>      :=  "," | (<expr> ("," <expr>)*)

The <list> rule seems to allow the list literal [ , , ]

But that gives a compile error:

Expected ']', not ','

KevinKelley Tue 10 Apr 2012

I think that's a grammar glitch; this might be more accurate:

<list>           :=  [<type>] "[" <listItems> "]"
<listItems>      :=  "," | (<expr> ("," <expr>)*) [","]

<listItems> can be either:

  • single comma, signifying a literal empty list;
  • comma-separated list of items, with optional (ignored) trailing comma.

Doubled-comma definitely not allowed, surely.

brian Sat 14 Apr 2012

Kevin is right - that is just a grammar doc problem (the parser is right). I pushed a fix to the docs

Login or Signup to reply.