aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-06 10:16:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-06 10:16:02 -0300
commit168ea16acb62231d56147b38edeb8c2aca4ed2f8 (patch)
tree8a0fe3bc2d65643620a29502efb8456a1243c664 /lparser.c
parentdc6e6c48bb7eeac20f79acd9fe4aa4fbb4496303 (diff)
downloadlua-168ea16acb62231d56147b38edeb8c2aca4ed2f8.tar.gz
lua-168ea16acb62231d56147b38edeb8c2aca4ed2f8.tar.bz2
lua-168ea16acb62231d56147b38edeb8c2aca4ed2f8.zip
details
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lparser.c b/lparser.c
index 805db329..9d0bc4d9 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.184 2002/05/16 18:39:46 roberto Exp roberto $ 2** $Id: lparser.c,v 1.185 2002/06/03 14:09:57 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -83,7 +83,7 @@ static void check (LexState *ls, int c) {
83#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } 83#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
84 84
85 85
86static int optional (LexState *ls, int c) { 86static int testnext (LexState *ls, int c) {
87 if (ls->t.token == c) { 87 if (ls->t.token == c) {
88 next(ls); 88 next(ls);
89 return 1; 89 return 1;
@@ -539,7 +539,7 @@ static void constructor (LexState *ls, expdesc *t) {
539 check(ls, '{'); 539 check(ls, '{');
540 for (;;) { 540 for (;;) {
541 lua_assert(cc.v.k == VVOID || cc.tostore > 0); 541 lua_assert(cc.v.k == VVOID || cc.tostore > 0);
542 optional(ls, ';'); /* compatibility only */ 542 testnext(ls, ';'); /* compatibility only */
543 if (ls->t.token == '}') break; 543 if (ls->t.token == '}') break;
544 closelistfield(fs, &cc); 544 closelistfield(fs, &cc);
545 switch(ls->t.token) { 545 switch(ls->t.token) {
@@ -988,7 +988,7 @@ static void fornum (LexState *ls, TString *varname, int line) {
988 exp1(ls); /* initial value */ 988 exp1(ls); /* initial value */
989 check(ls, ','); 989 check(ls, ',');
990 exp1(ls); /* limit */ 990 exp1(ls); /* limit */
991 if (optional(ls, ',')) 991 if (testnext(ls, ','))
992 exp1(ls); /* optional step */ 992 exp1(ls); /* optional step */
993 else { /* default step = 1 */ 993 else { /* default step = 1 */
994 luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); 994 luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
@@ -1018,7 +1018,7 @@ static void forlist (LexState *ls, TString *indexname) {
1018 new_localvarstr(ls, "(for generator)", nvars++); 1018 new_localvarstr(ls, "(for generator)", nvars++);
1019 new_localvarstr(ls, "(for state)", nvars++); 1019 new_localvarstr(ls, "(for state)", nvars++);
1020 new_localvar(ls, indexname, nvars++); 1020 new_localvar(ls, indexname, nvars++);
1021 while (optional(ls, ',')) { 1021 while (testnext(ls, ',')) {
1022 new_localvar(ls, str_checkname(ls), nvars++); 1022 new_localvar(ls, str_checkname(ls), nvars++);
1023 next(ls); 1023 next(ls);
1024 } 1024 }
@@ -1096,12 +1096,12 @@ static void localstat (LexState *ls) {
1096 int nvars = 0; 1096 int nvars = 0;
1097 int nexps; 1097 int nexps;
1098 expdesc e; 1098 expdesc e;
1099 next(ls); /* skip LOCAL */
1099 do { 1100 do {
1100 next(ls); /* skip LOCAL or `,' */
1101 new_localvar(ls, str_checkname(ls), nvars++); 1101 new_localvar(ls, str_checkname(ls), nvars++);
1102 next(ls); /* skip var name */ 1102 next(ls); /* skip var name */
1103 } while (ls->t.token == ','); 1103 } while (testnext(ls, ','));
1104 if (optional(ls, '=')) 1104 if (testnext(ls, '='))
1105 nexps = explist1(ls, &e); 1105 nexps = explist1(ls, &e);
1106 else { 1106 else {
1107 e.k = VVOID; 1107 e.k = VVOID;
@@ -1266,7 +1266,7 @@ static void parlist (LexState *ls) {
1266 default: luaX_syntaxerror(ls, "<name> or `...' expected"); 1266 default: luaX_syntaxerror(ls, "<name> or `...' expected");
1267 } 1267 }
1268 next(ls); 1268 next(ls);
1269 } while (!dots && optional(ls, ',')); 1269 } while (!dots && testnext(ls, ','));
1270 } 1270 }
1271 code_params(ls, nparams, dots); 1271 code_params(ls, nparams, dots);
1272} 1272}
@@ -1297,7 +1297,7 @@ static void chunk (LexState *ls) {
1297 int islast = 0; 1297 int islast = 0;
1298 while (!islast && !block_follow(ls->t.token)) { 1298 while (!islast && !block_follow(ls->t.token)) {
1299 islast = statement(ls); 1299 islast = statement(ls);
1300 optional(ls, ';'); 1300 testnext(ls, ';');
1301 lua_assert(ls->fs->freereg >= ls->fs->nactvar); 1301 lua_assert(ls->fs->freereg >= ls->fs->nactvar);
1302 ls->fs->freereg = ls->fs->nactvar; /* free registers */ 1302 ls->fs->freereg = ls->fs->nactvar; /* free registers */
1303 } 1303 }