diff options
-rw-r--r-- | lua.stx | 51 |
1 files changed, 28 insertions, 23 deletions
@@ -1,6 +1,6 @@ | |||
1 | %{ | 1 | %{ |
2 | /* | 2 | /* |
3 | ** $Id: lua.stx,v 1.22 1997/12/09 16:01:08 roberto Exp roberto $ | 3 | ** $Id: lua.stx,v 1.23 1997/12/15 16:17:20 roberto Exp roberto $ |
4 | ** Syntax analizer and code generator | 4 | ** Syntax analizer and code generator |
5 | ** See Copyright Notice in lua.h | 5 | ** See Copyright Notice in lua.h |
6 | */ | 6 | */ |
@@ -664,8 +664,7 @@ TProtoFunc *luaY_parser (ZIO *z, char *chunkname) | |||
664 | counter */ | 664 | counter */ |
665 | %type <vInt> varlist1, funcParams, funcvalue | 665 | %type <vInt> varlist1, funcParams, funcvalue |
666 | %type <vInt> fieldlist, localnamelist, decinit | 666 | %type <vInt> fieldlist, localnamelist, decinit |
667 | %type <vInt> ffieldlist, ffieldlist1, semicolonpart | 667 | %type <vInt> ffieldlist1, lfieldlist1, ffieldlist, lfieldlist, part |
668 | %type <vInt> lfieldlist, lfieldlist1 | ||
669 | %type <vLong> var, funcname /* vardesc */ | 668 | %type <vLong> var, funcname /* vardesc */ |
670 | %type <pFunc> body | 669 | %type <pFunc> body |
671 | 670 | ||
@@ -861,25 +860,35 @@ parlist : /* empty */ { code_args(0, 0); } | |||
861 | | localnamelist ',' DOTS { code_args($1, 1); } | 860 | | localnamelist ',' DOTS { code_args($1, 1); } |
862 | ; | 861 | ; |
863 | 862 | ||
864 | fieldlist : lfieldlist | 863 | fieldlist : part { $$ = abs($1); } |
865 | { flush_list($1/LFIELDS_PER_FLUSH, $1%LFIELDS_PER_FLUSH); } | 864 | | part ';' part |
866 | semicolonpart | 865 | { |
867 | { $$ = $1+$3; } | 866 | if ($1*$3 > 0) /* repeated parts? */ |
868 | | ffieldlist1 lastcomma | 867 | luaY_error("invalid constructor syntax"); |
869 | { $$ = $1; flush_record($1%RFIELDS_PER_FLUSH); } | 868 | $$ = abs($1)+abs($3); |
870 | ; | 869 | } |
870 | ; | ||
871 | 871 | ||
872 | semicolonpart : /* empty */ { $$ = 0; } | 872 | part : /* empty */ { $$ = 0; } |
873 | | ';' ffieldlist { $$ = $2; flush_record($2%RFIELDS_PER_FLUSH); } | 873 | | ffieldlist { $$ = $1; } |
874 | ; | 874 | | lfieldlist { $$ = $1; } |
875 | ; | ||
875 | 876 | ||
876 | lastcomma : /* empty */ | 877 | lastcomma : /* empty */ | ',' ; |
877 | | ',' | ||
878 | ; | ||
879 | 878 | ||
880 | ffieldlist : /* empty */ { $$ = 0; } | 879 | ffieldlist : ffieldlist1 lastcomma |
881 | | ffieldlist1 lastcomma { $$ = $1; } | 880 | { |
882 | ; | 881 | flush_record($1%RFIELDS_PER_FLUSH); |
882 | $$ = -$1; /* negative signals a "record" part */ | ||
883 | } | ||
884 | ; | ||
885 | |||
886 | lfieldlist : lfieldlist1 lastcomma | ||
887 | { | ||
888 | flush_list($1/LFIELDS_PER_FLUSH, $1%LFIELDS_PER_FLUSH); | ||
889 | $$ = $1; | ||
890 | } | ||
891 | ; | ||
883 | 892 | ||
884 | ffieldlist1 : ffield {$$=1;} | 893 | ffieldlist1 : ffield {$$=1;} |
885 | | ffieldlist1 ',' ffield | 894 | | ffieldlist1 ',' ffield |
@@ -897,10 +906,6 @@ ffieldkey : '[' expr1 ']' | |||
897 | | NAME { code_string($1); } | 906 | | NAME { code_string($1); } |
898 | ; | 907 | ; |
899 | 908 | ||
900 | lfieldlist : /* empty */ { $$ = 0; } | ||
901 | | lfieldlist1 lastcomma { $$ = $1; } | ||
902 | ; | ||
903 | |||
904 | lfieldlist1 : expr1 {$$=1;} | 909 | lfieldlist1 : expr1 {$$=1;} |
905 | | lfieldlist1 ',' expr1 | 910 | | lfieldlist1 ',' expr1 |
906 | { | 911 | { |