allow syntax << function (x) ... end (...) >> as a statement

This commit is contained in:
Roberto Ierusalimschy
2001-04-05 13:49:14 -03:00
parent dd3a63c205
commit 2112142680

View File

@@ -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 ** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h ** 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 */ /* stat -> func | assignment */
FuncState *fs = ls->fs; FuncState *fs = ls->fs;
expdesc v; expdesc v;
@@ -1059,8 +1059,12 @@ static int statement (LexState *ls) {
repeatstat(ls, line); repeatstat(ls, line);
return 0; return 0;
} }
case TK_FUNCTION: { /* stat -> funcstat */ case TK_FUNCTION: {
funcstat(ls, line); lookahead(ls);
if (ls->lookahead.token == '(')
exprstat(ls);
else
funcstat(ls, line); /* stat -> funcstat */
return 0; return 0;
} }
case TK_LOCAL: { /* stat -> localstat */ case TK_LOCAL: { /* stat -> localstat */
@@ -1076,7 +1080,7 @@ static int statement (LexState *ls) {
return 1; /* must be last statement */ return 1; /* must be last statement */
} }
default: { default: {
namestat(ls); exprstat(ls);
return 0; /* to avoid warnings */ return 0; /* to avoid warnings */
} }
} }