y_tab.c 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. # line 2 "lua.stx"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include "opcode.h"
  6. #include "hash.h"
  7. #include "inout.h"
  8. #include "table.h"
  9. #include "lua.h"
  10. #ifndef ALIGNMENT
  11. #define ALIGNMENT (sizeof(void *))
  12. #endif
  13. #ifndef MAXCODE
  14. #define MAXCODE 1024
  15. #endif
  16. static long buffer[MAXCODE];
  17. static Byte *code = (Byte *)buffer;
  18. static long mainbuffer[MAXCODE];
  19. static Byte *maincode = (Byte *)mainbuffer;
  20. static Byte *basepc;
  21. static Byte *pc;
  22. #define MAXVAR 32
  23. static long varbuffer[MAXVAR];
  24. static Byte nvarbuffer=0; /* number of variables at a list */
  25. static Word localvar[STACKGAP];
  26. static Byte nlocalvar=0; /* number of local variables */
  27. static int ntemp; /* number of temporary var into stack */
  28. static int err; /* flag to indicate error */
  29. /* Internal functions */
  30. #define align(n) align_n(sizeof(n))
  31. static void code_byte (Byte c)
  32. {
  33. if (pc-basepc>MAXCODE-1)
  34. {
  35. lua_error ("code buffer overflow");
  36. err = 1;
  37. }
  38. *pc++ = c;
  39. }
  40. static void code_word (Word n)
  41. {
  42. if (pc-basepc>MAXCODE-sizeof(Word))
  43. {
  44. lua_error ("code buffer overflow");
  45. err = 1;
  46. }
  47. *((Word *)pc) = n;
  48. pc += sizeof(Word);
  49. }
  50. static void code_float (float n)
  51. {
  52. if (pc-basepc>MAXCODE-sizeof(float))
  53. {
  54. lua_error ("code buffer overflow");
  55. err = 1;
  56. }
  57. *((float *)pc) = n;
  58. pc += sizeof(float);
  59. }
  60. static void incr_ntemp (void)
  61. {
  62. if (ntemp+nlocalvar+MAXVAR+1 < STACKGAP)
  63. ntemp++;
  64. else
  65. {
  66. lua_error ("stack overflow");
  67. err = 1;
  68. }
  69. }
  70. static void incr_nlocalvar (void)
  71. {
  72. if (ntemp+nlocalvar+MAXVAR+1 < STACKGAP)
  73. nlocalvar++;
  74. else
  75. {
  76. lua_error ("too many local variables or expression too complicate");
  77. err = 1;
  78. }
  79. }
  80. static void incr_nvarbuffer (void)
  81. {
  82. if (nvarbuffer < MAXVAR-1)
  83. nvarbuffer++;
  84. else
  85. {
  86. lua_error ("variable buffer overflow");
  87. err = 1;
  88. }
  89. }
  90. static void align_n (unsigned size)
  91. {
  92. if (size > ALIGNMENT) size = ALIGNMENT;
  93. while (((pc+1-code)%size) != 0) /* +1 to include BYTECODE */
  94. code_byte (NOP);
  95. }
  96. static void code_number (float f)
  97. { int i = f;
  98. if (f == i) /* f has an integer value */
  99. {
  100. if (i <= 2) code_byte(PUSH0 + i);
  101. else if (i <= 255)
  102. {
  103. code_byte(PUSHBYTE);
  104. code_byte(i);
  105. }
  106. else
  107. {
  108. align(Word);
  109. code_byte(PUSHWORD);
  110. code_word(i);
  111. }
  112. }
  113. else
  114. {
  115. align(float);
  116. code_byte(PUSHFLOAT);
  117. code_float(f);
  118. }
  119. incr_ntemp();
  120. }
  121. # line 140 "lua.stx"
  122. typedef union
  123. {
  124. int vInt;
  125. long vLong;
  126. float vFloat;
  127. Word vWord;
  128. Byte *pByte;
  129. } YYSTYPE;
  130. # define NIL 257
  131. # define IF 258
  132. # define THEN 259
  133. # define ELSE 260
  134. # define ELSEIF 261
  135. # define WHILE 262
  136. # define DO 263
  137. # define REPEAT 264
  138. # define UNTIL 265
  139. # define END 266
  140. # define RETURN 267
  141. # define LOCAL 268
  142. # define NUMBER 269
  143. # define FUNCTION 270
  144. # define NAME 271
  145. # define STRING 272
  146. # define DEBUG 273
  147. # define NOT 274
  148. # define AND 275
  149. # define OR 276
  150. # define NE 277
  151. # define LE 278
  152. # define GE 279
  153. # define CONC 280
  154. # define UNARY 281
  155. #define yyclearin yychar = -1
  156. #define yyerrok yyerrflag = 0
  157. extern int yychar;
  158. extern int yyerrflag;
  159. #ifndef YYMAXDEPTH
  160. #define YYMAXDEPTH 150
  161. #endif
  162. YYSTYPE yylval, yyval;
  163. # define YYERRCODE 256
  164. # line 530 "lua.stx"
  165. /*
  166. ** Search a local name and if find return its index. If do not find return -1
  167. */
  168. static int lua_localname (Word n)
  169. {
  170. int i;
  171. for (i=nlocalvar-1; i >= 0; i--)
  172. if (n == localvar[i]) return i; /* local var */
  173. return -1; /* global var */
  174. }
  175. /*
  176. ** Push a variable given a number. If number is positive, push global variable
  177. ** indexed by (number -1). If negative, push local indexed by ABS(number)-1.
  178. ** Otherwise, if zero, push indexed variable (record).
  179. */
  180. static void lua_pushvar (long number)
  181. {
  182. if (number > 0) /* global var */
  183. {
  184. align(Word);
  185. code_byte(PUSHGLOBAL);
  186. code_word(number-1);
  187. incr_ntemp();
  188. }
  189. else if (number < 0) /* local var */
  190. {
  191. number = (-number) - 1;
  192. if (number < 10) code_byte(PUSHLOCAL0 + number);
  193. else
  194. {
  195. code_byte(PUSHLOCAL);
  196. code_byte(number);
  197. }
  198. incr_ntemp();
  199. }
  200. else
  201. {
  202. code_byte(PUSHINDEXED);
  203. ntemp--;
  204. }
  205. }
  206. static void lua_codeadjust (int n)
  207. {
  208. code_byte(ADJUST);
  209. code_byte(n + nlocalvar);
  210. }
  211. static void lua_codestore (int i)
  212. {
  213. if (varbuffer[i] > 0) /* global var */
  214. {
  215. align(Word);
  216. code_byte(STOREGLOBAL);
  217. code_word(varbuffer[i]-1);
  218. }
  219. else if (varbuffer[i] < 0) /* local var */
  220. {
  221. int number = (-varbuffer[i]) - 1;
  222. if (number < 10) code_byte(STORELOCAL0 + number);
  223. else
  224. {
  225. code_byte(STORELOCAL);
  226. code_byte(number);
  227. }
  228. }
  229. else /* indexed var */
  230. {
  231. int j;
  232. int upper=0; /* number of indexed variables upper */
  233. int param; /* number of itens until indexed expression */
  234. for (j=i+1; j <nvarbuffer; j++)
  235. if (varbuffer[j] == 0) upper++;
  236. param = upper*2 + i;
  237. if (param == 0)
  238. code_byte(STOREINDEXED0);
  239. else
  240. {
  241. code_byte(STOREINDEXED);
  242. code_byte(param);
  243. }
  244. }
  245. }
  246. void yyerror (char *s)
  247. {
  248. static char msg[256];
  249. sprintf (msg,"%s near \"%s\" at line %d in file \"%s\"",
  250. s, lua_lasttext (), lua_linenumber, lua_filename());
  251. lua_error (msg);
  252. err = 1;
  253. }
  254. int yywrap (void)
  255. {
  256. return 1;
  257. }
  258. /*
  259. ** Parse LUA code and execute global statement.
  260. ** Return 0 on success or 1 on error.
  261. */
  262. int lua_parse (void)
  263. {
  264. Byte *initcode = maincode;
  265. err = 0;
  266. if (yyparse () || (err==1)) return 1;
  267. *maincode++ = HALT;
  268. if (lua_execute (initcode)) return 1;
  269. maincode = initcode;
  270. return 0;
  271. }
  272. #if 0
  273. static void PrintCode (void)
  274. {
  275. Byte *p = code;
  276. printf ("\n\nCODE\n");
  277. while (p != pc)
  278. {
  279. switch ((OpCode)*p)
  280. {
  281. case NOP: printf ("%d NOP\n", (p++)-code); break;
  282. case PUSHNIL: printf ("%d PUSHNIL\n", (p++)-code); break;
  283. case PUSH0: case PUSH1: case PUSH2:
  284. printf ("%d PUSH%c\n", p-code, *p-PUSH0+'0');
  285. p++;
  286. break;
  287. case PUSHBYTE:
  288. printf ("%d PUSHBYTE %d\n", p-code, *(++p));
  289. p++;
  290. break;
  291. case PUSHWORD:
  292. printf ("%d PUSHWORD %d\n", p-code, *((Word *)(p+1)));
  293. p += 1 + sizeof(Word);
  294. break;
  295. case PUSHFLOAT:
  296. printf ("%d PUSHFLOAT %f\n", p-code, *((float *)(p+1)));
  297. p += 1 + sizeof(float);
  298. break;
  299. case PUSHSTRING:
  300. printf ("%d PUSHSTRING %d\n", p-code, *((Word *)(p+1)));
  301. p += 1 + sizeof(Word);
  302. break;
  303. case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2: case PUSHLOCAL3:
  304. case PUSHLOCAL4: case PUSHLOCAL5: case PUSHLOCAL6: case PUSHLOCAL7:
  305. case PUSHLOCAL8: case PUSHLOCAL9:
  306. printf ("%d PUSHLOCAL%c\n", p-code, *p-PUSHLOCAL0+'0');
  307. p++;
  308. break;
  309. case PUSHLOCAL: printf ("%d PUSHLOCAL %d\n", p-code, *(++p));
  310. p++;
  311. break;
  312. case PUSHGLOBAL:
  313. printf ("%d PUSHGLOBAL %d\n", p-code, *((Word *)(p+1)));
  314. p += 1 + sizeof(Word);
  315. break;
  316. case PUSHINDEXED: printf ("%d PUSHINDEXED\n", (p++)-code); break;
  317. case PUSHMARK: printf ("%d PUSHMARK\n", (p++)-code); break;
  318. case PUSHOBJECT: printf ("%d PUSHOBJECT\n", (p++)-code); break;
  319. case STORELOCAL0: case STORELOCAL1: case STORELOCAL2: case STORELOCAL3:
  320. case STORELOCAL4: case STORELOCAL5: case STORELOCAL6: case STORELOCAL7:
  321. case STORELOCAL8: case STORELOCAL9:
  322. printf ("%d STORELOCAL%c\n", p-code, *p-STORELOCAL0+'0');
  323. p++;
  324. break;
  325. case STORELOCAL:
  326. printf ("%d STORELOCAK %d\n", p-code, *(++p));
  327. p++;
  328. break;
  329. case STOREGLOBAL:
  330. printf ("%d STOREGLOBAL %d\n", p-code, *((Word *)(p+1)));
  331. p += 1 + sizeof(Word);
  332. break;
  333. case STOREINDEXED0: printf ("%d STOREINDEXED0\n", (p++)-code); break;
  334. case STOREINDEXED: printf ("%d STOREINDEXED %d\n", p-code, *(++p));
  335. p++;
  336. break;
  337. case STOREFIELD: printf ("%d STOREFIELD\n", (p++)-code); break;
  338. case ADJUST:
  339. printf ("%d ADJUST %d\n", p-code, *(++p));
  340. p++;
  341. break;
  342. case CREATEARRAY: printf ("%d CREATEARRAY\n", (p++)-code); break;
  343. case EQOP: printf ("%d EQOP\n", (p++)-code); break;
  344. case LTOP: printf ("%d LTOP\n", (p++)-code); break;
  345. case LEOP: printf ("%d LEOP\n", (p++)-code); break;
  346. case ADDOP: printf ("%d ADDOP\n", (p++)-code); break;
  347. case SUBOP: printf ("%d SUBOP\n", (p++)-code); break;
  348. case MULTOP: printf ("%d MULTOP\n", (p++)-code); break;
  349. case DIVOP: printf ("%d DIVOP\n", (p++)-code); break;
  350. case CONCOP: printf ("%d CONCOP\n", (p++)-code); break;
  351. case MINUSOP: printf ("%d MINUSOP\n", (p++)-code); break;
  352. case NOTOP: printf ("%d NOTOP\n", (p++)-code); break;
  353. case ONTJMP:
  354. printf ("%d ONTJMP %d\n", p-code, *((Word *)(p+1)));
  355. p += sizeof(Word) + 1;
  356. break;
  357. case ONFJMP:
  358. printf ("%d ONFJMP %d\n", p-code, *((Word *)(p+1)));
  359. p += sizeof(Word) + 1;
  360. break;
  361. case JMP:
  362. printf ("%d JMP %d\n", p-code, *((Word *)(p+1)));
  363. p += sizeof(Word) + 1;
  364. break;
  365. case UPJMP:
  366. printf ("%d UPJMP %d\n", p-code, *((Word *)(p+1)));
  367. p += sizeof(Word) + 1;
  368. break;
  369. case IFFJMP:
  370. printf ("%d IFFJMP %d\n", p-code, *((Word *)(p+1)));
  371. p += sizeof(Word) + 1;
  372. break;
  373. case IFFUPJMP:
  374. printf ("%d IFFUPJMP %d\n", p-code, *((Word *)(p+1)));
  375. p += sizeof(Word) + 1;
  376. break;
  377. case POP: printf ("%d POP\n", (p++)-code); break;
  378. case CALLFUNC: printf ("%d CALLFUNC\n", (p++)-code); break;
  379. case RETCODE:
  380. printf ("%d RETCODE %d\n", p-code, *(++p));
  381. p++;
  382. break;
  383. default: printf ("%d Cannot happen\n", (p++)-code); break;
  384. }
  385. }
  386. }
  387. #endif
  388. int yyexca[] ={
  389. -1, 1,
  390. 0, -1,
  391. -2, 2,
  392. -1, 19,
  393. 40, 65,
  394. 91, 95,
  395. 46, 97,
  396. -2, 92,
  397. -1, 29,
  398. 40, 65,
  399. 91, 95,
  400. 46, 97,
  401. -2, 51,
  402. -1, 70,
  403. 275, 33,
  404. 276, 33,
  405. 61, 33,
  406. 277, 33,
  407. 62, 33,
  408. 60, 33,
  409. 278, 33,
  410. 279, 33,
  411. 280, 33,
  412. 43, 33,
  413. 45, 33,
  414. 42, 33,
  415. 47, 33,
  416. -2, 68,
  417. -1, 71,
  418. 91, 95,
  419. 46, 97,
  420. -2, 93,
  421. -1, 102,
  422. 260, 27,
  423. 261, 27,
  424. 265, 27,
  425. 266, 27,
  426. 267, 27,
  427. -2, 11,
  428. -1, 117,
  429. 93, 85,
  430. -2, 87,
  431. -1, 122,
  432. 267, 30,
  433. -2, 29,
  434. -1, 145,
  435. 275, 33,
  436. 276, 33,
  437. 61, 33,
  438. 277, 33,
  439. 62, 33,
  440. 60, 33,
  441. 278, 33,
  442. 279, 33,
  443. 280, 33,
  444. 43, 33,
  445. 45, 33,
  446. 42, 33,
  447. 47, 33,
  448. -2, 70,
  449. };
  450. # define YYNPROD 105
  451. # define YYLAST 318
  452. int yyact[]={
  453. 54, 52, 136, 53, 13, 55, 54, 52, 14, 53,
  454. 15, 55, 5, 166, 18, 6, 129, 21, 47, 46,
  455. 48, 107, 104, 97, 47, 46, 48, 54, 52, 80,
  456. 53, 21, 55, 54, 52, 40, 53, 9, 55, 54,
  457. 52, 158, 53, 160, 55, 47, 46, 48, 159, 101,
  458. 81, 47, 46, 48, 10, 54, 52, 126, 53, 67,
  459. 55, 54, 52, 60, 53, 155, 55, 148, 149, 135,
  460. 147, 108, 150, 47, 46, 48, 73, 23, 75, 47,
  461. 46, 48, 7, 25, 38, 153, 26, 164, 27, 117,
  462. 61, 62, 74, 11, 76, 54, 24, 127, 65, 66,
  463. 55, 37, 154, 151, 103, 111, 72, 28, 93, 94,
  464. 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
  465. 92, 116, 59, 77, 54, 52, 118, 53, 99, 55,
  466. 110, 95, 64, 44, 70, 109, 29, 33, 105, 106,
  467. 42, 112, 41, 165, 139, 19, 17, 152, 79, 123,
  468. 43, 119, 20, 114, 113, 98, 63, 144, 143, 122,
  469. 68, 39, 36, 130, 35, 120, 12, 8, 102, 125,
  470. 128, 141, 78, 69, 70, 71, 142, 131, 132, 140,
  471. 22, 124, 4, 3, 2, 121, 96, 138, 146, 137,
  472. 134, 157, 133, 115, 16, 1, 0, 0, 0, 0,
  473. 0, 0, 0, 156, 0, 0, 0, 0, 161, 0,
  474. 0, 0, 0, 162, 0, 0, 0, 168, 0, 172,
  475. 145, 163, 171, 0, 174, 0, 0, 0, 169, 156,
  476. 167, 170, 173, 57, 58, 49, 50, 51, 56, 57,
  477. 58, 49, 50, 51, 56, 175, 0, 0, 100, 0,
  478. 45, 0, 0, 0, 0, 70, 0, 0, 0, 0,
  479. 57, 58, 49, 50, 51, 56, 57, 58, 49, 50,
  480. 51, 56, 0, 0, 0, 0, 0, 56, 0, 0,
  481. 0, 0, 0, 0, 0, 0, 0, 0, 57, 58,
  482. 49, 50, 51, 56, 0, 0, 49, 50, 51, 56,
  483. 32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  484. 0, 0, 30, 0, 21, 31, 0, 34 };
  485. int yypact[]={
  486. -1000, -258, -1000, -1000, -1000, -234, -1000, 34, -254, -1000,
  487. -1000, -1000, -1000, 43, -1000, -1000, 40, -1000, -236, -1000,
  488. -1000, -1000, 93, -9, -1000, 43, 43, 43, 92, -1000,
  489. -1000, -1000, -1000, -1000, 43, 43, -1000, 43, -240, 62,
  490. 31, -13, 48, 83, -242, -1000, 43, 43, 43, 43,
  491. 43, 43, 43, 43, 43, 43, 43, -1000, -1000, 90,
  492. 13, -1000, -1000, -248, 43, 19, -15, -216, -1000, 60,
  493. -1000, -1000, -249, -1000, -1000, 43, -250, 43, 89, 61,
  494. -1000, -1000, -3, -3, -3, -3, -3, -3, 53, 53,
  495. -1000, -1000, 82, -1000, -1000, -1000, -2, -1000, 85, 13,
  496. -1000, 43, -1000, -1000, 31, 43, -36, -1000, 56, 60,
  497. -1000, -255, -1000, 43, 43, -1000, -269, -1000, -1000, -1000,
  498. 13, 34, -1000, 43, -1000, 13, -1000, -1000, -1000, -1000,
  499. -193, 19, 19, -53, 59, -1000, -1000, -8, 58, 43,
  500. -1000, -1000, -1000, -1000, -226, -1000, -218, -223, -1000, 43,
  501. -1000, -269, 26, -1000, -1000, -1000, 13, -253, 43, -1000,
  502. -1000, -1000, -42, -1000, 43, 43, -1000, 34, -1000, 13,
  503. -1000, -1000, -1000, -1000, -193, -1000 };
  504. int yypgo[]={
  505. 0, 195, 50, 96, 71, 135, 194, 193, 192, 190,
  506. 189, 187, 136, 186, 184, 82, 54, 183, 182, 180,
  507. 172, 170, 59, 168, 167, 166, 63, 70, 164, 162,
  508. 137, 161, 160, 159, 158, 157, 156, 155, 154, 153,
  509. 152, 150, 149, 148, 69, 147, 144, 65, 143, 142,
  510. 140, 76, 138 };
  511. int yyr1[]={
  512. 0, 1, 14, 1, 1, 1, 19, 21, 17, 23,
  513. 23, 24, 15, 16, 16, 25, 28, 25, 29, 25,
  514. 25, 25, 25, 27, 27, 27, 32, 33, 22, 34,
  515. 35, 34, 2, 26, 3, 3, 3, 3, 3, 3,
  516. 3, 3, 3, 3, 3, 3, 3, 3, 36, 3,
  517. 3, 3, 3, 3, 3, 3, 3, 38, 3, 39,
  518. 3, 37, 37, 41, 30, 40, 4, 4, 5, 42,
  519. 5, 20, 20, 43, 43, 13, 13, 7, 7, 8,
  520. 8, 9, 9, 45, 44, 10, 10, 46, 11, 48,
  521. 11, 47, 6, 6, 12, 49, 12, 50, 12, 31,
  522. 31, 51, 52, 51, 18 };
  523. int yyr2[]={
  524. 0, 0, 1, 9, 4, 4, 1, 1, 19, 0,
  525. 6, 1, 4, 0, 2, 17, 1, 17, 1, 13,
  526. 7, 3, 4, 0, 4, 15, 1, 1, 9, 0,
  527. 1, 9, 1, 3, 7, 7, 7, 7, 7, 7,
  528. 7, 7, 7, 7, 7, 7, 5, 5, 1, 9,
  529. 9, 3, 3, 3, 3, 3, 5, 1, 11, 1,
  530. 11, 1, 2, 1, 11, 3, 1, 3, 3, 1,
  531. 9, 0, 2, 3, 7, 1, 3, 7, 7, 1,
  532. 3, 3, 7, 1, 9, 1, 3, 1, 5, 1,
  533. 9, 3, 3, 7, 3, 1, 11, 1, 9, 5,
  534. 9, 1, 1, 6, 3 };
  535. int yychk[]={
  536. -1000, -1, -14, -17, -18, 270, 273, -15, -24, 271,
  537. -16, 59, -25, 258, 262, 264, -6, -30, 268, -12,
  538. -40, 271, -19, -26, -3, 40, 43, 45, 64, -12,
  539. 269, 272, 257, -30, 274, -28, -29, 61, 44, -31,
  540. 271, -49, -50, -41, 40, 259, 61, 60, 62, 277,
  541. 278, 279, 43, 45, 42, 47, 280, 275, 276, -3,
  542. -26, -26, -26, -36, 40, -26, -26, -22, -32, -5,
  543. -3, -12, 44, -51, 61, 91, 46, 40, -20, -43,
  544. 271, -2, -26, -26, -26, -26, -26, -26, -26, -26,
  545. -26, -26, -26, -2, -2, 41, -13, 271, -37, -26,
  546. 263, 265, -23, 44, 271, -52, -26, 271, -4, -5,
  547. 41, 44, -22, -38, -39, -7, 123, 91, 41, -2,
  548. -26, -15, -33, -42, -51, -26, 93, 41, -21, 271,
  549. -2, -26, -26, -8, -9, -44, 271, -10, -11, -46,
  550. -22, -2, -16, -34, -35, -3, -22, -27, 260, 261,
  551. 125, 44, -45, 93, 44, -47, -26, -2, 267, 266,
  552. 266, -22, -26, -44, 61, -48, 266, -4, 259, -26,
  553. -47, -16, -2, -22, -2, -27 };
  554. int yydef[]={
  555. 1, -2, 11, 4, 5, 0, 104, 13, 0, 6,
  556. 3, 14, 12, 0, 16, 18, 0, 21, 0, -2,
  557. 63, 94, 0, 0, 33, 0, 0, 0, 48, -2,
  558. 52, 53, 54, 55, 0, 0, 26, 0, 0, 22,
  559. 101, 0, 0, 0, 71, 32, 0, 0, 0, 0,
  560. 0, 0, 0, 0, 0, 0, 0, 32, 32, 33,
  561. 0, 46, 47, 75, 61, 56, 0, 0, 9, 20,
  562. -2, -2, 0, 99, 102, 0, 0, 66, 0, 72,
  563. 73, 26, 35, 36, 37, 38, 39, 40, 41, 42,
  564. 43, 44, 45, 57, 59, 34, 0, 76, 0, 62,
  565. 32, 0, -2, 69, 101, 0, 0, 98, 0, 67,
  566. 7, 0, 32, 0, 0, 49, 79, -2, 50, 26,
  567. 32, 13, -2, 0, 100, 103, 96, 64, 26, 74,
  568. 23, 58, 60, 0, 80, 81, 83, 0, 86, 0,
  569. 32, 19, 10, 28, 0, -2, 0, 0, 26, 0,
  570. 77, 0, 0, 78, 89, 88, 91, 0, 66, 8,
  571. 15, 24, 0, 82, 0, 0, 17, 13, 32, 84,
  572. 90, 31, 26, 32, 23, 25 };
  573. typedef struct { char *t_name; int t_val; } yytoktype;
  574. #ifndef YYDEBUG
  575. # define YYDEBUG 0 /* don't allow debugging */
  576. #endif
  577. #if YYDEBUG
  578. yytoktype yytoks[] =
  579. {
  580. "NIL", 257,
  581. "IF", 258,
  582. "THEN", 259,
  583. "ELSE", 260,
  584. "ELSEIF", 261,
  585. "WHILE", 262,
  586. "DO", 263,
  587. "REPEAT", 264,
  588. "UNTIL", 265,
  589. "END", 266,
  590. "RETURN", 267,
  591. "LOCAL", 268,
  592. "NUMBER", 269,
  593. "FUNCTION", 270,
  594. "NAME", 271,
  595. "STRING", 272,
  596. "DEBUG", 273,
  597. "NOT", 274,
  598. "AND", 275,
  599. "OR", 276,
  600. "=", 61,
  601. "NE", 277,
  602. ">", 62,
  603. "<", 60,
  604. "LE", 278,
  605. "GE", 279,
  606. "CONC", 280,
  607. "+", 43,
  608. "-", 45,
  609. "*", 42,
  610. "/", 47,
  611. "%", 37,
  612. "UNARY", 281,
  613. "-unknown-", -1 /* ends search */
  614. };
  615. char * yyreds[] =
  616. {
  617. "-no such reduction-",
  618. "functionlist : /* empty */",
  619. "functionlist : functionlist",
  620. "functionlist : functionlist stat sc",
  621. "functionlist : functionlist function",
  622. "functionlist : functionlist setdebug",
  623. "function : FUNCTION NAME",
  624. "function : FUNCTION NAME '(' parlist ')'",
  625. "function : FUNCTION NAME '(' parlist ')' block END",
  626. "statlist : /* empty */",
  627. "statlist : statlist stat sc",
  628. "stat : /* empty */",
  629. "stat : stat1",
  630. "sc : /* empty */",
  631. "sc : ';'",
  632. "stat1 : IF expr1 THEN PrepJump block PrepJump elsepart END",
  633. "stat1 : WHILE",
  634. "stat1 : WHILE expr1 DO PrepJump block PrepJump END",
  635. "stat1 : REPEAT",
  636. "stat1 : REPEAT block UNTIL expr1 PrepJump",
  637. "stat1 : varlist1 '=' exprlist1",
  638. "stat1 : functioncall",
  639. "stat1 : LOCAL declist",
  640. "elsepart : /* empty */",
  641. "elsepart : ELSE block",
  642. "elsepart : ELSEIF expr1 THEN PrepJump block PrepJump elsepart",
  643. "block : /* empty */",
  644. "block : statlist",
  645. "block : statlist ret",
  646. "ret : /* empty */",
  647. "ret : /* empty */",
  648. "ret : RETURN exprlist sc",
  649. "PrepJump : /* empty */",
  650. "expr1 : expr",
  651. "expr : '(' expr ')'",
  652. "expr : expr1 '=' expr1",
  653. "expr : expr1 '<' expr1",
  654. "expr : expr1 '>' expr1",
  655. "expr : expr1 NE expr1",
  656. "expr : expr1 LE expr1",
  657. "expr : expr1 GE expr1",
  658. "expr : expr1 '+' expr1",
  659. "expr : expr1 '-' expr1",
  660. "expr : expr1 '*' expr1",
  661. "expr : expr1 '/' expr1",
  662. "expr : expr1 CONC expr1",
  663. "expr : '+' expr1",
  664. "expr : '-' expr1",
  665. "expr : '@'",
  666. "expr : '@' objectname fieldlist",
  667. "expr : '@' '(' dimension ')'",
  668. "expr : var",
  669. "expr : NUMBER",
  670. "expr : STRING",
  671. "expr : NIL",
  672. "expr : functioncall",
  673. "expr : NOT expr1",
  674. "expr : expr1 AND PrepJump",
  675. "expr : expr1 AND PrepJump expr1",
  676. "expr : expr1 OR PrepJump",
  677. "expr : expr1 OR PrepJump expr1",
  678. "dimension : /* empty */",
  679. "dimension : expr1",
  680. "functioncall : functionvalue",
  681. "functioncall : functionvalue '(' exprlist ')'",
  682. "functionvalue : var",
  683. "exprlist : /* empty */",
  684. "exprlist : exprlist1",
  685. "exprlist1 : expr",
  686. "exprlist1 : exprlist1 ','",
  687. "exprlist1 : exprlist1 ',' expr",
  688. "parlist : /* empty */",
  689. "parlist : parlist1",
  690. "parlist1 : NAME",
  691. "parlist1 : parlist1 ',' NAME",
  692. "objectname : /* empty */",
  693. "objectname : NAME",
  694. "fieldlist : '{' ffieldlist '}'",
  695. "fieldlist : '[' lfieldlist ']'",
  696. "ffieldlist : /* empty */",
  697. "ffieldlist : ffieldlist1",
  698. "ffieldlist1 : ffield",
  699. "ffieldlist1 : ffieldlist1 ',' ffield",
  700. "ffield : NAME",
  701. "ffield : NAME '=' expr1",
  702. "lfieldlist : /* empty */",
  703. "lfieldlist : lfieldlist1",
  704. "lfieldlist1 : /* empty */",
  705. "lfieldlist1 : lfield",
  706. "lfieldlist1 : lfieldlist1 ','",
  707. "lfieldlist1 : lfieldlist1 ',' lfield",
  708. "lfield : expr1",
  709. "varlist1 : var",
  710. "varlist1 : varlist1 ',' var",
  711. "var : NAME",
  712. "var : var",
  713. "var : var '[' expr1 ']'",
  714. "var : var",
  715. "var : var '.' NAME",
  716. "declist : NAME init",
  717. "declist : declist ',' NAME init",
  718. "init : /* empty */",
  719. "init : '='",
  720. "init : '=' expr1",
  721. "setdebug : DEBUG",
  722. };
  723. #endif /* YYDEBUG */
  724. #line 1 "/usr/lib/yaccpar"
  725. /* @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10 */
  726. /*
  727. ** Skeleton parser driver for yacc output
  728. */
  729. /*
  730. ** yacc user known macros and defines
  731. */
  732. #define YYERROR goto yyerrlab
  733. #define YYACCEPT { free(yys); free(yyv); return(0); }
  734. #define YYABORT { free(yys); free(yyv); return(1); }
  735. #define YYBACKUP( newtoken, newvalue )\
  736. {\
  737. if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  738. {\
  739. yyerror( "syntax error - cannot backup" );\
  740. goto yyerrlab;\
  741. }\
  742. yychar = newtoken;\
  743. yystate = *yyps;\
  744. yylval = newvalue;\
  745. goto yynewstate;\
  746. }
  747. #define YYRECOVERING() (!!yyerrflag)
  748. #ifndef YYDEBUG
  749. # define YYDEBUG 1 /* make debugging available */
  750. #endif
  751. /*
  752. ** user known globals
  753. */
  754. int yydebug; /* set to 1 to get debugging */
  755. /*
  756. ** driver internal defines
  757. */
  758. #define YYFLAG (-1000)
  759. /*
  760. ** static variables used by the parser
  761. */
  762. static YYSTYPE *yyv; /* value stack */
  763. static int *yys; /* state stack */
  764. static YYSTYPE *yypv; /* top of value stack */
  765. static int *yyps; /* top of state stack */
  766. static int yystate; /* current state */
  767. static int yytmp; /* extra var (lasts between blocks) */
  768. int yynerrs; /* number of errors */
  769. int yyerrflag; /* error recovery flag */
  770. int yychar; /* current input token number */
  771. /*
  772. ** yyparse - return 0 if worked, 1 if syntax error not recovered from
  773. */
  774. int
  775. yyparse()
  776. {
  777. register YYSTYPE *yypvt; /* top of value stack for $vars */
  778. unsigned yymaxdepth = YYMAXDEPTH;
  779. /*
  780. ** Initialize externals - yyparse may be called more than once
  781. */
  782. yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
  783. yys = (int*)malloc(yymaxdepth*sizeof(int));
  784. if (!yyv || !yys)
  785. {
  786. yyerror( "out of memory" );
  787. return(1);
  788. }
  789. yypv = &yyv[-1];
  790. yyps = &yys[-1];
  791. yystate = 0;
  792. yytmp = 0;
  793. yynerrs = 0;
  794. yyerrflag = 0;
  795. yychar = -1;
  796. goto yystack;
  797. {
  798. register YYSTYPE *yy_pv; /* top of value stack */
  799. register int *yy_ps; /* top of state stack */
  800. register int yy_state; /* current state */
  801. register int yy_n; /* internal state number info */
  802. /*
  803. ** get globals into registers.
  804. ** branch to here only if YYBACKUP was called.
  805. */
  806. yynewstate:
  807. yy_pv = yypv;
  808. yy_ps = yyps;
  809. yy_state = yystate;
  810. goto yy_newstate;
  811. /*
  812. ** get globals into registers.
  813. ** either we just started, or we just finished a reduction
  814. */
  815. yystack:
  816. yy_pv = yypv;
  817. yy_ps = yyps;
  818. yy_state = yystate;
  819. /*
  820. ** top of for (;;) loop while no reductions done
  821. */
  822. yy_stack:
  823. /*
  824. ** put a state and value onto the stacks
  825. */
  826. #if YYDEBUG
  827. /*
  828. ** if debugging, look up token value in list of value vs.
  829. ** name pairs. 0 and negative (-1) are special values.
  830. ** Note: linear search is used since time is not a real
  831. ** consideration while debugging.
  832. */
  833. if ( yydebug )
  834. {
  835. register int yy_i;
  836. (void)printf( "State %d, token ", yy_state );
  837. if ( yychar == 0 )
  838. (void)printf( "end-of-file\n" );
  839. else if ( yychar < 0 )
  840. (void)printf( "-none-\n" );
  841. else
  842. {
  843. for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  844. yy_i++ )
  845. {
  846. if ( yytoks[yy_i].t_val == yychar )
  847. break;
  848. }
  849. (void)printf( "%s\n", yytoks[yy_i].t_name );
  850. }
  851. }
  852. #endif /* YYDEBUG */
  853. if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */
  854. {
  855. /*
  856. ** reallocate and recover. Note that pointers
  857. ** have to be reset, or bad things will happen
  858. */
  859. int yyps_index = (yy_ps - yys);
  860. int yypv_index = (yy_pv - yyv);
  861. int yypvt_index = (yypvt - yyv);
  862. yymaxdepth += YYMAXDEPTH;
  863. yyv = (YYSTYPE*)realloc((char*)yyv,
  864. yymaxdepth * sizeof(YYSTYPE));
  865. yys = (int*)realloc((char*)yys,
  866. yymaxdepth * sizeof(int));
  867. if (!yyv || !yys)
  868. {
  869. yyerror( "yacc stack overflow" );
  870. return(1);
  871. }
  872. yy_ps = yys + yyps_index;
  873. yy_pv = yyv + yypv_index;
  874. yypvt = yyv + yypvt_index;
  875. }
  876. *yy_ps = yy_state;
  877. *++yy_pv = yyval;
  878. /*
  879. ** we have a new state - find out what to do
  880. */
  881. yy_newstate:
  882. if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
  883. goto yydefault; /* simple state */
  884. #if YYDEBUG
  885. /*
  886. ** if debugging, need to mark whether new token grabbed
  887. */
  888. yytmp = yychar < 0;
  889. #endif
  890. if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  891. yychar = 0; /* reached EOF */
  892. #if YYDEBUG
  893. if ( yydebug && yytmp )
  894. {
  895. register int yy_i;
  896. (void)printf( "Received token " );
  897. if ( yychar == 0 )
  898. (void)printf( "end-of-file\n" );
  899. else if ( yychar < 0 )
  900. (void)printf( "-none-\n" );
  901. else
  902. {
  903. for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  904. yy_i++ )
  905. {
  906. if ( yytoks[yy_i].t_val == yychar )
  907. break;
  908. }
  909. (void)printf( "%s\n", yytoks[yy_i].t_name );
  910. }
  911. }
  912. #endif /* YYDEBUG */
  913. if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
  914. goto yydefault;
  915. if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/
  916. {
  917. yychar = -1;
  918. yyval = yylval;
  919. yy_state = yy_n;
  920. if ( yyerrflag > 0 )
  921. yyerrflag--;
  922. goto yy_stack;
  923. }
  924. yydefault:
  925. if ( ( yy_n = yydef[ yy_state ] ) == -2 )
  926. {
  927. #if YYDEBUG
  928. yytmp = yychar < 0;
  929. #endif
  930. if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  931. yychar = 0; /* reached EOF */
  932. #if YYDEBUG
  933. if ( yydebug && yytmp )
  934. {
  935. register int yy_i;
  936. (void)printf( "Received token " );
  937. if ( yychar == 0 )
  938. (void)printf( "end-of-file\n" );
  939. else if ( yychar < 0 )
  940. (void)printf( "-none-\n" );
  941. else
  942. {
  943. for ( yy_i = 0;
  944. yytoks[yy_i].t_val >= 0;
  945. yy_i++ )
  946. {
  947. if ( yytoks[yy_i].t_val
  948. == yychar )
  949. {
  950. break;
  951. }
  952. }
  953. (void)printf( "%s\n", yytoks[yy_i].t_name );
  954. }
  955. }
  956. #endif /* YYDEBUG */
  957. /*
  958. ** look through exception table
  959. */
  960. {
  961. register int *yyxi = yyexca;
  962. while ( ( *yyxi != -1 ) ||
  963. ( yyxi[1] != yy_state ) )
  964. {
  965. yyxi += 2;
  966. }
  967. while ( ( *(yyxi += 2) >= 0 ) &&
  968. ( *yyxi != yychar ) )
  969. ;
  970. if ( ( yy_n = yyxi[1] ) < 0 )
  971. YYACCEPT;
  972. }
  973. }
  974. /*
  975. ** check for syntax error
  976. */
  977. if ( yy_n == 0 ) /* have an error */
  978. {
  979. /* no worry about speed here! */
  980. switch ( yyerrflag )
  981. {
  982. case 0: /* new error */
  983. yyerror( "syntax error" );
  984. goto skip_init;
  985. yyerrlab:
  986. /*
  987. ** get globals into registers.
  988. ** we have a user generated syntax type error
  989. */
  990. yy_pv = yypv;
  991. yy_ps = yyps;
  992. yy_state = yystate;
  993. yynerrs++;
  994. skip_init:
  995. case 1:
  996. case 2: /* incompletely recovered error */
  997. /* try again... */
  998. yyerrflag = 3;
  999. /*
  1000. ** find state where "error" is a legal
  1001. ** shift action
  1002. */
  1003. while ( yy_ps >= yys )
  1004. {
  1005. yy_n = yypact[ *yy_ps ] + YYERRCODE;
  1006. if ( yy_n >= 0 && yy_n < YYLAST &&
  1007. yychk[yyact[yy_n]] == YYERRCODE) {
  1008. /*
  1009. ** simulate shift of "error"
  1010. */
  1011. yy_state = yyact[ yy_n ];
  1012. goto yy_stack;
  1013. }
  1014. /*
  1015. ** current state has no shift on
  1016. ** "error", pop stack
  1017. */
  1018. #if YYDEBUG
  1019. # define _POP_ "Error recovery pops state %d, uncovers state %d\n"
  1020. if ( yydebug )
  1021. (void)printf( _POP_, *yy_ps,
  1022. yy_ps[-1] );
  1023. # undef _POP_
  1024. #endif
  1025. yy_ps--;
  1026. yy_pv--;
  1027. }
  1028. /*
  1029. ** there is no state on stack with "error" as
  1030. ** a valid shift. give up.
  1031. */
  1032. YYABORT;
  1033. case 3: /* no shift yet; eat a token */
  1034. #if YYDEBUG
  1035. /*
  1036. ** if debugging, look up token in list of
  1037. ** pairs. 0 and negative shouldn't occur,
  1038. ** but since timing doesn't matter when
  1039. ** debugging, it doesn't hurt to leave the
  1040. ** tests here.
  1041. */
  1042. if ( yydebug )
  1043. {
  1044. register int yy_i;
  1045. (void)printf( "Error recovery discards " );
  1046. if ( yychar == 0 )
  1047. (void)printf( "token end-of-file\n" );
  1048. else if ( yychar < 0 )
  1049. (void)printf( "token -none-\n" );
  1050. else
  1051. {
  1052. for ( yy_i = 0;
  1053. yytoks[yy_i].t_val >= 0;
  1054. yy_i++ )
  1055. {
  1056. if ( yytoks[yy_i].t_val
  1057. == yychar )
  1058. {
  1059. break;
  1060. }
  1061. }
  1062. (void)printf( "token %s\n",
  1063. yytoks[yy_i].t_name );
  1064. }
  1065. }
  1066. #endif /* YYDEBUG */
  1067. if ( yychar == 0 ) /* reached EOF. quit */
  1068. YYABORT;
  1069. yychar = -1;
  1070. goto yy_newstate;
  1071. }
  1072. }/* end if ( yy_n == 0 ) */
  1073. /*
  1074. ** reduction by production yy_n
  1075. ** put stack tops, etc. so things right after switch
  1076. */
  1077. #if YYDEBUG
  1078. /*
  1079. ** if debugging, print the string that is the user's
  1080. ** specification of the reduction which is just about
  1081. ** to be done.
  1082. */
  1083. if ( yydebug )
  1084. (void)printf( "Reduce by (%d) \"%s\"\n",
  1085. yy_n, yyreds[ yy_n ] );
  1086. #endif
  1087. yytmp = yy_n; /* value to switch over */
  1088. yypvt = yy_pv; /* $vars top of value stack */
  1089. /*
  1090. ** Look in goto table for next state
  1091. ** Sorry about using yy_state here as temporary
  1092. ** register variable, but why not, if it works...
  1093. ** If yyr2[ yy_n ] doesn't have the low order bit
  1094. ** set, then there is no action to be done for
  1095. ** this reduction. So, no saving & unsaving of
  1096. ** registers done. The only difference between the
  1097. ** code just after the if and the body of the if is
  1098. ** the goto yy_stack in the body. This way the test
  1099. ** can be made before the choice of what to do is needed.
  1100. */
  1101. {
  1102. /* length of production doubled with extra bit */
  1103. register int yy_len = yyr2[ yy_n ];
  1104. if ( !( yy_len & 01 ) )
  1105. {
  1106. yy_len >>= 1;
  1107. yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
  1108. yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  1109. *( yy_ps -= yy_len ) + 1;
  1110. if ( yy_state >= YYLAST ||
  1111. yychk[ yy_state =
  1112. yyact[ yy_state ] ] != -yy_n )
  1113. {
  1114. yy_state = yyact[ yypgo[ yy_n ] ];
  1115. }
  1116. goto yy_stack;
  1117. }
  1118. yy_len >>= 1;
  1119. yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
  1120. yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  1121. *( yy_ps -= yy_len ) + 1;
  1122. if ( yy_state >= YYLAST ||
  1123. yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
  1124. {
  1125. yy_state = yyact[ yypgo[ yy_n ] ];
  1126. }
  1127. }
  1128. /* save until reenter driver code */
  1129. yystate = yy_state;
  1130. yyps = yy_ps;
  1131. yypv = yy_pv;
  1132. }
  1133. /*
  1134. ** code supplied by user is placed in this switch
  1135. */
  1136. switch( yytmp )
  1137. {
  1138. case 2:
  1139. # line 179 "lua.stx"
  1140. {pc=basepc=maincode; nlocalvar=0;} break;
  1141. case 3:
  1142. # line 179 "lua.stx"
  1143. {maincode=pc;} break;
  1144. case 6:
  1145. # line 184 "lua.stx"
  1146. {pc=basepc=code; nlocalvar=0;} break;
  1147. case 7:
  1148. # line 185 "lua.stx"
  1149. {
  1150. if (lua_debug)
  1151. {
  1152. align(Word);
  1153. code_byte(SETFUNCTION);
  1154. code_word(yypvt[-5].vWord);
  1155. code_word(yypvt[-4].vWord);
  1156. }
  1157. lua_codeadjust (0);
  1158. } break;
  1159. case 8:
  1160. # line 197 "lua.stx"
  1161. {
  1162. if (lua_debug) code_byte(RESET);
  1163. code_byte(RETCODE); code_byte(nlocalvar);
  1164. s_tag(yypvt[-7].vWord) = T_FUNCTION;
  1165. s_bvalue(yypvt[-7].vWord) = calloc (pc-code, sizeof(Byte));
  1166. memcpy (s_bvalue(yypvt[-7].vWord), code, (pc-code)*sizeof(Byte));
  1167. } break;
  1168. case 11:
  1169. # line 210 "lua.stx"
  1170. {
  1171. ntemp = 0;
  1172. if (lua_debug)
  1173. {
  1174. align(Word); code_byte(SETLINE); code_word(lua_linenumber);
  1175. }
  1176. } break;
  1177. case 15:
  1178. # line 223 "lua.stx"
  1179. {
  1180. {
  1181. Byte *elseinit = yypvt[-2].pByte + sizeof(Word)+1;
  1182. if (pc - elseinit == 0) /* no else */
  1183. {
  1184. pc -= sizeof(Word)+1;
  1185. /* if (*(pc-1) == NOP) --pc; */
  1186. elseinit = pc;
  1187. }
  1188. else
  1189. {
  1190. *(yypvt[-2].pByte) = JMP;
  1191. *((Word *)(yypvt[-2].pByte+1)) = pc - elseinit;
  1192. }
  1193. *(yypvt[-4].pByte) = IFFJMP;
  1194. *((Word *)(yypvt[-4].pByte+1)) = elseinit - (yypvt[-4].pByte + sizeof(Word)+1);
  1195. }
  1196. } break;
  1197. case 16:
  1198. # line 242 "lua.stx"
  1199. {yyval.pByte = pc;} break;
  1200. case 17:
  1201. # line 244 "lua.stx"
  1202. {
  1203. *(yypvt[-3].pByte) = IFFJMP;
  1204. *((Word *)(yypvt[-3].pByte+1)) = pc - (yypvt[-3].pByte + sizeof(Word)+1);
  1205. *(yypvt[-1].pByte) = UPJMP;
  1206. *((Word *)(yypvt[-1].pByte+1)) = pc - yypvt[-6].pByte;
  1207. } break;
  1208. case 18:
  1209. # line 252 "lua.stx"
  1210. {yyval.pByte = pc;} break;
  1211. case 19:
  1212. # line 254 "lua.stx"
  1213. {
  1214. *(yypvt[-0].pByte) = IFFUPJMP;
  1215. *((Word *)(yypvt[-0].pByte+1)) = pc - yypvt[-4].pByte;
  1216. } break;
  1217. case 20:
  1218. # line 261 "lua.stx"
  1219. {
  1220. {
  1221. int i;
  1222. if (yypvt[-0].vInt == 0 || nvarbuffer != ntemp - yypvt[-2].vInt * 2)
  1223. lua_codeadjust (yypvt[-2].vInt * 2 + nvarbuffer);
  1224. for (i=nvarbuffer-1; i>=0; i--)
  1225. lua_codestore (i);
  1226. if (yypvt[-2].vInt > 1 || (yypvt[-2].vInt == 1 && varbuffer[0] != 0))
  1227. lua_codeadjust (0);
  1228. }
  1229. } break;
  1230. case 21:
  1231. # line 272 "lua.stx"
  1232. { lua_codeadjust (0); } break;
  1233. case 25:
  1234. # line 279 "lua.stx"
  1235. {
  1236. {
  1237. Byte *elseinit = yypvt[-1].pByte + sizeof(Word)+1;
  1238. if (pc - elseinit == 0) /* no else */
  1239. {
  1240. pc -= sizeof(Word)+1;
  1241. /* if (*(pc-1) == NOP) --pc; */
  1242. elseinit = pc;
  1243. }
  1244. else
  1245. {
  1246. *(yypvt[-1].pByte) = JMP;
  1247. *((Word *)(yypvt[-1].pByte+1)) = pc - elseinit;
  1248. }
  1249. *(yypvt[-3].pByte) = IFFJMP;
  1250. *((Word *)(yypvt[-3].pByte+1)) = elseinit - (yypvt[-3].pByte + sizeof(Word)+1);
  1251. }
  1252. } break;
  1253. case 26:
  1254. # line 299 "lua.stx"
  1255. {yyval.vInt = nlocalvar;} break;
  1256. case 27:
  1257. # line 299 "lua.stx"
  1258. {ntemp = 0;} break;
  1259. case 28:
  1260. # line 300 "lua.stx"
  1261. {
  1262. if (nlocalvar != yypvt[-3].vInt)
  1263. {
  1264. nlocalvar = yypvt[-3].vInt;
  1265. lua_codeadjust (0);
  1266. }
  1267. } break;
  1268. case 30:
  1269. # line 310 "lua.stx"
  1270. { if (lua_debug){align(Word);code_byte(SETLINE);code_word(lua_linenumber);}} break;
  1271. case 31:
  1272. # line 312 "lua.stx"
  1273. {
  1274. if (lua_debug) code_byte(RESET);
  1275. code_byte(RETCODE); code_byte(nlocalvar);
  1276. } break;
  1277. case 32:
  1278. # line 319 "lua.stx"
  1279. {
  1280. align(Word);
  1281. yyval.pByte = pc;
  1282. code_byte(0); /* open space */
  1283. code_word (0);
  1284. } break;
  1285. case 33:
  1286. # line 326 "lua.stx"
  1287. { if (yypvt[-0].vInt == 0) {lua_codeadjust (ntemp+1); incr_ntemp();}} break;
  1288. case 34:
  1289. # line 329 "lua.stx"
  1290. { yyval.vInt = yypvt[-1].vInt; } break;
  1291. case 35:
  1292. # line 330 "lua.stx"
  1293. { code_byte(EQOP); yyval.vInt = 1; ntemp--;} break;
  1294. case 36:
  1295. # line 331 "lua.stx"
  1296. { code_byte(LTOP); yyval.vInt = 1; ntemp--;} break;
  1297. case 37:
  1298. # line 332 "lua.stx"
  1299. { code_byte(LEOP); code_byte(NOTOP); yyval.vInt = 1; ntemp--;} break;
  1300. case 38:
  1301. # line 333 "lua.stx"
  1302. { code_byte(EQOP); code_byte(NOTOP); yyval.vInt = 1; ntemp--;} break;
  1303. case 39:
  1304. # line 334 "lua.stx"
  1305. { code_byte(LEOP); yyval.vInt = 1; ntemp--;} break;
  1306. case 40:
  1307. # line 335 "lua.stx"
  1308. { code_byte(LTOP); code_byte(NOTOP); yyval.vInt = 1; ntemp--;} break;
  1309. case 41:
  1310. # line 336 "lua.stx"
  1311. { code_byte(ADDOP); yyval.vInt = 1; ntemp--;} break;
  1312. case 42:
  1313. # line 337 "lua.stx"
  1314. { code_byte(SUBOP); yyval.vInt = 1; ntemp--;} break;
  1315. case 43:
  1316. # line 338 "lua.stx"
  1317. { code_byte(MULTOP); yyval.vInt = 1; ntemp--;} break;
  1318. case 44:
  1319. # line 339 "lua.stx"
  1320. { code_byte(DIVOP); yyval.vInt = 1; ntemp--;} break;
  1321. case 45:
  1322. # line 340 "lua.stx"
  1323. { code_byte(CONCOP); yyval.vInt = 1; ntemp--;} break;
  1324. case 46:
  1325. # line 341 "lua.stx"
  1326. { yyval.vInt = 1; } break;
  1327. case 47:
  1328. # line 342 "lua.stx"
  1329. { code_byte(MINUSOP); yyval.vInt = 1;} break;
  1330. case 48:
  1331. # line 344 "lua.stx"
  1332. {
  1333. code_byte(PUSHBYTE);
  1334. yyval.pByte = pc; code_byte(0);
  1335. incr_ntemp();
  1336. code_byte(CREATEARRAY);
  1337. } break;
  1338. case 49:
  1339. # line 351 "lua.stx"
  1340. {
  1341. *(yypvt[-2].pByte) = yypvt[-0].vInt;
  1342. if (yypvt[-1].vLong < 0) /* there is no function to be called */
  1343. {
  1344. yyval.vInt = 1;
  1345. }
  1346. else
  1347. {
  1348. lua_pushvar (yypvt[-1].vLong+1);
  1349. code_byte(PUSHMARK);
  1350. incr_ntemp();
  1351. code_byte(PUSHOBJECT);
  1352. incr_ntemp();
  1353. code_byte(CALLFUNC);
  1354. ntemp -= 4;
  1355. yyval.vInt = 0;
  1356. if (lua_debug)
  1357. {
  1358. align(Word); code_byte(SETLINE); code_word(lua_linenumber);
  1359. }
  1360. }
  1361. } break;
  1362. case 50:
  1363. # line 374 "lua.stx"
  1364. {
  1365. code_byte(CREATEARRAY);
  1366. yyval.vInt = 1;
  1367. } break;
  1368. case 51:
  1369. # line 378 "lua.stx"
  1370. { lua_pushvar (yypvt[-0].vLong); yyval.vInt = 1;} break;
  1371. case 52:
  1372. # line 379 "lua.stx"
  1373. { code_number(yypvt[-0].vFloat); yyval.vInt = 1; } break;
  1374. case 53:
  1375. # line 381 "lua.stx"
  1376. {
  1377. align(Word);
  1378. code_byte(PUSHSTRING);
  1379. code_word(yypvt[-0].vWord);
  1380. yyval.vInt = 1;
  1381. incr_ntemp();
  1382. } break;
  1383. case 54:
  1384. # line 388 "lua.stx"
  1385. {code_byte(PUSHNIL); yyval.vInt = 1; incr_ntemp();} break;
  1386. case 55:
  1387. # line 390 "lua.stx"
  1388. {
  1389. yyval.vInt = 0;
  1390. if (lua_debug)
  1391. {
  1392. align(Word); code_byte(SETLINE); code_word(lua_linenumber);
  1393. }
  1394. } break;
  1395. case 56:
  1396. # line 397 "lua.stx"
  1397. { code_byte(NOTOP); yyval.vInt = 1;} break;
  1398. case 57:
  1399. # line 398 "lua.stx"
  1400. {code_byte(POP); ntemp--;} break;
  1401. case 58:
  1402. # line 399 "lua.stx"
  1403. {
  1404. *(yypvt[-2].pByte) = ONFJMP;
  1405. *((Word *)(yypvt[-2].pByte+1)) = pc - (yypvt[-2].pByte + sizeof(Word)+1);
  1406. yyval.vInt = 1;
  1407. } break;
  1408. case 59:
  1409. # line 404 "lua.stx"
  1410. {code_byte(POP); ntemp--;} break;
  1411. case 60:
  1412. # line 405 "lua.stx"
  1413. {
  1414. *(yypvt[-2].pByte) = ONTJMP;
  1415. *((Word *)(yypvt[-2].pByte+1)) = pc - (yypvt[-2].pByte + sizeof(Word)+1);
  1416. yyval.vInt = 1;
  1417. } break;
  1418. case 61:
  1419. # line 412 "lua.stx"
  1420. { code_byte(PUSHNIL); incr_ntemp();} break;
  1421. case 63:
  1422. # line 416 "lua.stx"
  1423. {code_byte(PUSHMARK); yyval.vInt = ntemp; incr_ntemp();} break;
  1424. case 64:
  1425. # line 417 "lua.stx"
  1426. { code_byte(CALLFUNC); ntemp = yypvt[-3].vInt-1;} break;
  1427. case 65:
  1428. # line 419 "lua.stx"
  1429. {lua_pushvar (yypvt[-0].vLong); } break;
  1430. case 66:
  1431. # line 422 "lua.stx"
  1432. { yyval.vInt = 1; } break;
  1433. case 67:
  1434. # line 423 "lua.stx"
  1435. { yyval.vInt = yypvt[-0].vInt; } break;
  1436. case 68:
  1437. # line 426 "lua.stx"
  1438. { yyval.vInt = yypvt[-0].vInt; } break;
  1439. case 69:
  1440. # line 427 "lua.stx"
  1441. {if (!yypvt[-1].vInt){lua_codeadjust (ntemp+1); incr_ntemp();}} break;
  1442. case 70:
  1443. # line 428 "lua.stx"
  1444. {yyval.vInt = yypvt[-0].vInt;} break;
  1445. case 73:
  1446. # line 435 "lua.stx"
  1447. {localvar[nlocalvar]=yypvt[-0].vWord; incr_nlocalvar();} break;
  1448. case 74:
  1449. # line 436 "lua.stx"
  1450. {localvar[nlocalvar]=yypvt[-0].vWord; incr_nlocalvar();} break;
  1451. case 75:
  1452. # line 439 "lua.stx"
  1453. {yyval.vLong=-1;} break;
  1454. case 76:
  1455. # line 440 "lua.stx"
  1456. {yyval.vLong=yypvt[-0].vWord;} break;
  1457. case 77:
  1458. # line 443 "lua.stx"
  1459. { yyval.vInt = yypvt[-1].vInt; } break;
  1460. case 78:
  1461. # line 444 "lua.stx"
  1462. { yyval.vInt = yypvt[-1].vInt; } break;
  1463. case 79:
  1464. # line 447 "lua.stx"
  1465. { yyval.vInt = 0; } break;
  1466. case 80:
  1467. # line 448 "lua.stx"
  1468. { yyval.vInt = yypvt[-0].vInt; } break;
  1469. case 81:
  1470. # line 451 "lua.stx"
  1471. {yyval.vInt=1;} break;
  1472. case 82:
  1473. # line 452 "lua.stx"
  1474. {yyval.vInt=yypvt[-2].vInt+1;} break;
  1475. case 83:
  1476. # line 456 "lua.stx"
  1477. {
  1478. align(Word);
  1479. code_byte(PUSHSTRING);
  1480. code_word(lua_findconstant (s_name(yypvt[-0].vWord)));
  1481. incr_ntemp();
  1482. } break;
  1483. case 84:
  1484. # line 463 "lua.stx"
  1485. {
  1486. code_byte(STOREFIELD);
  1487. ntemp-=2;
  1488. } break;
  1489. case 85:
  1490. # line 469 "lua.stx"
  1491. { yyval.vInt = 0; } break;
  1492. case 86:
  1493. # line 470 "lua.stx"
  1494. { yyval.vInt = yypvt[-0].vInt; } break;
  1495. case 87:
  1496. # line 473 "lua.stx"
  1497. { code_number(1); } break;
  1498. case 88:
  1499. # line 473 "lua.stx"
  1500. {yyval.vInt=1;} break;
  1501. case 89:
  1502. # line 474 "lua.stx"
  1503. { code_number(yypvt[-1].vInt+1); } break;
  1504. case 90:
  1505. # line 475 "lua.stx"
  1506. {yyval.vInt=yypvt[-3].vInt+1;} break;
  1507. case 91:
  1508. # line 479 "lua.stx"
  1509. {
  1510. code_byte(STOREFIELD);
  1511. ntemp-=2;
  1512. } break;
  1513. case 92:
  1514. # line 486 "lua.stx"
  1515. {
  1516. nvarbuffer = 0;
  1517. varbuffer[nvarbuffer] = yypvt[-0].vLong; incr_nvarbuffer();
  1518. yyval.vInt = (yypvt[-0].vLong == 0) ? 1 : 0;
  1519. } break;
  1520. case 93:
  1521. # line 492 "lua.stx"
  1522. {
  1523. varbuffer[nvarbuffer] = yypvt[-0].vLong; incr_nvarbuffer();
  1524. yyval.vInt = (yypvt[-0].vLong == 0) ? yypvt[-2].vInt + 1 : yypvt[-2].vInt;
  1525. } break;
  1526. case 94:
  1527. # line 499 "lua.stx"
  1528. {
  1529. int local = lua_localname (yypvt[-0].vWord);
  1530. if (local == -1) /* global var */
  1531. yyval.vLong = yypvt[-0].vWord + 1; /* return positive value */
  1532. else
  1533. yyval.vLong = -(local+1); /* return negative value */
  1534. } break;
  1535. case 95:
  1536. # line 507 "lua.stx"
  1537. {lua_pushvar (yypvt[-0].vLong);} break;
  1538. case 96:
  1539. # line 508 "lua.stx"
  1540. {
  1541. yyval.vLong = 0; /* indexed variable */
  1542. } break;
  1543. case 97:
  1544. # line 511 "lua.stx"
  1545. {lua_pushvar (yypvt[-0].vLong);} break;
  1546. case 98:
  1547. # line 512 "lua.stx"
  1548. {
  1549. align(Word);
  1550. code_byte(PUSHSTRING);
  1551. code_word(lua_findconstant (s_name(yypvt[-0].vWord))); incr_ntemp();
  1552. yyval.vLong = 0; /* indexed variable */
  1553. } break;
  1554. case 99:
  1555. # line 520 "lua.stx"
  1556. {localvar[nlocalvar]=yypvt[-1].vWord; incr_nlocalvar();} break;
  1557. case 100:
  1558. # line 521 "lua.stx"
  1559. {localvar[nlocalvar]=yypvt[-1].vWord; incr_nlocalvar();} break;
  1560. case 101:
  1561. # line 524 "lua.stx"
  1562. { code_byte(PUSHNIL); } break;
  1563. case 102:
  1564. # line 525 "lua.stx"
  1565. {ntemp = 0;} break;
  1566. case 104:
  1567. # line 528 "lua.stx"
  1568. {lua_debug = yypvt[-0].vInt;} break;
  1569. }
  1570. goto yystack; /* reset registers in driver code */
  1571. }