aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-23 14:17:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-23 14:17:25 -0300
commit39b79783297bee79db9853b63d199e120a009a8f (patch)
treec738c621c4c28d8822c2f785400786301985273b /lparser.c
parentd164e2294f73d8e69f00d95a66014514b2dd0ec0 (diff)
downloadlua-39b79783297bee79db9853b63d199e120a009a8f.tar.gz
lua-39b79783297bee79db9853b63d199e120a009a8f.tar.bz2
lua-39b79783297bee79db9853b63d199e120a009a8f.zip
first (big) step to support wide chars
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c184
1 files changed, 92 insertions, 92 deletions
diff --git a/lparser.c b/lparser.c
index bb4ea097..53e05565 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.137 2001/02/22 18:59:59 roberto Exp roberto $ 2** $Id: lparser.c,v 1.138 2001/02/23 13:38:56 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*/
@@ -72,9 +72,9 @@ static void lookahead (LexState *ls) {
72 72
73 73
74static void error_expected (LexState *ls, int token) { 74static void error_expected (LexState *ls, int token) {
75 char buff[30], t[TOKEN_LEN]; 75 l_char buff[30], t[TOKEN_LEN];
76 luaX_token2str(token, t); 76 luaX_token2str(token, t);
77 sprintf(buff, "`%.10s' expected", t); 77 sprintf(buff, l_s("`%.10s' expected"), t);
78 luaK_error(ls, buff); 78 luaK_error(ls, buff);
79} 79}
80 80
@@ -86,7 +86,7 @@ static void check (LexState *ls, int c) {
86} 86}
87 87
88 88
89static void check_condition (LexState *ls, int c, const char *msg) { 89static void check_condition (LexState *ls, int c, const l_char *msg) {
90 if (!c) luaK_error(ls, msg); 90 if (!c) luaK_error(ls, msg);
91} 91}
92 92
@@ -105,11 +105,11 @@ static void check_match (LexState *ls, int what, int who, int where) {
105 if (where == ls->linenumber) 105 if (where == ls->linenumber)
106 error_expected(ls, what); 106 error_expected(ls, what);
107 else { 107 else {
108 char buff[70]; 108 l_char buff[70];
109 char t_what[TOKEN_LEN], t_who[TOKEN_LEN]; 109 l_char t_what[TOKEN_LEN], t_who[TOKEN_LEN];
110 luaX_token2str(what, t_what); 110 luaX_token2str(what, t_what);
111 luaX_token2str(who, t_who); 111 luaX_token2str(who, t_who);
112 sprintf(buff, "`%.10s' expected (to close `%.10s' at line %d)", 112 sprintf(buff, l_s("`%.10s' expected (to close `%.10s' at line %d)"),
113 t_what, t_who, where); 113 t_what, t_who, where);
114 luaK_error(ls, buff); 114 luaK_error(ls, buff);
115 } 115 }
@@ -123,7 +123,7 @@ static int string_constant (FuncState *fs, TString *s) {
123 int c = s->u.s.constindex; 123 int c = s->u.s.constindex;
124 if (c >= fs->nkstr || f->kstr[c] != s) { 124 if (c >= fs->nkstr || f->kstr[c] != s) {
125 luaM_growvector(fs->L, f->kstr, fs->nkstr, f->sizekstr, TString *, 125 luaM_growvector(fs->L, f->kstr, fs->nkstr, f->sizekstr, TString *,
126 MAXARG_U, "constant table overflow"); 126 MAXARG_U, l_s("constant table overflow"));
127 c = fs->nkstr++; 127 c = fs->nkstr++;
128 f->kstr[c] = s; 128 f->kstr[c] = s;
129 s->u.s.constindex = c; /* hint for next time */ 129 s->u.s.constindex = c; /* hint for next time */
@@ -139,7 +139,7 @@ static void code_string (LexState *ls, TString *s) {
139 139
140static TString *str_checkname (LexState *ls) { 140static TString *str_checkname (LexState *ls) {
141 TString *ts; 141 TString *ts;
142 check_condition(ls, (ls->t.token == TK_NAME), "<name> expected"); 142 check_condition(ls, (ls->t.token == TK_NAME), l_s("<name> expected"));
143 ts = ls->t.seminfo.ts; 143 ts = ls->t.seminfo.ts;
144 next(ls); 144 next(ls);
145 return ts; 145 return ts;
@@ -155,7 +155,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
155 FuncState *fs = ls->fs; 155 FuncState *fs = ls->fs;
156 Proto *f = fs->f; 156 Proto *f = fs->f;
157 luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, 157 luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
158 LocVar, MAX_INT, ""); 158 LocVar, MAX_INT, l_s(""));
159 f->locvars[fs->nlocvars].varname = varname; 159 f->locvars[fs->nlocvars].varname = varname;
160 return fs->nlocvars++; 160 return fs->nlocvars++;
161} 161}
@@ -163,7 +163,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
163 163
164static void new_localvar (LexState *ls, TString *name, int n) { 164static void new_localvar (LexState *ls, TString *name, int n) {
165 FuncState *fs = ls->fs; 165 FuncState *fs = ls->fs;
166 luaX_checklimit(ls, fs->nactloc+n+1, MAXLOCALS, "local variables"); 166 luaX_checklimit(ls, fs->nactloc+n+1, MAXLOCALS, l_s("local variables"));
167 fs->actloc[fs->nactloc+n] = luaI_registerlocalvar(ls, name); 167 fs->actloc[fs->nactloc+n] = luaI_registerlocalvar(ls, name);
168} 168}
169 169
@@ -182,7 +182,7 @@ static void removelocalvars (LexState *ls, int nvars) {
182} 182}
183 183
184 184
185static void new_localvarstr (LexState *ls, const char *name, int n) { 185static void new_localvarstr (LexState *ls, const l_char *name, int n) {
186 new_localvar(ls, luaS_new(ls->L, name), n); 186 new_localvar(ls, luaS_new(ls->L, name), n);
187} 187}
188 188
@@ -209,7 +209,7 @@ static int search_local (LexState *ls, TString *n, expdesc *var) {
209static void singlevar (LexState *ls, TString *n, expdesc *var) { 209static void singlevar (LexState *ls, TString *n, expdesc *var) {
210 int level = search_local(ls, n, var); 210 int level = search_local(ls, n, var);
211 if (level >= 1) /* neither local (0) nor global (-1)? */ 211 if (level >= 1) /* neither local (0) nor global (-1)? */
212 luaX_syntaxerror(ls, "cannot access a variable in outer function", 212 luaX_syntaxerror(ls, l_s("cannot access a variable in outer function"),
213 getstr(n)); 213 getstr(n));
214 else if (level == -1) /* global? */ 214 else if (level == -1) /* global? */
215 var->u.index = string_constant(ls->fs, n); 215 var->u.index = string_constant(ls->fs, n);
@@ -224,7 +224,7 @@ static int indexupvalue (LexState *ls, expdesc *v) {
224 return i; 224 return i;
225 } 225 }
226 /* new one */ 226 /* new one */
227 luaX_checklimit(ls, fs->f->nupvalues+1, MAXUPVALUES, "upvalues"); 227 luaX_checklimit(ls, fs->f->nupvalues+1, MAXUPVALUES, l_s("upvalues"));
228 fs->upvalues[fs->f->nupvalues] = *v; 228 fs->upvalues[fs->f->nupvalues] = *v;
229 return fs->f->nupvalues++; 229 return fs->f->nupvalues++;
230} 230}
@@ -236,12 +236,12 @@ static void pushupvalue (LexState *ls, TString *n) {
236 int level = search_local(ls, n, &v); 236 int level = search_local(ls, n, &v);
237 if (level == -1) { /* global? */ 237 if (level == -1) { /* global? */
238 if (fs->prev == NULL) 238 if (fs->prev == NULL)
239 luaX_syntaxerror(ls, "cannot access an upvalue at top level", getstr(n)); 239 luaX_syntaxerror(ls, l_s("cannot access an upvalue at top level"), getstr(n));
240 v.u.index = string_constant(fs->prev, n); 240 v.u.index = string_constant(fs->prev, n);
241 } 241 }
242 else if (level != 1) { 242 else if (level != 1) {
243 luaX_syntaxerror(ls, 243 luaX_syntaxerror(ls,
244 "upvalue must be global or local to immediately outer function", getstr(n)); 244 l_s("upvalue must be global or local to immediately outer function"), getstr(n));
245 } 245 }
246 luaK_code1(fs, OP_PUSHUPVALUE, indexupvalue(ls, &v)); 246 luaK_code1(fs, OP_PUSHUPVALUE, indexupvalue(ls, &v));
247} 247}
@@ -267,11 +267,11 @@ static void adjust_mult_assign (LexState *ls, int nvars, int nexps) {
267static void code_params (LexState *ls, int nparams, short dots) { 267static void code_params (LexState *ls, int nparams, short dots) {
268 FuncState *fs = ls->fs; 268 FuncState *fs = ls->fs;
269 adjustlocalvars(ls, nparams); 269 adjustlocalvars(ls, nparams);
270 luaX_checklimit(ls, fs->nactloc, MAXPARAMS, "parameters"); 270 luaX_checklimit(ls, fs->nactloc, MAXPARAMS, l_s("parameters"));
271 fs->f->numparams = (short)fs->nactloc; /* `self' could be there already */ 271 fs->f->numparams = (short)fs->nactloc; /* `self' could be there already */
272 fs->f->is_vararg = dots; 272 fs->f->is_vararg = dots;
273 if (dots) { 273 if (dots) {
274 new_localvarstr(ls, "arg", 0); 274 new_localvarstr(ls, l_s("arg"), 0);
275 adjustlocalvars(ls, 1); 275 adjustlocalvars(ls, 1);
276 } 276 }
277 luaK_deltastack(fs, fs->nactloc); /* count parameters in the stack */ 277 luaK_deltastack(fs, fs->nactloc); /* count parameters in the stack */
@@ -300,7 +300,7 @@ static void pushclosure (LexState *ls, FuncState *func) {
300 for (i=0; i<func->f->nupvalues; i++) 300 for (i=0; i<func->f->nupvalues; i++)
301 luaK_tostack(ls, &func->upvalues[i], 1); 301 luaK_tostack(ls, &func->upvalues[i], 1);
302 luaM_growvector(ls->L, f->kproto, fs->nkproto, f->sizekproto, Proto *, 302 luaM_growvector(ls->L, f->kproto, fs->nkproto, f->sizekproto, Proto *,
303 MAXARG_A, "constant table overflow"); 303 MAXARG_A, l_s("constant table overflow"));
304 f->kproto[fs->nkproto++] = func->f; 304 f->kproto[fs->nkproto++] = func->f;
305 luaK_code2(fs, OP_CLOSURE, fs->nkproto-1, func->f->nupvalues); 305 luaK_code2(fs, OP_CLOSURE, fs->nkproto-1, func->f->nupvalues);
306} 306}
@@ -366,7 +366,7 @@ Proto *luaY_parser (lua_State *L, ZIO *z) {
366 open_func(&lexstate, &funcstate); 366 open_func(&lexstate, &funcstate);
367 next(&lexstate); /* read first token */ 367 next(&lexstate); /* read first token */
368 chunk(&lexstate); 368 chunk(&lexstate);
369 check_condition(&lexstate, (lexstate.t.token == TK_EOS), "<eof> expected"); 369 check_condition(&lexstate, (lexstate.t.token == TK_EOS), l_s("<eof> expected"));
370 close_func(&lexstate); 370 close_func(&lexstate);
371 lua_assert(funcstate.prev == NULL); 371 lua_assert(funcstate.prev == NULL);
372 lua_assert(funcstate.f->nupvalues == 0); 372 lua_assert(funcstate.f->nupvalues == 0);
@@ -385,7 +385,7 @@ static int explist1 (LexState *ls) {
385 int n = 1; /* at least one expression */ 385 int n = 1; /* at least one expression */
386 expdesc v; 386 expdesc v;
387 expr(ls, &v); 387 expr(ls, &v);
388 while (ls->t.token == ',') { 388 while (ls->t.token == l_c(',')) {
389 next(ls); /* skip comma */ 389 next(ls); /* skip comma */
390 luaK_tostack(ls, &v, 1); /* gets only 1 value from previous expression */ 390 luaK_tostack(ls, &v, 1); /* gets only 1 value from previous expression */
391 expr(ls, &v); 391 expr(ls, &v);
@@ -400,13 +400,13 @@ static void funcargs (LexState *ls, int slf) {
400 FuncState *fs = ls->fs; 400 FuncState *fs = ls->fs;
401 int slevel = fs->stacklevel - slf - 1; /* where is func in the stack */ 401 int slevel = fs->stacklevel - slf - 1; /* where is func in the stack */
402 switch (ls->t.token) { 402 switch (ls->t.token) {
403 case '(': { /* funcargs -> `(' [ explist1 ] `)' */ 403 case l_c('('): { /* funcargs -> `(' [ explist1 ] `)' */
404 int line = ls->linenumber; 404 int line = ls->linenumber;
405 int nargs = 0; 405 int nargs = 0;
406 next(ls); 406 next(ls);
407 if (ls->t.token != ')') /* arg list not empty? */ 407 if (ls->t.token != l_c(')')) /* arg list not empty? */
408 nargs = explist1(ls); 408 nargs = explist1(ls);
409 check_match(ls, ')', '(', line); 409 check_match(ls, l_c(')'), l_c('('), line);
410#ifdef LUA_COMPAT_ARGRET 410#ifdef LUA_COMPAT_ARGRET
411 if (nargs > 0) /* arg list is not empty? */ 411 if (nargs > 0) /* arg list is not empty? */
412 luaK_setcallreturns(fs, 1); /* last call returns only 1 value */ 412 luaK_setcallreturns(fs, 1); /* last call returns only 1 value */
@@ -415,7 +415,7 @@ static void funcargs (LexState *ls, int slf) {
415#endif 415#endif
416 break; 416 break;
417 } 417 }
418 case '{': { /* funcargs -> constructor */ 418 case l_c('{'): { /* funcargs -> constructor */
419 constructor(ls); 419 constructor(ls);
420 break; 420 break;
421 } 421 }
@@ -425,7 +425,7 @@ static void funcargs (LexState *ls, int slf) {
425 break; 425 break;
426 } 426 }
427 default: { 427 default: {
428 luaK_error(ls, "function arguments expected"); 428 luaK_error(ls, l_s("function arguments expected"));
429 break; 429 break;
430 } 430 }
431 } 431 }
@@ -448,15 +448,15 @@ static void recfield (LexState *ls) {
448 luaK_kstr(ls, checkname(ls)); 448 luaK_kstr(ls, checkname(ls));
449 break; 449 break;
450 } 450 }
451 case '[': { 451 case l_c('['): {
452 next(ls); 452 next(ls);
453 exp1(ls); 453 exp1(ls);
454 check(ls, ']'); 454 check(ls, l_c(']'));
455 break; 455 break;
456 } 456 }
457 default: luaK_error(ls, "<name> or `[' expected"); 457 default: luaK_error(ls, l_s("<name> or `[' expected"));
458 } 458 }
459 check(ls, '='); 459 check(ls, l_c('='));
460 exp1(ls); 460 exp1(ls);
461} 461}
462 462
@@ -466,9 +466,9 @@ static int recfields (LexState *ls) {
466 FuncState *fs = ls->fs; 466 FuncState *fs = ls->fs;
467 int n = 1; /* at least one element */ 467 int n = 1; /* at least one element */
468 recfield(ls); 468 recfield(ls);
469 while (ls->t.token == ',') { 469 while (ls->t.token == l_c(',')) {
470 next(ls); 470 next(ls);
471 if (ls->t.token == ';' || ls->t.token == '}') 471 if (ls->t.token == l_c(';') || ls->t.token == l_c('}'))
472 break; 472 break;
473 recfield(ls); 473 recfield(ls);
474 n++; 474 n++;
@@ -485,14 +485,14 @@ static int listfields (LexState *ls) {
485 FuncState *fs = ls->fs; 485 FuncState *fs = ls->fs;
486 int n = 1; /* at least one element */ 486 int n = 1; /* at least one element */
487 exp1(ls); 487 exp1(ls);
488 while (ls->t.token == ',') { 488 while (ls->t.token == l_c(',')) {
489 next(ls); 489 next(ls);
490 if (ls->t.token == ';' || ls->t.token == '}') 490 if (ls->t.token == l_c(';') || ls->t.token == l_c('}'))
491 break; 491 break;
492 exp1(ls); 492 exp1(ls);
493 n++; 493 n++;
494 luaX_checklimit(ls, n/LFIELDS_PER_FLUSH, MAXARG_A, 494 luaX_checklimit(ls, n/LFIELDS_PER_FLUSH, MAXARG_A,
495 "`item groups' in a list initializer"); 495 l_s("`item groups' in a list initializer"));
496 if (n%LFIELDS_PER_FLUSH == 0) 496 if (n%LFIELDS_PER_FLUSH == 0)
497 luaK_code2(fs, OP_SETLIST, n/LFIELDS_PER_FLUSH - 1, LFIELDS_PER_FLUSH); 497 luaK_code2(fs, OP_SETLIST, n/LFIELDS_PER_FLUSH - 1, LFIELDS_PER_FLUSH);
498 } 498 }
@@ -504,18 +504,18 @@ static int listfields (LexState *ls) {
504 504
505static void constructor_part (LexState *ls, Constdesc *cd) { 505static void constructor_part (LexState *ls, Constdesc *cd) {
506 switch (ls->t.token) { 506 switch (ls->t.token) {
507 case ';': case '}': { /* constructor_part -> empty */ 507 case l_c(';'): case l_c('}'): { /* constructor_part -> empty */
508 cd->n = 0; 508 cd->n = 0;
509 cd->k = ls->t.token; 509 cd->k = ls->t.token;
510 break; 510 break;
511 } 511 }
512 case TK_NAME: { /* may be listfields or recfields */ 512 case TK_NAME: { /* may be listfields or recfields */
513 lookahead(ls); 513 lookahead(ls);
514 if (ls->lookahead.token != '=') /* expression? */ 514 if (ls->lookahead.token != l_c('=')) /* expression? */
515 goto case_default; 515 goto case_default;
516 /* else go through to recfields */ 516 /* else go through to recfields */
517 } 517 }
518 case '[': { /* constructor_part -> recfields */ 518 case l_c('['): { /* constructor_part -> recfields */
519 cd->n = recfields(ls); 519 cd->n = recfields(ls);
520 cd->k = 1; /* record */ 520 cd->k = 1; /* record */
521 break; 521 break;
@@ -537,17 +537,17 @@ static void constructor (LexState *ls) {
537 int pc = luaK_code1(fs, OP_CREATETABLE, 0); 537 int pc = luaK_code1(fs, OP_CREATETABLE, 0);
538 int nelems; 538 int nelems;
539 Constdesc cd; 539 Constdesc cd;
540 check(ls, '{'); 540 check(ls, l_c('{'));
541 constructor_part(ls, &cd); 541 constructor_part(ls, &cd);
542 nelems = cd.n; 542 nelems = cd.n;
543 if (optional(ls, ';')) { 543 if (optional(ls, l_c(';'))) {
544 Constdesc other_cd; 544 Constdesc other_cd;
545 constructor_part(ls, &other_cd); 545 constructor_part(ls, &other_cd);
546 check_condition(ls, (cd.k != other_cd.k), "invalid constructor syntax"); 546 check_condition(ls, (cd.k != other_cd.k), l_s("invalid constructor syntax"));
547 nelems += other_cd.n; 547 nelems += other_cd.n;
548 } 548 }
549 check_match(ls, '}', '{', line); 549 check_match(ls, l_c('}'), l_c('{'), line);
550 luaX_checklimit(ls, nelems, MAXARG_U, "elements in a table constructor"); 550 luaX_checklimit(ls, nelems, MAXARG_U, l_s("elements in a table constructor"));
551 SETARG_U(fs->f->code[pc], nelems); /* set initial table size */ 551 SETARG_U(fs->f->code[pc], nelems); /* set initial table size */
552} 552}
553 553
@@ -581,7 +581,7 @@ static void primaryexp (LexState *ls, expdesc *v) {
581 next(ls); 581 next(ls);
582 break; 582 break;
583 } 583 }
584 case '{': { /* constructor */ 584 case l_c('{'): { /* constructor */
585 constructor(ls); 585 constructor(ls);
586 break; 586 break;
587 } 587 }
@@ -590,23 +590,23 @@ static void primaryexp (LexState *ls, expdesc *v) {
590 body(ls, 0, ls->linenumber); 590 body(ls, 0, ls->linenumber);
591 break; 591 break;
592 } 592 }
593 case '(': { 593 case l_c('('): {
594 next(ls); 594 next(ls);
595 expr(ls, v); 595 expr(ls, v);
596 check(ls, ')'); 596 check(ls, l_c(')'));
597 return; 597 return;
598 } 598 }
599 case TK_NAME: { 599 case TK_NAME: {
600 singlevar(ls, str_checkname(ls), v); 600 singlevar(ls, str_checkname(ls), v);
601 return; 601 return;
602 } 602 }
603 case '%': { 603 case l_c('%'): {
604 next(ls); /* skip `%' */ 604 next(ls); /* skip `%' */
605 pushupvalue(ls, str_checkname(ls)); 605 pushupvalue(ls, str_checkname(ls));
606 break; 606 break;
607 } 607 }
608 default: { 608 default: {
609 luaK_error(ls, "unexpected symbol"); 609 luaK_error(ls, l_s("unexpected symbol"));
610 return; 610 return;
611 } 611 }
612 } 612 }
@@ -621,22 +621,22 @@ static void simpleexp (LexState *ls, expdesc *v) {
621 primaryexp(ls, v); 621 primaryexp(ls, v);
622 for (;;) { 622 for (;;) {
623 switch (ls->t.token) { 623 switch (ls->t.token) {
624 case '.': { /* `.' NAME */ 624 case l_c('.'): { /* `.' NAME */
625 next(ls); 625 next(ls);
626 luaK_tostack(ls, v, 1); /* `v' must be on stack */ 626 luaK_tostack(ls, v, 1); /* `v' must be on stack */
627 luaK_kstr(ls, checkname(ls)); 627 luaK_kstr(ls, checkname(ls));
628 v->k = VINDEXED; 628 v->k = VINDEXED;
629 break; 629 break;
630 } 630 }
631 case '[': { /* `[' exp1 `]' */ 631 case l_c('['): { /* `[' exp1 `]' */
632 next(ls); 632 next(ls);
633 luaK_tostack(ls, v, 1); /* `v' must be on stack */ 633 luaK_tostack(ls, v, 1); /* `v' must be on stack */
634 v->k = VINDEXED; 634 v->k = VINDEXED;
635 exp1(ls); 635 exp1(ls);
636 check(ls, ']'); 636 check(ls, l_c(']'));
637 break; 637 break;
638 } 638 }
639 case ':': { /* `:' NAME funcargs */ 639 case l_c(':'): { /* `:' NAME funcargs */
640 next(ls); 640 next(ls);
641 luaK_tostack(ls, v, 1); /* `v' must be on stack */ 641 luaK_tostack(ls, v, 1); /* `v' must be on stack */
642 luaK_code1(ls->fs, OP_PUSHSELF, checkname(ls)); 642 luaK_code1(ls->fs, OP_PUSHSELF, checkname(ls));
@@ -645,7 +645,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
645 v->u.l.t = v->u.l.f = NO_JUMP; 645 v->u.l.t = v->u.l.f = NO_JUMP;
646 break; 646 break;
647 } 647 }
648 case '(': case TK_STRING: case '{': { /* funcargs */ 648 case l_c('('): case TK_STRING: case l_c('{'): { /* funcargs */
649 luaK_tostack(ls, v, 1); /* `v' must be on stack */ 649 luaK_tostack(ls, v, 1); /* `v' must be on stack */
650 funcargs(ls, 0); 650 funcargs(ls, 0);
651 v->k = VEXP; 651 v->k = VEXP;
@@ -661,7 +661,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
661static UnOpr getunopr (int op) { 661static UnOpr getunopr (int op) {
662 switch (op) { 662 switch (op) {
663 case TK_NOT: return OPR_NOT; 663 case TK_NOT: return OPR_NOT;
664 case '-': return OPR_MINUS; 664 case l_c('-'): return OPR_MINUS;
665 default: return OPR_NOUNOPR; 665 default: return OPR_NOUNOPR;
666 } 666 }
667} 667}
@@ -669,17 +669,17 @@ static UnOpr getunopr (int op) {
669 669
670static BinOpr getbinopr (int op) { 670static BinOpr getbinopr (int op) {
671 switch (op) { 671 switch (op) {
672 case '+': return OPR_ADD; 672 case l_c('+'): return OPR_ADD;
673 case '-': return OPR_SUB; 673 case l_c('-'): return OPR_SUB;
674 case '*': return OPR_MULT; 674 case l_c('*'): return OPR_MULT;
675 case '/': return OPR_DIV; 675 case l_c('/'): return OPR_DIV;
676 case '^': return OPR_POW; 676 case l_c('^'): return OPR_POW;
677 case TK_CONCAT: return OPR_CONCAT; 677 case TK_CONCAT: return OPR_CONCAT;
678 case TK_NE: return OPR_NE; 678 case TK_NE: return OPR_NE;
679 case TK_EQ: return OPR_EQ; 679 case TK_EQ: return OPR_EQ;
680 case '<': return OPR_LT; 680 case l_c('<'): return OPR_LT;
681 case TK_LE: return OPR_LE; 681 case TK_LE: return OPR_LE;
682 case '>': return OPR_GT; 682 case l_c('>'): return OPR_GT;
683 case TK_GE: return OPR_GE; 683 case TK_GE: return OPR_GE;
684 case TK_AND: return OPR_AND; 684 case TK_AND: return OPR_AND;
685 case TK_OR: return OPR_OR; 685 case TK_OR: return OPR_OR;
@@ -774,17 +774,17 @@ static void block (LexState *ls) {
774 774
775static int assignment (LexState *ls, expdesc *v, int nvars) { 775static int assignment (LexState *ls, expdesc *v, int nvars) {
776 int left = 0; /* number of values left in the stack after assignment */ 776 int left = 0; /* number of values left in the stack after assignment */
777 luaX_checklimit(ls, nvars, MAXVARSLH, "variables in a multiple assignment"); 777 luaX_checklimit(ls, nvars, MAXVARSLH, l_s("variables in a multiple assignment"));
778 if (ls->t.token == ',') { /* assignment -> `,' simpleexp assignment */ 778 if (ls->t.token == l_c(',')) { /* assignment -> `,' simpleexp assignment */
779 expdesc nv; 779 expdesc nv;
780 next(ls); 780 next(ls);
781 simpleexp(ls, &nv); 781 simpleexp(ls, &nv);
782 check_condition(ls, (nv.k != VEXP), "syntax error"); 782 check_condition(ls, (nv.k != VEXP), l_s("syntax error"));
783 left = assignment(ls, &nv, nvars+1); 783 left = assignment(ls, &nv, nvars+1);
784 } 784 }
785 else { /* assignment -> `=' explist1 */ 785 else { /* assignment -> `=' explist1 */
786 int nexps; 786 int nexps;
787 check(ls, '='); 787 check(ls, l_c('='));
788 nexps = explist1(ls); 788 nexps = explist1(ls);
789 adjust_mult_assign(ls, nvars, nexps); 789 adjust_mult_assign(ls, nvars, nexps);
790 } 790 }
@@ -856,17 +856,17 @@ static void forbody (LexState *ls, int nvar, OpCode prepfor, OpCode loopfor) {
856static void fornum (LexState *ls, TString *varname) { 856static void fornum (LexState *ls, TString *varname) {
857 /* fornum -> NAME = exp1,exp1[,exp1] forbody */ 857 /* fornum -> NAME = exp1,exp1[,exp1] forbody */
858 FuncState *fs = ls->fs; 858 FuncState *fs = ls->fs;
859 check(ls, '='); 859 check(ls, l_c('='));
860 exp1(ls); /* initial value */ 860 exp1(ls); /* initial value */
861 check(ls, ','); 861 check(ls, l_c(','));
862 exp1(ls); /* limit */ 862 exp1(ls); /* limit */
863 if (optional(ls, ',')) 863 if (optional(ls, l_c(',')))
864 exp1(ls); /* optional step */ 864 exp1(ls); /* optional step */
865 else 865 else
866 luaK_code1(fs, OP_PUSHINT, 1); /* default step */ 866 luaK_code1(fs, OP_PUSHINT, 1); /* default step */
867 new_localvar(ls, varname, 0); 867 new_localvar(ls, varname, 0);
868 new_localvarstr(ls, "(limit)", 1); 868 new_localvarstr(ls, l_s("(limit)"), 1);
869 new_localvarstr(ls, "(step)", 2); 869 new_localvarstr(ls, l_s("(step)"), 2);
870 forbody(ls, 3, OP_FORPREP, OP_FORLOOP); 870 forbody(ls, 3, OP_FORPREP, OP_FORLOOP);
871} 871}
872 872
@@ -874,17 +874,17 @@ static void fornum (LexState *ls, TString *varname) {
874static void forlist (LexState *ls, TString *indexname) { 874static void forlist (LexState *ls, TString *indexname) {
875 /* forlist -> NAME,NAME IN exp1 forbody */ 875 /* forlist -> NAME,NAME IN exp1 forbody */
876 TString *valname; 876 TString *valname;
877 check(ls, ','); 877 check(ls, l_c(','));
878 valname = str_checkname(ls); 878 valname = str_checkname(ls);
879 /* next test is dirty, but avoids `in' being a reserved word */ 879 /* next test is dirty, but avoids `in' being a reserved word */
880 check_condition(ls, 880 check_condition(ls,
881 (ls->t.token == TK_NAME && 881 (ls->t.token == TK_NAME &&
882 ls->t.seminfo.ts == luaS_newliteral(ls->L, "in")), 882 ls->t.seminfo.ts == luaS_newliteral(ls->L, l_s("in"))),
883 "`in' expected"); 883 l_s("`in' expected"));
884 next(ls); /* skip `in' */ 884 next(ls); /* skip `in' */
885 exp1(ls); /* table */ 885 exp1(ls); /* table */
886 new_localvarstr(ls, "(table)", 0); 886 new_localvarstr(ls, l_s("(table)"), 0);
887 new_localvarstr(ls, "(index)", 1); 887 new_localvarstr(ls, l_s("(index)"), 1);
888 new_localvar(ls, indexname, 2); 888 new_localvar(ls, indexname, 2);
889 new_localvar(ls, valname, 3); 889 new_localvar(ls, valname, 3);
890 forbody(ls, 4, OP_LFORPREP, OP_LFORLOOP); 890 forbody(ls, 4, OP_LFORPREP, OP_LFORLOOP);
@@ -900,9 +900,9 @@ static void forstat (LexState *ls, int line) {
900 next(ls); /* skip `for' */ 900 next(ls); /* skip `for' */
901 varname = str_checkname(ls); /* first variable name */ 901 varname = str_checkname(ls); /* first variable name */
902 switch (ls->t.token) { 902 switch (ls->t.token) {
903 case '=': fornum(ls, varname); break; 903 case l_c('='): fornum(ls, varname); break;
904 case ',': forlist(ls, varname); break; 904 case l_c(','): forlist(ls, varname); break;
905 default: luaK_error(ls, "`=' or `,' expected"); 905 default: luaK_error(ls, l_s("`=' or `,' expected"));
906 } 906 }
907 check_match(ls, TK_END, TK_FOR, line); 907 check_match(ls, TK_END, TK_FOR, line);
908 leavebreak(fs, &bl); 908 leavebreak(fs, &bl);
@@ -949,8 +949,8 @@ static void localstat (LexState *ls) {
949 do { 949 do {
950 next(ls); /* skip LOCAL or `,' */ 950 next(ls); /* skip LOCAL or `,' */
951 new_localvar(ls, str_checkname(ls), nvars++); 951 new_localvar(ls, str_checkname(ls), nvars++);
952 } while (ls->t.token == ','); 952 } while (ls->t.token == l_c(','));
953 if (optional(ls, '=')) 953 if (optional(ls, l_c('=')))
954 nexps = explist1(ls); 954 nexps = explist1(ls);
955 else 955 else
956 nexps = 0; 956 nexps = 0;
@@ -963,13 +963,13 @@ static int funcname (LexState *ls, expdesc *v) {
963 /* funcname -> NAME {`.' NAME} [`:' NAME] */ 963 /* funcname -> NAME {`.' NAME} [`:' NAME] */
964 int needself = 0; 964 int needself = 0;
965 singlevar(ls, str_checkname(ls), v); 965 singlevar(ls, str_checkname(ls), v);
966 while (ls->t.token == '.') { 966 while (ls->t.token == l_c('.')) {
967 next(ls); 967 next(ls);
968 luaK_tostack(ls, v, 1); 968 luaK_tostack(ls, v, 1);
969 luaK_kstr(ls, checkname(ls)); 969 luaK_kstr(ls, checkname(ls));
970 v->k = VINDEXED; 970 v->k = VINDEXED;
971 } 971 }
972 if (ls->t.token == ':') { 972 if (ls->t.token == l_c(':')) {
973 needself = 1; 973 needself = 1;
974 next(ls); 974 next(ls);
975 luaK_tostack(ls, v, 1); 975 luaK_tostack(ls, v, 1);
@@ -997,7 +997,7 @@ static void namestat (LexState *ls) {
997 expdesc v; 997 expdesc v;
998 simpleexp(ls, &v); 998 simpleexp(ls, &v);
999 if (v.k == VEXP) { /* stat -> func */ 999 if (v.k == VEXP) { /* stat -> func */
1000 check_condition(ls, luaK_lastisopen(fs), "syntax error"); /* an upvalue? */ 1000 check_condition(ls, luaK_lastisopen(fs), l_s("syntax error")); /* an upvalue? */
1001 luaK_setcallreturns(fs, 0); /* call statement uses no results */ 1001 luaK_setcallreturns(fs, 0); /* call statement uses no results */
1002 } 1002 }
1003 else { /* stat -> assignment */ 1003 else { /* stat -> assignment */
@@ -1011,7 +1011,7 @@ static void retstat (LexState *ls) {
1011 /* stat -> RETURN explist */ 1011 /* stat -> RETURN explist */
1012 FuncState *fs = ls->fs; 1012 FuncState *fs = ls->fs;
1013 next(ls); /* skip RETURN */ 1013 next(ls); /* skip RETURN */
1014 if (!block_follow(ls->t.token) && ls->t.token != ';') 1014 if (!block_follow(ls->t.token) && ls->t.token != l_c(';'))
1015 explist1(ls); /* optional return values */ 1015 explist1(ls); /* optional return values */
1016 luaK_code1(fs, OP_RETURN, ls->fs->nactloc); 1016 luaK_code1(fs, OP_RETURN, ls->fs->nactloc);
1017 fs->stacklevel = fs->nactloc; /* removes all temp values */ 1017 fs->stacklevel = fs->nactloc; /* removes all temp values */
@@ -1024,7 +1024,7 @@ static void breakstat (LexState *ls) {
1024 int currentlevel = fs->stacklevel; 1024 int currentlevel = fs->stacklevel;
1025 Breaklabel *bl = fs->bl; 1025 Breaklabel *bl = fs->bl;
1026 if (!bl) 1026 if (!bl)
1027 luaK_error(ls, "no loop to break"); 1027 luaK_error(ls, l_s("no loop to break"));
1028 next(ls); /* skip BREAK */ 1028 next(ls); /* skip BREAK */
1029 luaK_adjuststack(fs, currentlevel - bl->stacklevel); 1029 luaK_adjuststack(fs, currentlevel - bl->stacklevel);
1030 luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); 1030 luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
@@ -1086,14 +1086,14 @@ static void parlist (LexState *ls) {
1086 /* parlist -> [ param { `,' param } ] */ 1086 /* parlist -> [ param { `,' param } ] */
1087 int nparams = 0; 1087 int nparams = 0;
1088 short dots = 0; 1088 short dots = 0;
1089 if (ls->t.token != ')') { /* is `parlist' not empty? */ 1089 if (ls->t.token != l_c(')')) { /* is `parlist' not empty? */
1090 do { 1090 do {
1091 switch (ls->t.token) { 1091 switch (ls->t.token) {
1092 case TK_DOTS: next(ls); dots = 1; break; 1092 case TK_DOTS: next(ls); dots = 1; break;
1093 case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break; 1093 case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break;
1094 default: luaK_error(ls, "<name> or `...' expected"); 1094 default: luaK_error(ls, l_s("<name> or `...' expected"));
1095 } 1095 }
1096 } while (!dots && optional(ls, ',')); 1096 } while (!dots && optional(ls, l_c(',')));
1097 } 1097 }
1098 code_params(ls, nparams, dots); 1098 code_params(ls, nparams, dots);
1099} 1099}
@@ -1104,13 +1104,13 @@ static void body (LexState *ls, int needself, int line) {
1104 FuncState new_fs; 1104 FuncState new_fs;
1105 open_func(ls, &new_fs); 1105 open_func(ls, &new_fs);
1106 new_fs.f->lineDefined = line; 1106 new_fs.f->lineDefined = line;
1107 check(ls, '('); 1107 check(ls, l_c('('));
1108 if (needself) { 1108 if (needself) {
1109 new_localvarstr(ls, "self", 0); 1109 new_localvarstr(ls, l_s("self"), 0);
1110 adjustlocalvars(ls, 1); 1110 adjustlocalvars(ls, 1);
1111 } 1111 }
1112 parlist(ls); 1112 parlist(ls);
1113 check(ls, ')'); 1113 check(ls, l_c(')'));
1114 chunk(ls); 1114 chunk(ls);
1115 check_match(ls, TK_END, TK_FUNCTION, line); 1115 check_match(ls, TK_END, TK_FUNCTION, line);
1116 close_func(ls); 1116 close_func(ls);
@@ -1126,7 +1126,7 @@ static void chunk (LexState *ls) {
1126 int islast = 0; 1126 int islast = 0;
1127 while (!islast && !block_follow(ls->t.token)) { 1127 while (!islast && !block_follow(ls->t.token)) {
1128 islast = statement(ls); 1128 islast = statement(ls);
1129 optional(ls, ';'); 1129 optional(ls, l_c(';'));
1130 lua_assert(ls->fs->stacklevel == ls->fs->nactloc); 1130 lua_assert(ls->fs->stacklevel == ls->fs->nactloc);
1131 } 1131 }
1132} 1132}