Browse Source

syntax for {...;...} is more flexible now.

Roberto Ierusalimschy 30 years ago
parent
commit
97b2fd1ba1
1 changed files with 21 additions and 10 deletions
  1. 21 10
      lua.stx

+ 21 - 10
lua.stx

@@ -1,6 +1,6 @@
 %{
 
-char *rcs_luastx = "$Id: lua.stx,v 3.17 1995/01/13 22:11:12 roberto Exp celes $";
+char *rcs_luastx = "$Id: lua.stx,v 3.18 1995/04/11 17:56:30 celes Exp roberto $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -398,8 +398,8 @@ void lua_parse (Byte **code)
 %type <vLong> PrepJump
 %type <vInt>  expr, exprlist, exprlist1, varlist1, funcParams, funcvalue
 %type <vInt>  fieldlist, localdeclist, decinit
-%type <vInt>  ffieldlist1
-%type <vInt>  lfieldlist1
+%type <vInt>  ffieldlist, ffieldlist1, semicolonpart
+%type <vInt>  lfieldlist, lfieldlist1
 %type <vLong> var, singlevar
 %type <pByte> body
 
@@ -648,21 +648,28 @@ parlist1 :	NAME
 		}
 	  ;
 		
-fieldlist  : /* empty */ { $$ =  0; }
-	   | lfieldlist1 lastcomma
-  	     { $$ = $1; flush_list($1/FIELDS_PER_FLUSH, $1%FIELDS_PER_FLUSH); }
+fieldlist  : lfieldlist
+  	     { flush_list($1/FIELDS_PER_FLUSH, $1%FIELDS_PER_FLUSH); }
+	     semicolonpart
+	     { $$ = $1+$3; }
 	   | ffieldlist1 lastcomma
 	     { $$ = $1; flush_record($1%FIELDS_PER_FLUSH); }
-	   | lfieldlist1 ';' 
-	     { flush_list($1/FIELDS_PER_FLUSH, $1%FIELDS_PER_FLUSH); }
-	    ffieldlist1 lastcomma
-	     { $$ = $1+$4; flush_record($4%FIELDS_PER_FLUSH); }
 	   ;
 
+semicolonpart : /* empty */
+	        { $$ = 0; }
+	      | ';' ffieldlist
+	        { $$ = $2; flush_record($2%FIELDS_PER_FLUSH); }
+	      ;
+
 lastcomma  : /* empty */ 
 	   | ','
 	   ;
 
+ffieldlist  : /* empty */ { $$ = 0; }
+            | ffieldlist1 lastcomma { $$ = $1; }
+            ;   
+
 ffieldlist1 : ffield			{$$=1;}
 	   | ffieldlist1 ',' ffield	
 		{
@@ -677,6 +684,10 @@ ffield      : NAME '=' expr1
 	      }
            ;
 
+lfieldlist  : /* empty */ { $$ = 0; }
+	    | lfieldlist1 lastcomma { $$ = $1; }
+	    ;
+
 lfieldlist1 : expr1  {$$=1;}
 	    | lfieldlist1 ',' expr1
 		{