diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-04-05 13:49:14 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-04-05 13:49:14 -0300 |
commit | 211214268065ec61180141d336e02393bc15bce4 (patch) | |
tree | 398f704416203198260aa4e9f912a0a1bedefa9b | |
parent | dd3a63c205a97339d8c8aec3cd49941bc10ba45c (diff) | |
download | lua-211214268065ec61180141d336e02393bc15bce4.tar.gz lua-211214268065ec61180141d336e02393bc15bce4.tar.bz2 lua-211214268065ec61180141d336e02393bc15bce4.zip |
allow syntax << function (x) ... end (...) >> as a statement
-rw-r--r-- | lparser.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.139 2001/02/23 17:17:25 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.140 2001/03/26 14:31:49 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -992,7 +992,7 @@ static void funcstat (LexState *ls, int line) { | |||
992 | } | 992 | } |
993 | 993 | ||
994 | 994 | ||
995 | static void namestat (LexState *ls) { | 995 | static void exprstat (LexState *ls) { |
996 | /* stat -> func | assignment */ | 996 | /* stat -> func | assignment */ |
997 | FuncState *fs = ls->fs; | 997 | FuncState *fs = ls->fs; |
998 | expdesc v; | 998 | expdesc v; |
@@ -1059,8 +1059,12 @@ static int statement (LexState *ls) { | |||
1059 | repeatstat(ls, line); | 1059 | repeatstat(ls, line); |
1060 | return 0; | 1060 | return 0; |
1061 | } | 1061 | } |
1062 | case TK_FUNCTION: { /* stat -> funcstat */ | 1062 | case TK_FUNCTION: { |
1063 | funcstat(ls, line); | 1063 | lookahead(ls); |
1064 | if (ls->lookahead.token == '(') | ||
1065 | exprstat(ls); | ||
1066 | else | ||
1067 | funcstat(ls, line); /* stat -> funcstat */ | ||
1064 | return 0; | 1068 | return 0; |
1065 | } | 1069 | } |
1066 | case TK_LOCAL: { /* stat -> localstat */ | 1070 | case TK_LOCAL: { /* stat -> localstat */ |
@@ -1076,7 +1080,7 @@ static int statement (LexState *ls) { | |||
1076 | return 1; /* must be last statement */ | 1080 | return 1; /* must be last statement */ |
1077 | } | 1081 | } |
1078 | default: { | 1082 | default: { |
1079 | namestat(ls); | 1083 | exprstat(ls); |
1080 | return 0; /* to avoid warnings */ | 1084 | return 0; /* to avoid warnings */ |
1081 | } | 1085 | } |
1082 | } | 1086 | } |