Nannying (was: Array comprehension syntax)

Brendan Eich brendan at mozilla.com
Tue Sep 25 21:49:18 PDT 2012


Allen Wirfs-Brock wrote:
> So, from that perspective, why didn't you make it:
>
> ArrLit:
>        '[' AssExpList ']'
> |       '[' Exp FOR ID OF Exp IF Exp ']'

Because that is ambiguous, with a reduce/reduce conflict on lookahead ',':

state 6

     3 AssExpList: AssExp .
     5 Exp: AssExp .

     FOR       reduce using rule 5 (Exp)
     ','       reduce using rule 3 (AssExpList)
     ','       [reduce using rule 5 (Exp)]
     $default  reduce using rule 3 (AssExpList)


You can spot it by inspection given

AssExpList:
         AssExp
|       AssExpList ',' AssExp
;

and

Exp:
         AssExp
|       Exp ',' AssExp
;

/be



More information about the es-discuss mailing list