commit 211214268065ec61180141d336e02393bc15bce4
parent dd3a63c205a97339d8c8aec3cd49941bc10ba45c
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 5 Apr 2001 13:48:52 -0300
allow syntax << function (x) ... end (...) >> as a statement
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 1.139 2001/02/23 17:17:25 roberto Exp roberto $
+** $Id: lparser.c,v 1.140 2001/03/26 14:31:49 roberto Exp roberto $
** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -992,7 +992,7 @@ static void funcstat (LexState *ls, int line) {
}
-static void namestat (LexState *ls) {
+static void exprstat (LexState *ls) {
/* stat -> func | assignment */
FuncState *fs = ls->fs;
expdesc v;
@@ -1059,8 +1059,12 @@ static int statement (LexState *ls) {
repeatstat(ls, line);
return 0;
}
- case TK_FUNCTION: { /* stat -> funcstat */
- funcstat(ls, line);
+ case TK_FUNCTION: {
+ lookahead(ls);
+ if (ls->lookahead.token == '(')
+ exprstat(ls);
+ else
+ funcstat(ls, line); /* stat -> funcstat */
return 0;
}
case TK_LOCAL: { /* stat -> localstat */
@@ -1076,7 +1080,7 @@ static int statement (LexState *ls) {
return 1; /* must be last statement */
}
default: {
- namestat(ls);
+ exprstat(ls);
return 0; /* to avoid warnings */
}
}