shithub: mc

Download patch

ref: 622d529211cbe9223fcbae00db289c0c2e92ab40
parent: 9f10f9d30d224a28da8fffb93ab53d338ecb6838
author: Ori Bernstein <[email protected]>
date: Fri Dec 27 09:14:34 EST 2013

Support a terminating ',' at the end of arrays.

    This makes it easier to generate tables from code, since you
    don't have to track the last element of the array. Just put in
    a comma.

--- a/parse/gram.y
+++ b/parse/gram.y
@@ -650,13 +650,15 @@
         ;
 
 arrayelts
-        : arrayelt
+        : endlns arrayelt
             {$$.nl = NULL; $$.nn = 0;
-             lappend(&$$.nl, &$$.nn, mkidxinit($1->line, mkint($1->line, 0), $1));}
-        | arrayelts Tcomma arrayelt
-             {lappend(&$$.nl, &$$.nn, mkidxinit($3->line, mkint($3->line, $$.nn), $3));}
+             lappend(&$$.nl, &$$.nn, mkidxinit($2->line, mkint($2->line, 0), $2));}
+        | arrayelts Tcomma endlns arrayelt
+             {lappend(&$$.nl, &$$.nn, mkidxinit($4->line, mkint($4->line, $$.nn), $4));}
+        | arrayelts Tcomma endlns
+        ;
 
-arrayelt: endlns expr endlns {$$ = $2;}
+arrayelt: expr endlns {$$ = $1;}
         ;
 
 structelts