1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
|
/* A Bison parser, made from lua.stx
by GNU Bison version 1.25
*/
// generated most closed version (1.25 was available in 11 May 1996) of bison
// before lua 3.1 alpha was published by lhf in 15 Jan 1998 based on
// http://lua-users.org/lists/lua-l/1998-01/msg00023.html
// lua.stx is from RCS source tree from lua.org by lhf on request
// generated by using command: bison -o lstx.c -p luaY_ -d lua.stx
// removed platform depend not used code, formated code too
#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
#include "engines/grim/lua/lauxlib.h"
#include "engines/grim/lua/ldo.h"
#include "engines/grim/lua/lfunc.h"
#include "engines/grim/lua/llex.h"
#include "engines/grim/lua/lmem.h"
#include "engines/grim/lua/lopcodes.h"
#include "engines/grim/lua/lparser.h"
#include "engines/grim/lua/lstate.h"
#include "engines/grim/lua/lstring.h"
#include "engines/grim/lua/lua.h"
#include "engines/grim/lua/luadebug.h"
#include "engines/grim/lua/lzio.h"
namespace Grim {
#define YYBISON 1 /* Identify Bison output. */
#define yyparse luaY_parse
#define yylex luaY_lex
#define yyerror luaY_error
#define yylval luaY_lval
#define yychar luaY_char
#define yydebug luaY_debug
#define yynerrs luaY_nerrs
#define WRONGTOKEN 258
#define NIL 259
#define IF 260
#define THEN 261
#define ELSE 262
#define ELSEIF 263
#define WHILE 264
#define DO 265
#define REPEAT 266
#define UNTIL 267
#define END 268
#define RETURN 269
#define LOCAL 270
#define FUNCTION 271
#define DOTS 272
#define NUMBER 273
#define NAME 274
#define STRING 275
#define AND 276
#define OR 277
#define EQ 278
#define NE 279
#define LE 280
#define GE 281
#define CONC 282
#define UNARY 283
#define NOT 284
/*
** $Id$
** Syntax analizer and code generator
** See Copyright Notice in lua.h
*/
int luaY_parse (void);
#define MES_LIM(x) "(limit=" x ")"
/* size of a "normal" jump instruction: OpCode + 1 byte */
#define JMPSIZE 2
/* maximum number of local variables */
#define MAXLOCALS 32
#define SMAXLOCALS "32"
#define MINGLOBAL (MAXLOCALS+1)
/* maximum number of variables in a multiple assignment */
#define MAXVAR 32
#define SMAXVAR "32"
/* maximum number of nested functions */
#define MAXSTATES 6
#define SMAXSTATES "6"
/* maximum number of upvalues */
#define MAXUPVALUES 16
#define SMAXUPVALUES "16"
/*
** Variable descriptor:
** if 0<n<MINGLOBAL, represents local variable indexed by (n-1);
** if MINGLOBAL<=n, represents global variable at position (n-MINGLOBAL);
** if n<0, indexed variable with index (-n)-1 (table on top of stack);
** if n==0, an indexed variable (table and index on top of stack)
** Must be long to store negative Word values.
*/
typedef long vardesc;
#define isglobal(v) (MINGLOBAL<=(v))
#define globalindex(v) ((v)-MINGLOBAL)
#define islocal(v) (0<(v) && (v)<MINGLOBAL)
#define localindex(v) ((v)-1)
#define isdot(v) (v<0)
#define dotindex(v) ((-(v))-1)
/* state needed to generate code for a given function */
typedef struct FuncState {
TProtoFunc *f; /* current function header */
int pc; /* next position to code */
TaggedString *localvar[MAXLOCALS]; /* store local variable names */
int stacksize; /* number of values on activation register */
int maxstacksize; /* maximum number of values on activation register */
int nlocalvar; /* number of active local variables */
int nupvalues; /* number of upvalues */
int nvars; /* number of entries in f->locvars */
int maxcode; /* size of f->code */
int maxvars; /* size of f->locvars (-1 if no debug information) */
int maxconsts; /* size of f->consts */
vardesc varbuffer[MAXVAR]; /* variables in an assignment list */
vardesc upvalues[MAXUPVALUES]; /* upvalues */
} FuncState;
#define YYPURE 1
void luaY_syntaxerror (const char *s, const char *token)
{
if (token[0] == 0)
token = "<eof>";
luaL_verror("%.100s;\n last token read: \"%.50s\" at line %d in file %.50s",
s, token, lua_state->lexstate->linenumber, lua_state->mainState->f->fileName->str);
}
void luaY_error (const char *s)
{
luaY_syntaxerror(s, luaX_lasttoken());
}
static void check_pc (int n)
{
FuncState *fs = lua_state->currState;
if (fs->pc+n > fs->maxcode)
fs->maxcode = luaM_growvector(&fs->f->code, fs->maxcode,
byte, codeEM, MAX_INT);
}
static void code_byte (byte c)
{
check_pc(1);
lua_state->currState->f->code[lua_state->currState->pc++] = c;
}
static void deltastack (int delta)
{
FuncState *fs = lua_state->currState;
fs->stacksize += delta;
if (fs->stacksize > fs->maxstacksize) {
if (fs->stacksize > 255)
luaY_error("function/expression too complex");
fs->maxstacksize = fs->stacksize;
}
}
static int code_oparg_at (int pc, OpCode op, int builtin, int arg, int delta)
{
byte *code = lua_state->currState->f->code;
deltastack(delta);
if (arg < builtin) {
code[pc] = op+1+arg;
return 1;
}
else if (arg <= 255) {
code[pc] = op;
code[pc+1] = arg;
return 2;
}
else if (arg <= (int)MAX_WORD) {
code[pc] = op+1+builtin;
code[pc+1] = arg&0xFF;
code[pc+2] = arg>>8;
return 3;
}
else luaY_error("code too long " MES_LIM("64K"));
return 0; /* to avoid warnings */
}
static int fix_opcode (int pc, OpCode op, int builtin, int arg)
{
FuncState *fs = lua_state->currState;
if (arg < builtin) { /* close space */
luaO_memdown(fs->f->code+pc+1, fs->f->code+pc+2, fs->pc-(pc+2));
fs->pc--;
}
else if (arg > 255) { /* open space */
check_pc(1);
luaO_memup(fs->f->code+pc+1, fs->f->code+pc, fs->pc-pc);
fs->pc++;
}
return code_oparg_at(pc, op, builtin, arg, 0) - 2;
}
static void code_oparg (OpCode op, int builtin, int arg, int delta)
{
check_pc(3); /* maximum code size */
lua_state->currState->pc += code_oparg_at(lua_state->currState->pc, op, builtin, arg, delta);
}
static void code_opcode (OpCode op, int delta)
{
deltastack(delta);
code_byte(op);
}
static void code_pop (OpCode op)
{
code_opcode(op, -1);
}
/* binary operations get 2 arguments and leave one, so they pop one */
#define code_binop(op) code_pop(op)
static void code_neutralop (OpCode op)
{
code_opcode(op, 0);
}
/* unary operations get 1 argument and leave one, so they are neutral */
#define code_unop(op) code_neutralop(op)
static void code_constant (int c)
{
code_oparg(PUSHCONSTANT, 8, c, 1);
}
static int next_constant (FuncState *cs)
{
TProtoFunc *f = cs->f;
if (f->nconsts >= cs->maxconsts) {
cs->maxconsts = luaM_growvector(&f->consts, cs->maxconsts, TObject,
constantEM, MAX_WORD);
}
return f->nconsts++;
}
static int string_constant (TaggedString *s, FuncState *cs)
{
TProtoFunc *f = cs->f;
int c = s->constindex;
if (!(c < f->nconsts &&
ttype(&f->consts[c]) == LUA_T_STRING && tsvalue(&f->consts[c]) == s)) {
c = next_constant(cs);
ttype(&f->consts[c]) = LUA_T_STRING;
tsvalue(&f->consts[c]) = s;
s->constindex = c; /* hint for next time */
}
return c;
}
static void code_string (TaggedString *s)
{
code_constant(string_constant(s, lua_state->currState));
}
#define LIM 20
static int real_constant(float r)
{
/* check whether 'r' has appeared within the last LIM entries */
TObject *cnt = lua_state->currState->f->consts;
int c = lua_state->currState->f->nconsts;
int lim = c < LIM ? 0 : c-LIM;
while (--c >= lim) {
if (ttype(&cnt[c]) == LUA_T_NUMBER && nvalue(&cnt[c]) == r)
return c;
}
/* not found; create a luaM_new entry */
c = next_constant(lua_state->currState);
cnt = lua_state->currState->f->consts; /* 'next_constant' may reallocate this vector */
ttype(&cnt[c]) = LUA_T_NUMBER;
nvalue(&cnt[c]) = r;
return c;
}
static void code_number(float f)
{
int i;
if (f >= 0 && f <= (float)MAX_WORD && (float)(i=(int)f) == f)
code_oparg(PUSHNUMBER, 3, i, 1); /* f has an (short) integer value */
else
code_constant(real_constant(f));
}
static void flush_record (int n)
{
if (n > 0)
code_oparg(SETMAP, 1, n-1, -2*n);
}
static void flush_list (int m, int n)
{
if (n == 0) return;
code_oparg(SETLIST, 1, m, -n);
code_byte(n);
}
static void luaI_registerlocalvar (TaggedString *varname, int line)
{
FuncState *fs = lua_state->currState;
if (fs->maxvars != -1) { /* debug information? */
if (fs->nvars >= fs->maxvars)
fs->maxvars = luaM_growvector(&fs->f->locvars, fs->maxvars,
LocVar, "", MAX_WORD);
fs->f->locvars[fs->nvars].varname = varname;
fs->f->locvars[fs->nvars].line = line;
fs->nvars++;
}
}
static void luaI_unregisterlocalvar (int line)
{
luaI_registerlocalvar(nullptr, line);
}
static void store_localvar (TaggedString *name, int n)
{
if (lua_state->currState->nlocalvar+n < MAXLOCALS)
lua_state->currState->localvar[lua_state->currState->nlocalvar+n] = name;
else
luaY_error("too many local variables " MES_LIM(SMAXLOCALS));
luaI_registerlocalvar(name, lua_state->lexstate->linenumber);
}
static void add_localvar (TaggedString *name)
{
store_localvar(name, 0);
lua_state->currState->nlocalvar++;
}
/*
** dotted variables <a.x> must be stored like regular indexed vars <a["x"]>
*/
static vardesc var2store (vardesc var)
{
if (isdot(var)) {
code_constant(dotindex(var));
var = 0;
}
return var;
}
static void add_varbuffer (vardesc var, int n)
{
if (n >= MAXVAR)
luaY_error("variable buffer overflow " MES_LIM(SMAXVAR));
lua_state->currState->varbuffer[n] = var2store(var);
}
static int aux_localname (TaggedString *n, FuncState *st)
{
int i;
for (i=st->nlocalvar-1; i >= 0; i--)
if (n == st->localvar[i]) return i; /* local var index */
return -1; /* not found */
}
static vardesc singlevar (TaggedString *n, FuncState *st)
{
int i = aux_localname(n, st);
if (i == -1) { /* check shadowing */
int l;
for (l=1; l<=(st-lua_state->mainState); l++)
if (aux_localname(n, st-l) >= 0)
luaY_syntaxerror("cannot access a variable in outer scope", n->str);
return string_constant(n, st)+MINGLOBAL; /* global value */
}
else return i+1; /* local value */
}
static int indexupvalue (TaggedString *n)
{
vardesc v = singlevar(n, lua_state->currState-1);
int i;
for (i=0; i<lua_state->currState->nupvalues; i++) {
if (lua_state->currState->upvalues[i] == v)
return i;
}
/* new one */
if (++(lua_state->currState->nupvalues) > MAXUPVALUES)
luaY_error("too many upvalues in a single function " MES_LIM(SMAXUPVALUES));
lua_state->currState->upvalues[i] = v; /* i = lua_state->currState->nupvalues - 1 */
return i;
}
static void pushupvalue (TaggedString *n)
{
int i;
if (lua_state->currState == lua_state->mainState)
luaY_error("cannot access upvalue in main");
if (aux_localname(n, lua_state->currState) >= 0)
luaY_syntaxerror("cannot access an upvalue in current scope", n->str);
i = indexupvalue(n);
code_oparg(PUSHUPVALUE, 2, i, 1);
}
void luaY_codedebugline (int32 line)
{
if (lua_debug && line != lua_state->lexstate->lastline) {
code_oparg(SETLINE, 0, line, 0);
lua_state->lexstate->lastline = line;
}
}
static void adjuststack (int n)
{
if (n > 0)
code_oparg(POP, 2, n-1, -n);
else if (n < 0)
code_oparg(PUSHNIL, 1, (-n)-1, -n);
}
static long adjust_functioncall (long exp, int nresults)
{
if (exp <= 0)
return -exp; /* exp is -list length */
else {
int temp = lua_state->currState->f->code[exp];
int nparams = lua_state->currState->f->code[exp-1];
exp += fix_opcode(exp-2, CALLFUNC, 2, nresults);
lua_state->currState->f->code[exp] = nparams;
if (nresults != MULT_RET)
deltastack(nresults);
deltastack(-(nparams+1));
return temp+nresults;
}
}
static void adjust_mult_assign (int vars, long exps)
{
if (exps > 0) { /* must correct function call */
int diff = lua_state->currState->f->code[exps] - vars;
if (diff < 0)
adjust_functioncall(exps, -diff);
else {
adjust_functioncall(exps, 0);
adjuststack(diff);
}
}
else adjuststack((-exps)-vars);
}
static void code_args (int nparams, int dots)
{
lua_state->currState->nlocalvar += nparams; /* "self" may already be there */
nparams = lua_state->currState->nlocalvar;
if (!dots) {
lua_state->currState->f->code[1] = nparams; /* fill-in arg information */
deltastack(nparams);
}
else {
lua_state->currState->f->code[1] = nparams+ZEROVARARG;
deltastack(nparams+1);
add_localvar(luaS_new("arg"));
}
}
static void lua_pushvar (vardesc var)
{
if (isglobal(var))
code_oparg(GETGLOBAL, 8, globalindex(var), 1);
else if (islocal(var))
code_oparg(PUSHLOCAL, 8, localindex(var), 1);
else if (isdot(var))
code_oparg(GETDOTTED, 8, dotindex(var), 0);
else
code_pop(GETTABLE);
}
static void storevar (vardesc var)
{
if (var == 0) /* indexed var */
code_opcode(SETTABLE0, -3);
else if (isglobal(var))
code_oparg(SETGLOBAL, 8, globalindex(var), -1);
else /* local var */
code_oparg(SETLOCAL, 8, localindex(var), -1);
}
/* returns how many elements are left as 'garbage' on the stack */
static int lua_codestore (int i, int left)
{
if (lua_state->currState->varbuffer[i] != 0 || /* global or local var or */
left+i == 0) { /* indexed var without values in between */
storevar(lua_state->currState->varbuffer[i]);
return left;
}
else { /* indexed var with values in between*/
code_oparg(SETTABLE, 0, left+i, -1);
return left+2; /* table/index are not popped, since they are not on top */
}
}
static int fix_jump (int pc, OpCode op, int n)
{
/* jump is relative to position following jump instruction */
return fix_opcode(pc, op, 0, n-(pc+JMPSIZE));
}
static void fix_upjmp (OpCode op, int pos)
{
int delta = lua_state->currState->pc+JMPSIZE - pos; /* jump is relative */
if (delta > 255) delta++;
code_oparg(op, 0, delta, 0);
}
static void codeIf (int thenAdd, int elseAdd)
{
int elseinit = elseAdd+JMPSIZE;
if (lua_state->currState->pc == elseinit) { /* no else part */
lua_state->currState->pc -= JMPSIZE;
elseinit = lua_state->currState->pc;
}
else
elseinit += fix_jump(elseAdd, JMP, lua_state->currState->pc);
fix_jump(thenAdd, IFFJMP, elseinit);
}
static void code_shortcircuit (int pc, OpCode op)
{
fix_jump(pc, op, lua_state->currState->pc);
}
static void codereturn (void)
{
code_oparg(RETCODE, 0, lua_state->currState->nlocalvar, 0);
lua_state->currState->stacksize = lua_state->currState->nlocalvar;
}
static void func_onstack (TProtoFunc *f)
{
int i;
int nupvalues = (lua_state->currState+1)->nupvalues;
int c = next_constant(lua_state->currState);
ttype(&lua_state->currState->f->consts[c]) = LUA_T_PROTO;
lua_state->currState->f->consts[c].value.tf = (lua_state->currState+1)->f;
if (nupvalues == 0)
code_constant(c);
else {
for (i=0; i<nupvalues; i++)
lua_pushvar((lua_state->currState+1)->upvalues[i]);
code_constant(c);
code_oparg(CLOSURE, 2, nupvalues, -nupvalues);
}
}
static void init_state (TaggedString *filename) {
TProtoFunc *f = luaF_newproto();
FuncState *fs = lua_state->currState;
fs->stacksize = 0;
fs->maxstacksize = 0;
fs->nlocalvar = 0;
fs->nupvalues = 0;
fs->f = f;
f->fileName = filename;
fs->pc = 0;
fs->maxcode = 0;
f->code = nullptr;
fs->maxconsts = 0;
if (lua_debug) {
fs->nvars = 0;
fs->maxvars = 0;
}
else
fs->maxvars = -1; /* flag no debug information */
code_byte(0); /* to be filled with stacksize */
code_byte(0); /* to be filled with arg information */
lua_state->lexstate->lastline = 0; /* invalidate it */
}
static void init_func() {
if (lua_state->currState-lua_state->mainState >= MAXSTATES-1)
luaY_error("too many nested functions " MES_LIM(SMAXSTATES));
lua_state->currState++;
init_state(lua_state->mainState->f->fileName);
luaY_codedebugline(lua_state->lexstate->linenumber);
lua_state->currState->f->lineDefined = lua_state->lexstate->linenumber;
}
static TProtoFunc *close_func() {
TProtoFunc *f = lua_state->currState->f;
code_neutralop(ENDCODE);
f->code[0] = lua_state->currState->maxstacksize;
f->code = luaM_reallocvector(f->code, lua_state->currState->pc, byte);
f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject);
if (lua_state->currState->maxvars != -1) { /* debug information? */
luaI_registerlocalvar(nullptr, -1); /* flag end of vector */
f->locvars = luaM_reallocvector(f->locvars, lua_state->currState->nvars, LocVar);
}
lua_state->currState--;
return f;
}
/*
** Parse Lua code.
*/
TProtoFunc *luaY_parser (ZIO *z) {
struct LexState lexstate;
FuncState state[MAXSTATES];
lua_state->currState = lua_state->mainState = &state[0];
lua_state->lexstate = &lexstate;
luaX_setinput(z);
init_state(luaS_new(zname(z)));
if (luaY_parse())
lua_error("parse error");
return close_func();
}
typedef union {
int vInt;
float vReal;
char *pChar;
long vLong;
TaggedString *pTStr;
TProtoFunc *pFunc;
} YYSTYPE;
#define YYFINAL 181
#define YYFLAG -32768
#define YYNTBASE 49
#define YYTRANSLATE(x) ((unsigned)(x) <= 284 ? yytranslate[x] : 93)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 43, 2, 2, 41,
42, 32, 30, 48, 31, 39, 33, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 40, 37, 26,
38, 25, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
44, 2, 45, 36, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 46, 2, 47, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 27,
28, 29, 34, 35
};
static const short yyr1[] = { 0,
49, 50, 50, 51, 51, 52, 52, 52, 52, 52,
52, 52, 52, 54, 53, 55, 55, 55, 56, 57,
58, 59, 59, 59, 60, 60, 61, 62, 63, 64,
65, 66, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 68, 67, 67, 67, 69, 70, 70, 70,
71, 71, 71, 72, 73, 74, 75, 75, 76, 76,
76, 77, 77, 78, 79, 78, 80, 80, 80, 80,
81, 81, 82, 82, 82, 83, 83, 84, 85, 86,
86, 87, 88, 88, 89, 89, 90, 90, 91, 91,
92, 92
};
static const short yyr2[] = { 0,
2, 0, 3, 0, 1, 7, 3, 6, 5, 3,
1, 3, 3, 0, 2, 1, 3, 3, 1, 1,
5, 0, 2, 6, 0, 3, 0, 0, 1, 1,
2, 1, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 2, 2, 1, 1, 1,
1, 1, 0, 3, 4, 4, 1, 1, 2, 1,
1, 4, 3, 1, 4, 2, 1, 3, 3, 1,
1, 0, 1, 1, 0, 4, 0, 1, 1, 3,
1, 3, 0, 1, 1, 0, 1, 2, 2, 1,
3, 3, 3, 1, 1, 3, 1, 3, 1, 3,
0, 2
};
static const short yydefact[] = { 2,
25, 0, 27, 14, 27, 72, 0, 0, 64, 0,
4, 1, 67, 57, 58, 61, 11, 0, 0, 52,
53, 50, 51, 0, 0, 0, 28, 0, 28, 32,
48, 58, 49, 60, 0, 0, 2, 14, 0, 74,
4, 73, 99, 101, 0, 0, 19, 59, 5, 3,
0, 0, 0, 71, 72, 70, 66, 0, 0, 0,
46, 47, 32, 30, 83, 14, 28, 28, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29, 31, 0, 7, 15, 0, 26, 75, 0, 0,
12, 77, 13, 0, 0, 63, 68, 0, 0, 10,
58, 54, 33, 64, 0, 94, 95, 0, 81, 84,
85, 86, 90, 0, 86, 28, 0, 0, 34, 37,
36, 35, 38, 39, 45, 40, 41, 42, 43, 44,
14, 0, 0, 102, 100, 78, 0, 79, 20, 17,
18, 62, 69, 0, 65, 83, 87, 88, 0, 87,
89, 22, 55, 56, 0, 9, 76, 2, 0, 93,
82, 91, 92, 96, 14, 0, 0, 8, 0, 80,
23, 0, 6, 21, 14, 28, 22, 24, 0, 0,
0
};
static const short yydefgoto[] = { 85,
1, 50, 11, 36, 37, 45, 46, 106, 93, 167,
12, 35, 81, 82, 65, 28, 39, 30, 60, 13,
31, 32, 16, 33, 34, 18, 57, 41, 42, 133,
137, 108, 109, 148, 110, 111, 112, 113, 114, 115,
19, 44, 91
};
static const short yypact[] = {-32768,
147, 94,-32768,-32768,-32768, 94, 19, 34,-32768, 39,
-19,-32768, 2,-32768, -29,-32768, -10, -6, -27,-32768,
-32768,-32768,-32768, 94, 94, 94,-32768, 14, 196,-32768,
4,-32768,-32768,-32768, 94, 49,-32768,-32768, 196, 212,
-19, 18,-32768, -22, 38, 21, 40,-32768,-32768,-32768,
68, 71, 94,-32768, 94,-32768,-32768, 94, 9, 38,
57, 57, 62,-32768, 76,-32768,-32768,-32768, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
-32768,-32768, 96,-32768,-32768, 106,-32768,-32768, 94, 102,
-32768, -4,-32768, 109, 109,-32768,-32768, 146, 91, 18,
-21,-32768,-32768, 98, 94,-32768, 196, 92, 105,-32768,
-32768, 90,-32768, 107, 95,-32768, 94, 94, 53, 53,
53, 53, 53, 53, 69, 23, 23, 57, 57, 57,
-32768, 94, 94, 18,-32768,-32768, 104, 112,-32768,-32768,
-32768,-32768,-32768, 171,-32768, 76, -7,-32768, 94, 94,
-32768, 101, 226, 226, 136, 196, 212,-32768, 30,-32768,
-32768,-32768, 196, 196,-32768, 94, 137,-32768, 140,-32768,
-32768, 148,-32768,-32768,-32768,-32768, 101,-32768, 155, 165,
-32768
};
static const short yypgoto[] = { 1,
-32768, 139,-32768, -34,-32768,-32768,-32768, 29, 121, 7,
-32768, 178, -25, 59,-32768, -32, -2, -1,-32768,-32768,
5, 6, 177, 168, 186,-32768,-32768, 133, -50,-32768,
-32768,-32768, 43, 93,-32768,-32768,-32768, 58,-32768,-32768,
-32768, 114,-32768
};
#define YYLAST 262
static const short yytable[] = { 29,
179, 64, 83, 86, 40, 14, 15, 100, -97, -60,
58, 139, 136, 54, 43, 89, -98, 49, -97, 66,
59, 61, 62, -57, 63, 90, -98, 9, -60, -60,
-60, 116, 29, -60, 55, -60, 105, 43, 134, 27,
51, 52, -57, -57, -57, 53, 170, -57, 135, -57,
98, 10, 9, 40, 78, 79, 40, 48, 80, 94,
95, 84, 107, 14, 101, 88, 119, 120, 121, 122,
123, 124, 125, 126, 127, 128, 129, 130, 92, 20,
-16, 75, 76, 77, 78, 79, 96, 40, 80, 97,
152, 21, 80, 22, 104, 23, 155, 20, 76, 77,
78, 79, 144, 103, 80, 131, 24, 165, 166, 21,
25, 22, 9, 23, 153, 154, 26, 132, 10, 105,
135, 27, 140, 141, 24, 117, 118, 139, 25, 156,
171, 157, 143, 172, 26, -20, 10, 147, 145, 27,
176, 146, 150, 107, 149, 158, 163, 164, 168, 173,
177, 2, 174, 175, 180, 3, 4, 5, 169, 159,
6, 7, 8, 29, 181, 9, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 87,
102, 80, 38, 178, 47, 56, 17, 99, 161, 10,
142, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 162, 138, 80, 151, 0, 0,
0, 0, 0, 0, 0, 160, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 0,
0, 80, -32, -32, -32, -32, -32, -32, -32, -32,
-32, -32, -32, -32, -32, 0, 0, -32, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 0,
0, 80
};
static const short yycheck[] = { 2,
0, 27, 35, 38, 6, 1, 1, 58, 38, 20,
38, 19, 17, 20, 19, 38, 38, 37, 48, 6,
48, 24, 25, 20, 26, 48, 48, 19, 39, 40,
41, 66, 35, 44, 41, 46, 44, 19, 89, 46,
39, 40, 39, 40, 41, 44, 17, 44, 19, 46,
53, 43, 19, 55, 32, 33, 58, 19, 36, 39,
40, 13, 65, 59, 59, 48, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 41, 4,
41, 29, 30, 31, 32, 33, 19, 89, 36, 19,
116, 16, 36, 18, 19, 20, 131, 4, 30, 31,
32, 33, 105, 42, 36, 10, 31, 7, 8, 16,
35, 18, 19, 20, 117, 118, 41, 12, 43, 44,
19, 46, 94, 95, 31, 67, 68, 19, 35, 132,
165, 133, 42, 166, 41, 38, 43, 48, 47, 46,
175, 37, 48, 146, 38, 42, 149, 150, 13, 13,
176, 5, 13, 6, 0, 9, 10, 11, 158, 48,
14, 15, 16, 166, 0, 19, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 41,
60, 36, 5, 177, 8, 18, 1, 55, 146, 43,
45, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 147, 92, 36, 115, -1, -1,
-1, -1, -1, -1, -1, 45, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, -1,
-1, 36, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, -1, -1, 36, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, -1,
-1, 36
};
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(token, value) \
do \
if (yychar == YYEMPTY && yylen == 1) { \
yychar = (token), yylval = (value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} else { yyerror ("syntax error: cannot back up"); YYERROR; } \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#define YYLEX yylex(&yylval)
int32 luaY_lex(YYSTYPE *l);
/* If nonreentrant, generate the variables here */
#define YYINITDEPTH 1000
int yyparse() {
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
short yyssa[YYINITDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
#define YYPOPSTACK (yyvsp--, yyssp--)
int yystacksize = YYINITDEPTH;
int yychar;
YYSTYPE yylval;
int yynerrs;
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss - 1;
yyvsp = yyvs;
/* Push a new state, which is found in yystate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
yynewstate:
*++yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1) {
yyerror("parser stack overflow");
return 2;
}
goto yybackup;
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
yychar = YYLEX;
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) { /* This means end of input. */
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
} else {
yychar1 = YYTRANSLATE(yychar);
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0) {
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
} else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
/* count tokens shifted since error; after three, turn off error status. */
if (yyerrstatus)
yyerrstatus--;
yystate = yyn;
goto yynewstate;
/* Do the default action for the current state. */
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
/* Do a reduction. yyn is the number of a rule to reduce with. */
yyreduce:
yylen = yyr2[yyn];
if (yylen > 0)
yyval = yyvsp[1 - yylen]; /* implement default value of the action */
switch (yyn) {
case 6:
{ codeIf(yyvsp[-5].vInt, yyvsp[-2].vInt); ;
break;}
case 8:
{{
FuncState *fs = lua_state->currState;
int expsize = yyvsp[-3].vInt-yyvsp[-4].vInt;
int newpos = yyvsp[-4].vInt+JMPSIZE;
check_pc(expsize);
memcpy(fs->f->code+fs->pc, fs->f->code+yyvsp[-4].vInt, expsize);
luaO_memdown(fs->f->code+yyvsp[-4].vInt, fs->f->code+yyvsp[-3].vInt, fs->pc-yyvsp[-4].vInt);
newpos += fix_jump(yyvsp[-4].vInt, JMP, fs->pc-expsize);
fix_upjmp(IFTUPJMP, newpos);
};
break;}
case 9:
{
fix_upjmp(IFFUPJMP, yyvsp[-3].vInt);
deltastack(-1); /* pops condition */
;
break;}
case 10:
{{
int i;
int left = 0;
adjust_mult_assign(yyvsp[-2].vInt, yyvsp[0].vLong);
for (i=yyvsp[-2].vInt-1; i>=0; i--)
left = lua_codestore(i, left);
adjuststack(left); /* remove eventual 'garbage' left on stack */
};
break;}
case 11:
{ adjust_functioncall(yyvsp[0].vLong, 0); ;
break;}
case 12:
{
lua_state->currState->nlocalvar += yyvsp[-1].vInt;
adjust_mult_assign(yyvsp[-1].vInt, yyvsp[0].vInt);
;
break;}
case 13:
{ storevar(yyvsp[-1].vLong); ;
break;}
case 14:
{yyval.vInt = lua_state->currState->nlocalvar;;
break;}
case 15:
{
adjuststack(lua_state->currState->nlocalvar - yyvsp[-1].vInt);
for (; lua_state->currState->nlocalvar > yyvsp[-1].vInt; lua_state->currState->nlocalvar--)
luaI_unregisterlocalvar(lua_state->lexstate->linenumber);
;
break;}
case 16:
{ yyval.vLong = yyvsp[0].vLong; init_func(); ;
break;}
case 17:
{
yyval.vLong = 0; /* flag indexed variable */
init_func();
;
break;}
case 18:
{
yyval.vLong = 0; /* flag indexed variable */
init_func();
add_localvar(luaS_new("self"));
;
break;}
case 19:
{ lua_pushvar(yyvsp[0].vLong); ;
break;}
case 20:
{ code_string(yyvsp[0].pTStr); ;
break;}
case 21:
{ func_onstack(close_func()); ;
break;}
case 24:
{ codeIf(yyvsp[-4].vInt, yyvsp[-1].vInt); ;
break;}
case 26:
{
adjust_functioncall(yyvsp[-1].vLong, MULT_RET);
codereturn();
;
break;}
case 27:
{ yyval.vInt = lua_state->currState->pc; ;
break;}
case 28:
{ yyval.vInt = lua_state->currState->pc;
check_pc(JMPSIZE);
lua_state->currState->pc += JMPSIZE; /* open space */
;
break;}
case 29:
{ yyval.vInt = yyvsp[0].vInt; deltastack(-1); /* pop condition */ ;
break;}
case 30:
{ yyval.vInt = yyvsp[0].vInt; deltastack(1); /* push a value */ ;
break;}
case 31:
{ yyval.vInt = yyvsp[0].vInt; ;
break;}
case 32:
{ adjust_functioncall(yyvsp[0].vLong, 1); ;
break;}
case 33:
{ yyval.vLong = yyvsp[-1].vLong; ;
break;}
case 34:
{ code_binop(EQOP); yyval.vLong = 0; ;
break;}
case 35:
{ code_binop(LTOP); yyval.vLong = 0; ;
break;}
case 36:
{ code_binop(GTOP); yyval.vLong = 0; ;
break;}
case 37:
{ code_binop(NEQOP); yyval.vLong = 0; ;
break;}
case 38:
{ code_binop(LEOP); yyval.vLong = 0; ;
break;}
case 39:
{ code_binop(GEOP); yyval.vLong = 0; ;
break;}
case 40:
{ code_binop(ADDOP); yyval.vLong = 0; ;
break;}
case 41:
{ code_binop(SUBOP); yyval.vLong = 0; ;
break;}
case 42:
{ code_binop(MULTOP); yyval.vLong = 0; ;
break;}
case 43:
{ code_binop(DIVOP); yyval.vLong = 0; ;
break;}
case 44:
{ code_binop(POWOP); yyval.vLong = 0; ;
break;}
case 45:
{ code_binop(CONCOP); yyval.vLong = 0; ;
break;}
case 46:
{ code_unop(MINUSOP); yyval.vLong = 0;;
break;}
case 47:
{ code_unop(NOTOP); yyval.vLong = 0;;
break;}
case 48:
{ yyval.vLong = yyvsp[0].vLong; /* simple expressions */ ;
break;}
case 49:
{ yyval.vLong = 0; ;
break;}
case 50:
{ code_number(yyvsp[0].vReal); yyval.vLong = 0; ;
break;}
case 51:
{ code_string(yyvsp[0].pTStr); yyval.vLong = 0; ;
break;}
case 52:
{ adjuststack(-1); yyval.vLong = 0; ;
break;}
case 53:
{ init_func(); ;
break;}
case 54:
{ yyval.vLong = 0; ;
break;}
case 55:
{ code_shortcircuit(yyvsp[-1].vInt, ONFJMP); yyval.vLong = 0; ;
break;}
case 56:
{ code_shortcircuit(yyvsp[-1].vInt, ONTJMP); yyval.vLong = 0; ;
break;}
case 57:
{ adjust_functioncall(yyvsp[0].vLong, 1); ;
break;}
case 58:
{ lua_pushvar(yyvsp[0].vLong); yyval.vLong = 0; ;
break;}
case 59:
{ pushupvalue(yyvsp[0].pTStr); yyval.vLong = 0; ;
break;}
case 60:
{ yyval.vLong = yyvsp[0].vLong; ;
break;}
case 61:
{ yyval.vLong = yyvsp[0].vLong; ;
break;}
case 62:
{ yyval.vLong = 0; ;
break;}
case 63:
{ yyval.vLong = (-string_constant(yyvsp[0].pTStr, lua_state->currState))-1; ;
break;}
case 64:
{ yyval.vLong = singlevar(yyvsp[0].pTStr, lua_state->currState); ;
break;}
case 65:
{ fix_opcode(yyvsp[-2].vInt, CREATEARRAY, 2, yyvsp[-1].vInt); ;
break;}
case 66:
{
code_byte(0); /* save space for opcode */
code_byte(yyvsp[-1].vInt+yyvsp[0].vInt); /* number of parameters */
yyval.vLong = lua_state->currState->pc;
code_byte(0); /* must be adjusted by other rules */
;
break;}
case 67:
{ yyval.vInt = 0; ;
break;}
case 68:
{
code_oparg(PUSHSELF, 8, string_constant(yyvsp[0].pTStr, lua_state->currState), 1);
yyval.vInt = 1;
;
break;}
case 69:
{ yyval.vInt = adjust_functioncall(yyvsp[-1].vLong, 1); ;
break;}
case 70:
{ yyval.vInt = 1; ;
break;}
case 71:
{ code_string(yyvsp[0].pTStr); yyval.vInt = 1; ;
break;}
case 72:
{ yyval.vLong = 0; ;
break;}
case 73:
{ yyval.vLong = yyvsp[0].vLong; ;
break;}
case 74:
{ if (yyvsp[0].vLong != 0) yyval.vLong = yyvsp[0].vLong; else yyval.vLong = -1; ;
break;}
case 75:
{ yyval.vLong = adjust_functioncall(yyvsp[-1].vLong, 1); ;
break;}
case 76:
{
if (yyvsp[0].vLong == 0) yyval.vLong = -(yyvsp[-1].vLong + 1); /* -length */
else {
lua_state->currState->f->code[yyvsp[0].vLong] = yyvsp[-1].vLong; /* store list length */
yyval.vLong = yyvsp[0].vLong;
}
;
break;}
case 77:
{ code_args(0, 0); ;
break;}
case 78:
{ code_args(0, 1); ;
break;}
case 79:
{ code_args(yyvsp[0].vInt, 0); ;
break;}
case 80:
{ code_args(yyvsp[-2].vInt, 1); ;
break;}
case 81:
{ yyval.vInt = abs(yyvsp[0].vInt); ;
break;}
case 82:
{
if (yyvsp[-2].vInt*yyvsp[0].vInt > 0) /* repeated parts? */
luaY_error("invalid constructor syntax");
yyval.vInt = abs(yyvsp[-2].vInt)+abs(yyvsp[0].vInt);
;
break;}
case 83:
{ yyval.vInt = 0; ;
break;}
case 84:
{ yyval.vInt = yyvsp[0].vInt; ;
break;}
case 85:
{ yyval.vInt = yyvsp[0].vInt; ;
break;}
case 88:
{
flush_record(yyvsp[-1].vInt%RFIELDS_PER_FLUSH);
yyval.vInt = -yyvsp[-1].vInt; /* negative signals a "record" part */
;
break;}
case 89:
{
flush_list(yyvsp[-1].vInt/LFIELDS_PER_FLUSH, yyvsp[-1].vInt%LFIELDS_PER_FLUSH);
yyval.vInt = yyvsp[-1].vInt;
;
break;}
case 90:
{yyval.vInt=1;;
break;}
case 91:
{
yyval.vInt=yyvsp[-2].vInt+1;
if (yyval.vInt%RFIELDS_PER_FLUSH == 0)
flush_record(RFIELDS_PER_FLUSH);
;
break;}
case 95:
{yyval.vInt=1;;
break;}
case 96:
{
yyval.vInt=yyvsp[-2].vInt+1;
if (yyval.vInt%LFIELDS_PER_FLUSH == 0)
flush_list(yyval.vInt/LFIELDS_PER_FLUSH - 1, LFIELDS_PER_FLUSH);
;
break;}
case 97:
{ yyval.vInt = 1; add_varbuffer(yyvsp[0].vLong, 0); ;
break;}
case 98:
{ add_varbuffer(yyvsp[0].vLong, yyvsp[-2].vInt); yyval.vInt = yyvsp[-2].vInt+1; ;
break;}
case 99:
{store_localvar(yyvsp[0].pTStr, 0); yyval.vInt = 1;;
break;}
case 100:
{ store_localvar(yyvsp[0].pTStr, yyvsp[-2].vInt); yyval.vInt = yyvsp[-2].vInt+1; ;
break;}
case 101:
{ yyval.vInt = 0; ;
break;}
case 102:
{ yyval.vInt = yyvsp[0].vLong; ;
break;}
}
/* the action file gets copied in in place of this dollarsign */
yyvsp -= yylen;
yyssp -= yylen;
*++yyvsp = yyval;
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
yyerrlab: /* here on detecting error */
if (! yyerrstatus) {
/* If not already recovering from an error, report this error. */
++yynerrs;
yyerror("parse error");
}
goto yyerrlab1;
yyerrlab1: /* here on error raised explicitly by an action */
if (yyerrstatus == 3) {
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
yyerrdefault: /* current state does not do anything special for the error token. */
yyerrpop: /* pop the current state because it cannot handle the error token */
if (yyssp == yyss)
YYABORT;
yyvsp--;
yystate = *--yyssp;
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0) {
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
} else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
*++yyvsp = yylval;
yystate = yyn;
goto yynewstate;
}
} // end of namespace Grim
|