|
@ -1,5 +1,5 @@ |
|
|
/*
|
|
|
/*
|
|
|
** $Id: lparser.c,v 1.52 1999/12/29 18:07:10 roberto Exp roberto $ |
|
|
** $Id: lparser.c,v 1.53 2000/01/10 17:34:38 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 |
|
|
*/ |
|
|
*/ |
|
@ -114,7 +114,7 @@ typedef struct FuncState { |
|
|
static void body (LexState *ls, int needself, int line); |
|
|
static void body (LexState *ls, int needself, int line); |
|
|
static void chunk (LexState *ls); |
|
|
static void chunk (LexState *ls); |
|
|
static void constructor (LexState *ls); |
|
|
static void constructor (LexState *ls); |
|
|
static void exp (LexState *ls, vardesc *v); |
|
|
static void expr (LexState *ls, vardesc *v); |
|
|
static void exp1 (LexState *ls); |
|
|
static void exp1 (LexState *ls); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -740,13 +740,13 @@ static int cond (LexState *ls) { |
|
|
|
|
|
|
|
|
static void explist1 (LexState *ls, listdesc *d) { |
|
|
static void explist1 (LexState *ls, listdesc *d) { |
|
|
vardesc v; |
|
|
vardesc v; |
|
|
exp(ls, &v); |
|
|
expr(ls, &v); |
|
|
d->n = 1; |
|
|
d->n = 1; |
|
|
while (ls->token == ',') { |
|
|
while (ls->token == ',') { |
|
|
d->n++; |
|
|
d->n++; |
|
|
lua_pushvar(ls, &v); |
|
|
lua_pushvar(ls, &v); |
|
|
next(ls); |
|
|
next(ls); |
|
|
exp(ls, &v); |
|
|
expr(ls, &v); |
|
|
} |
|
|
} |
|
|
if (v.k == VEXP) |
|
|
if (v.k == VEXP) |
|
|
d->pc = v.info; |
|
|
d->pc = v.info; |
|
@ -935,7 +935,7 @@ static void constructor_part (LexState *ls, constdesc *cd) { |
|
|
|
|
|
|
|
|
case NAME: { |
|
|
case NAME: { |
|
|
vardesc v; |
|
|
vardesc v; |
|
|
exp(ls, &v); |
|
|
expr(ls, &v); |
|
|
if (ls->token == '=') { |
|
|
if (ls->token == '=') { |
|
|
switch (v.k) { |
|
|
switch (v.k) { |
|
|
case VGLOBAL: |
|
|
case VGLOBAL: |
|
@ -1088,9 +1088,9 @@ static void simpleexp (LexState *ls, vardesc *v, stack_op *s) { |
|
|
body(ls, 0, ls->linenumber); |
|
|
body(ls, 0, ls->linenumber); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case '(': /* simpleexp -> '(' exp ')' */ |
|
|
case '(': /* simpleexp -> '(' expr ')' */ |
|
|
next(ls); |
|
|
next(ls); |
|
|
exp(ls, v); |
|
|
expr(ls, v); |
|
|
check(ls, ')'); |
|
|
check(ls, ')'); |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
@ -1140,15 +1140,15 @@ static void arith_exp (LexState *ls, vardesc *v) { |
|
|
|
|
|
|
|
|
static void exp1 (LexState *ls) { |
|
|
static void exp1 (LexState *ls) { |
|
|
vardesc v; |
|
|
vardesc v; |
|
|
exp(ls, &v); |
|
|
expr(ls, &v); |
|
|
lua_pushvar(ls, &v); |
|
|
lua_pushvar(ls, &v); |
|
|
if (is_in(ls->token, expfollow) < 0) |
|
|
if (is_in(ls->token, expfollow) < 0) |
|
|
luaX_error(ls, "malformed expression"); |
|
|
luaX_error(ls, "malformed expression"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void exp (LexState *ls, vardesc *v) { |
|
|
static void expr (LexState *ls, vardesc *v) { |
|
|
/* exp -> arith_exp {(AND | OR) arith_exp} */ |
|
|
/* expr -> arith_exp {(AND | OR) arith_exp} */ |
|
|
arith_exp(ls, v); |
|
|
arith_exp(ls, v); |
|
|
while (ls->token == AND || ls->token == OR) { |
|
|
while (ls->token == AND || ls->token == OR) { |
|
|
OpCode op = (ls->token == AND) ? ONFJMP : ONTJMP; |
|
|
OpCode op = (ls->token == AND) ? ONFJMP : ONTJMP; |
|
|