PageRenderTime 71ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/xbmc/visualizations/Goom/goom2k4-0/src/goomsl_yacc.c

http://github.com/xbmc/xbmc
C | 2997 lines | 2309 code | 404 blank | 284 comment | 295 complexity | 6616b1b5b943d68f1012fa9618055aa8 MD5 | raw file
Possible License(s): GPL-3.0, CC-BY-SA-3.0, LGPL-2.0, 0BSD, Unlicense, GPL-2.0, AGPL-1.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0
  1. /* A Bison parser, made by GNU Bison 1.875. */
  2. /* Skeleton parser for Yacc-like parsing with Bison,
  3. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. /* As a special exception, when this file is copied by Bison into a
  17. Bison output file, you may use that output file without restriction.
  18. This special exception was added by the Free Software Foundation
  19. in version 1.24 of Bison. */
  20. /* Written by Richard Stallman by simplifying the original so called
  21. ``semantic'' parser. */
  22. /* All symbols defined below should begin with yy or YY, to avoid
  23. infringing on user name space. This should be done even for local
  24. variables, as they might otherwise be expanded by user macros.
  25. There are some unavoidable exceptions within include files to
  26. define necessary library symbols; they are noted "INFRINGES ON
  27. USER NAME SPACE" below. */
  28. /* Identify Bison output. */
  29. #define YYBISON 1
  30. /* Skeleton name. */
  31. #define YYSKELETON_NAME "yacc.c"
  32. /* Pure parsers. */
  33. #define YYPURE 0
  34. /* Using locations. */
  35. #define YYLSP_NEEDED 0
  36. /* Tokens. */
  37. #ifndef YYTOKENTYPE
  38. # define YYTOKENTYPE
  39. /* Put the tokens into the symbol table, so that GDB and other debuggers
  40. know about them. */
  41. enum yytokentype {
  42. LTYPE_INTEGER = 258,
  43. LTYPE_FLOAT = 259,
  44. LTYPE_VAR = 260,
  45. LTYPE_PTR = 261,
  46. PTR_TK = 262,
  47. INT_TK = 263,
  48. FLOAT_TK = 264,
  49. DECLARE = 265,
  50. EXTERNAL = 266,
  51. WHILE = 267,
  52. DO = 268,
  53. NOT = 269,
  54. PLUS_EQ = 270,
  55. SUB_EQ = 271,
  56. DIV_EQ = 272,
  57. MUL_EQ = 273,
  58. SUP_EQ = 274,
  59. LOW_EQ = 275,
  60. NOT_EQ = 276,
  61. STRUCT = 277,
  62. FOR = 278,
  63. IN = 279
  64. };
  65. #endif
  66. #define LTYPE_INTEGER 258
  67. #define LTYPE_FLOAT 259
  68. #define LTYPE_VAR 260
  69. #define LTYPE_PTR 261
  70. #define PTR_TK 262
  71. #define INT_TK 263
  72. #define FLOAT_TK 264
  73. #define DECLARE 265
  74. #define EXTERNAL 266
  75. #define WHILE 267
  76. #define DO 268
  77. #define NOT 269
  78. #define PLUS_EQ 270
  79. #define SUB_EQ 271
  80. #define DIV_EQ 272
  81. #define MUL_EQ 273
  82. #define SUP_EQ 274
  83. #define LOW_EQ 275
  84. #define NOT_EQ 276
  85. #define STRUCT 277
  86. #define FOR 278
  87. #define IN 279
  88. /* Copy the first part of user declarations. */
  89. #line 6 "goomsl_yacc.y"
  90. #include <stdio.h>
  91. #include <stdlib.h>
  92. #include <string.h>
  93. #include "goomsl.h"
  94. #include "goomsl_private.h"
  95. #define STRUCT_ALIGNMENT 16
  96. /* #define VERBOSE */
  97. int yylex(void);
  98. void yyerror(char *);
  99. extern GoomSL *currentGoomSL;
  100. static NodeType *nodeNew(const char *str, int type, int line_number);
  101. static NodeType *nodeClone(NodeType *node);
  102. static void nodeFreeInternals(NodeType *node);
  103. static void nodeFree(NodeType *node);
  104. static void commit_node(NodeType *node, int releaseIfTemp);
  105. static void precommit_node(NodeType *node);
  106. static NodeType *new_constInt(const char *str, int line_number);
  107. static NodeType *new_constFloat(const char *str, int line_number);
  108. static NodeType *new_constPtr(const char *str, int line_number);
  109. static NodeType *new_var(const char *str, int line_number);
  110. static NodeType *new_nop(const char *str);
  111. static NodeType *new_op(const char *str, int type, int nbOp);
  112. static int allocateLabel();
  113. static int allocateTemp();
  114. static void releaseTemp(int n);
  115. static void releaseAllTemps();
  116. static int is_tmp_expr(NodeType *node) {
  117. if (node->str) {
  118. return (!strncmp(node->str,"_i_tmp_",7))
  119. || (!strncmp(node->str,"_f_tmp_",7))
  120. || (!strncmp(node->str,"_p_tmp",7));
  121. }
  122. return 0;
  123. }
  124. /* pre: is_tmp_expr(node); */
  125. static int get_tmp_id(NodeType *node) { return atoi((node->str)+5); }
  126. static int is_commutative_expr(int itype)
  127. { /* {{{ */
  128. return (itype == INSTR_ADD)
  129. || (itype == INSTR_MUL)
  130. || (itype == INSTR_ISEQUAL);
  131. } /* }}} */
  132. static void GSL_PUT_LABEL(char *name, int line_number)
  133. { /* {{{ */
  134. #ifdef VERBOSE
  135. printf("label %s\n", name);
  136. #endif
  137. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "label", INSTR_LABEL, 1, line_number);
  138. gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL);
  139. } /* }}} */
  140. static void GSL_PUT_JUMP(char *name, int line_number)
  141. { /* {{{ */
  142. #ifdef VERBOSE
  143. printf("jump %s\n", name);
  144. #endif
  145. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "jump", INSTR_JUMP, 1, line_number);
  146. gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL);
  147. } /* }}} */
  148. static void GSL_PUT_JXXX(char *name, char *iname, int instr_id, int line_number)
  149. { /* {{{ */
  150. #ifdef VERBOSE
  151. printf("%s %s\n", iname, name);
  152. #endif
  153. currentGoomSL->instr = gsl_instr_init(currentGoomSL, iname, instr_id, 1, line_number);
  154. gsl_instr_add_param(currentGoomSL->instr, name, TYPE_LABEL);
  155. } /* }}} */
  156. static void GSL_PUT_JZERO(char *name,int line_number)
  157. { /* {{{ */
  158. GSL_PUT_JXXX(name,"jzero.i",INSTR_JZERO,line_number);
  159. } /* }}} */
  160. static void GSL_PUT_JNZERO(char *name, int line_number)
  161. { /* {{{ */
  162. GSL_PUT_JXXX(name,"jnzero.i",INSTR_JNZERO,line_number);
  163. } /* }}} */
  164. /* Structures Management */
  165. #define ALIGN_ADDR(_addr,_align) {\
  166. if (_align>1) {\
  167. int _dec = (_addr%_align);\
  168. if (_dec != 0) _addr += _align - _dec;\
  169. }}
  170. /* */
  171. void gsl_prepare_struct(GSL_Struct *s, int s_align, int i_align, int f_align)
  172. {
  173. int i;
  174. int consumed = 0;
  175. int iblk=0, fblk=0;
  176. s->iBlock[0].size = 0;
  177. s->iBlock[0].data = 0;
  178. s->fBlock[0].size = 0;
  179. s->fBlock[0].data = 0;
  180. /* Prepare sub-struct and calculate space needed for their storage */
  181. for (i = 0; i < s->nbFields; ++i)
  182. {
  183. if (s->fields[i]->type < FIRST_RESERVED)
  184. {
  185. int j=0;
  186. GSL_Struct *substruct = currentGoomSL->gsl_struct[s->fields[i]->type];
  187. consumed += sizeof(int); /* stocke le prefix */
  188. ALIGN_ADDR(consumed, s_align);
  189. s->fields[i]->offsetInStruct = consumed;
  190. gsl_prepare_struct(substruct, s_align, i_align, f_align);
  191. for(j=0;substruct->iBlock[j].size>0;++j) {
  192. s->iBlock[iblk].data = consumed + substruct->iBlock[j].data;
  193. s->iBlock[iblk].size = substruct->iBlock[j].size;
  194. iblk++;
  195. }
  196. for(j=0;substruct->fBlock[j].size>0;++j) {
  197. s->fBlock[fblk].data = consumed + substruct->fBlock[j].data;
  198. s->fBlock[fblk].size = substruct->fBlock[j].size;
  199. fblk++;
  200. }
  201. consumed += substruct->size;
  202. }
  203. }
  204. /* Then prepare integers */
  205. ALIGN_ADDR(consumed, i_align);
  206. for (i = 0; i < s->nbFields; ++i)
  207. {
  208. if (s->fields[i]->type == INSTR_INT)
  209. {
  210. if (s->iBlock[iblk].size == 0) {
  211. s->iBlock[iblk].size = 1;
  212. s->iBlock[iblk].data = consumed;
  213. } else {
  214. s->iBlock[iblk].size += 1;
  215. }
  216. s->fields[i]->offsetInStruct = consumed;
  217. consumed += sizeof(int);
  218. }
  219. }
  220. iblk++;
  221. s->iBlock[iblk].size = 0;
  222. s->iBlock[iblk].data = 0;
  223. /* Then prepare floats */
  224. ALIGN_ADDR(consumed, f_align);
  225. for (i = 0; i < s->nbFields; ++i)
  226. {
  227. if (s->fields[i]->type == INSTR_FLOAT)
  228. {
  229. if (s->fBlock[fblk].size == 0) {
  230. s->fBlock[fblk].size = 1;
  231. s->fBlock[fblk].data = consumed;
  232. } else {
  233. s->fBlock[fblk].size += 1;
  234. }
  235. s->fields[i]->offsetInStruct = consumed;
  236. consumed += sizeof(int);
  237. }
  238. }
  239. fblk++;
  240. s->fBlock[fblk].size = 0;
  241. s->fBlock[fblk].data = 0;
  242. /* Finally prepare pointers */
  243. ALIGN_ADDR(consumed, i_align);
  244. for (i = 0; i < s->nbFields; ++i)
  245. {
  246. if (s->fields[i]->type == INSTR_PTR)
  247. {
  248. s->fields[i]->offsetInStruct = consumed;
  249. consumed += sizeof(int);
  250. }
  251. }
  252. s->size = consumed;
  253. }
  254. /* Returns the ID of a struct from its name */
  255. int gsl_get_struct_id(const char *name) /* {{{ */
  256. {
  257. HashValue *ret = goom_hash_get(currentGoomSL->structIDS, name);
  258. if (ret != NULL) return ret->i;
  259. return -1;
  260. } /* }}} */
  261. /* Adds the definition of a struct */
  262. void gsl_add_struct(const char *name, GSL_Struct *gsl_struct) /* {{{ */
  263. {
  264. /* Prepare the struct: ie calculate internal storage format */
  265. gsl_prepare_struct(gsl_struct, STRUCT_ALIGNMENT, STRUCT_ALIGNMENT, STRUCT_ALIGNMENT);
  266. /* If the struct does not already exists */
  267. if (gsl_get_struct_id(name) < 0)
  268. {
  269. /* adds it */
  270. int id = currentGoomSL->nbStructID++;
  271. goom_hash_put_int(currentGoomSL->structIDS, name, id);
  272. if (currentGoomSL->gsl_struct_size <= id) {
  273. currentGoomSL->gsl_struct_size *= 2;
  274. currentGoomSL->gsl_struct = (GSL_Struct**)realloc(currentGoomSL->gsl_struct,
  275. sizeof(GSL_Struct*) * currentGoomSL->gsl_struct_size);
  276. }
  277. currentGoomSL->gsl_struct[id] = gsl_struct;
  278. }
  279. } /* }}} */
  280. /* Creates a field for a struct */
  281. GSL_StructField *gsl_new_struct_field(const char *name, int type)
  282. {
  283. GSL_StructField *field = (GSL_StructField*)malloc(sizeof(GSL_StructField));
  284. strcpy(field->name, name);
  285. field->type = type;
  286. return field;
  287. }
  288. /* Create as field for a struct which will be a struct itself */
  289. GSL_StructField *gsl_new_struct_field_struct(const char *name, const char *type)
  290. {
  291. GSL_StructField *field = gsl_new_struct_field(name, gsl_get_struct_id(type));
  292. if (field->type < 0) {
  293. fprintf(stderr, "ERROR: Line %d, Unknown structure: '%s'\n",
  294. currentGoomSL->num_lines, type);
  295. exit(1);
  296. }
  297. return field;
  298. }
  299. /* Creates a Struct */
  300. GSL_Struct *gsl_new_struct(GSL_StructField *field)
  301. {
  302. GSL_Struct *s = (GSL_Struct*)malloc(sizeof(GSL_Struct));
  303. s->nbFields = 1;
  304. s->fields[0] = field;
  305. return s;
  306. }
  307. /* Adds a field to a struct */
  308. void gsl_add_struct_field(GSL_Struct *s, GSL_StructField *field)
  309. {
  310. s->fields[s->nbFields++] = field;
  311. }
  312. int gsl_type_of_var(GoomHash *ns, const char *name)
  313. {
  314. char type_of[256];
  315. HashValue *hv;
  316. sprintf(type_of, "__type_of_%s", name);
  317. hv = goom_hash_get(ns, type_of);
  318. if (hv != NULL)
  319. return hv->i;
  320. fprintf(stderr, "ERROR: Unknown variable type: '%s'\n", name);
  321. return -1;
  322. }
  323. static void gsl_declare_var(GoomHash *ns, const char *name, int type, void *space)
  324. {
  325. char type_of[256];
  326. if (name[0] == '@') { ns = currentGoomSL->vars; }
  327. if (space == NULL) {
  328. switch (type) {
  329. case INSTR_INT:
  330. case INSTR_FLOAT:
  331. case INSTR_PTR:
  332. space = goom_heap_malloc_with_alignment(currentGoomSL->data_heap,
  333. sizeof(int), sizeof(int));
  334. break;
  335. case -1:
  336. fprintf(stderr, "What the fuck!\n");
  337. exit(1);
  338. default: /* On a un struct_id */
  339. space = goom_heap_malloc_with_alignment_prefixed(currentGoomSL->data_heap,
  340. currentGoomSL->gsl_struct[type]->size, STRUCT_ALIGNMENT, sizeof(int));
  341. }
  342. }
  343. goom_hash_put_ptr(ns, name, (void*)space);
  344. sprintf(type_of, "__type_of_%s", name);
  345. goom_hash_put_int(ns, type_of, type);
  346. /* Ensuite le hack: on ajoute les champs en tant que variables. */
  347. if (type < FIRST_RESERVED)
  348. {
  349. int i;
  350. GSL_Struct *gsl_struct = currentGoomSL->gsl_struct[type];
  351. ((int*)space)[-1] = type; /* stockage du type dans le prefixe de structure */
  352. for (i = 0; i < gsl_struct->nbFields; ++i)
  353. {
  354. char full_name[256];
  355. char *cspace = (char*)space + gsl_struct->fields[i]->offsetInStruct;
  356. sprintf(full_name, "%s.%s", name, gsl_struct->fields[i]->name);
  357. gsl_declare_var(ns, full_name, gsl_struct->fields[i]->type, cspace);
  358. }
  359. }
  360. }
  361. /* Declare a variable which will be a struct */
  362. static void gsl_struct_decl(GoomHash *namespace, const char *struct_name, const char *name)
  363. {
  364. int struct_id = gsl_get_struct_id(struct_name);
  365. gsl_declare_var(namespace, name, struct_id, NULL);
  366. }
  367. static void gsl_float_decl_global(const char *name)
  368. {
  369. gsl_declare_var(currentGoomSL->vars, name, INSTR_FLOAT, NULL);
  370. }
  371. static void gsl_int_decl_global(const char *name)
  372. {
  373. gsl_declare_var(currentGoomSL->vars, name, INSTR_INT, NULL);
  374. }
  375. static void gsl_ptr_decl_global(const char *name)
  376. {
  377. gsl_declare_var(currentGoomSL->vars, name, INSTR_PTR, NULL);
  378. }
  379. static void gsl_struct_decl_global_from_id(const char *name, int id)
  380. {
  381. gsl_declare_var(currentGoomSL->vars, name, id, NULL);
  382. }
  383. /* FLOAT */
  384. static void gsl_float_decl_local(const char *name)
  385. {
  386. gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_FLOAT, NULL);
  387. }
  388. /* INT */
  389. static void gsl_int_decl_local(const char *name)
  390. {
  391. gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_INT, NULL);
  392. }
  393. /* PTR */
  394. static void gsl_ptr_decl_local(const char *name)
  395. {
  396. gsl_declare_var(currentGoomSL->namespaces[currentGoomSL->currentNS], name, INSTR_PTR, NULL);
  397. }
  398. /* STRUCT */
  399. static void gsl_struct_decl_local(const char *struct_name, const char *name)
  400. {
  401. gsl_struct_decl(currentGoomSL->namespaces[currentGoomSL->currentNS],struct_name,name);
  402. }
  403. static void commit_test2(NodeType *set,const char *type, int instr);
  404. static NodeType *new_call(const char *name, NodeType *affect_list);
  405. /* SETTER */
  406. static NodeType *new_set(NodeType *lvalue, NodeType *expression)
  407. { /* {{{ */
  408. NodeType *set = new_op("set", OPR_SET, 2);
  409. set->unode.opr.op[0] = lvalue;
  410. set->unode.opr.op[1] = expression;
  411. return set;
  412. } /* }}} */
  413. static void commit_set(NodeType *set)
  414. { /* {{{ */
  415. commit_test2(set,"set",INSTR_SET);
  416. } /* }}} */
  417. /* PLUS_EQ */
  418. static NodeType *new_plus_eq(NodeType *lvalue, NodeType *expression) /* {{{ */
  419. {
  420. NodeType *set = new_op("plus_eq", OPR_PLUS_EQ, 2);
  421. set->unode.opr.op[0] = lvalue;
  422. set->unode.opr.op[1] = expression;
  423. return set;
  424. }
  425. static void commit_plus_eq(NodeType *set)
  426. {
  427. precommit_node(set->unode.opr.op[1]);
  428. #ifdef VERBOSE
  429. printf("add %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str);
  430. #endif
  431. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "add", INSTR_ADD, 2, set->line_number);
  432. commit_node(set->unode.opr.op[0],0);
  433. commit_node(set->unode.opr.op[1],1);
  434. } /* }}} */
  435. /* SUB_EQ */
  436. static NodeType *new_sub_eq(NodeType *lvalue, NodeType *expression) /* {{{ */
  437. {
  438. NodeType *set = new_op("sub_eq", OPR_SUB_EQ, 2);
  439. set->unode.opr.op[0] = lvalue;
  440. set->unode.opr.op[1] = expression;
  441. return set;
  442. }
  443. static void commit_sub_eq(NodeType *set)
  444. {
  445. precommit_node(set->unode.opr.op[1]);
  446. #ifdef VERBOSE
  447. printf("sub %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str);
  448. #endif
  449. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "sub", INSTR_SUB, 2, set->line_number);
  450. commit_node(set->unode.opr.op[0],0);
  451. commit_node(set->unode.opr.op[1],1);
  452. } /* }}} */
  453. /* MUL_EQ */
  454. static NodeType *new_mul_eq(NodeType *lvalue, NodeType *expression) /* {{{ */
  455. {
  456. NodeType *set = new_op("mul_eq", OPR_MUL_EQ, 2);
  457. set->unode.opr.op[0] = lvalue;
  458. set->unode.opr.op[1] = expression;
  459. return set;
  460. }
  461. static void commit_mul_eq(NodeType *set)
  462. {
  463. precommit_node(set->unode.opr.op[1]);
  464. #ifdef VERBOSE
  465. printf("mul %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str);
  466. #endif
  467. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "mul", INSTR_MUL, 2, set->line_number);
  468. commit_node(set->unode.opr.op[0],0);
  469. commit_node(set->unode.opr.op[1],1);
  470. } /* }}} */
  471. /* DIV_EQ */
  472. static NodeType *new_div_eq(NodeType *lvalue, NodeType *expression) /* {{{ */
  473. {
  474. NodeType *set = new_op("div_eq", OPR_DIV_EQ, 2);
  475. set->unode.opr.op[0] = lvalue;
  476. set->unode.opr.op[1] = expression;
  477. return set;
  478. }
  479. static void commit_div_eq(NodeType *set)
  480. {
  481. precommit_node(set->unode.opr.op[1]);
  482. #ifdef VERBOSE
  483. printf("div %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str);
  484. #endif
  485. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "div", INSTR_DIV, 2, set->line_number);
  486. commit_node(set->unode.opr.op[0],0);
  487. commit_node(set->unode.opr.op[1],1);
  488. } /* }}} */
  489. /* commodity method for add, mult, ... */
  490. static void precommit_expr(NodeType *expr, const char *type, int instr_id)
  491. { /* {{{ */
  492. NodeType *tmp, *tmpcpy;
  493. int toAdd;
  494. /* compute "left" and "right" */
  495. switch (expr->unode.opr.nbOp) {
  496. case 2:
  497. precommit_node(expr->unode.opr.op[1]);
  498. case 1:
  499. precommit_node(expr->unode.opr.op[0]);
  500. }
  501. if (is_tmp_expr(expr->unode.opr.op[0])) {
  502. tmp = expr->unode.opr.op[0];
  503. toAdd = 1;
  504. }
  505. else if (is_commutative_expr(instr_id) && (expr->unode.opr.nbOp==2) && is_tmp_expr(expr->unode.opr.op[1])) {
  506. tmp = expr->unode.opr.op[1];
  507. toAdd = 0;
  508. }
  509. else {
  510. char stmp[256];
  511. /* declare a temporary variable to store the result */
  512. if (expr->unode.opr.op[0]->type == CONST_INT_NODE) {
  513. sprintf(stmp,"_i_tmp_%i",allocateTemp());
  514. gsl_int_decl_global(stmp);
  515. }
  516. else if (expr->unode.opr.op[0]->type == CONST_FLOAT_NODE) {
  517. sprintf(stmp,"_f_tmp%i",allocateTemp());
  518. gsl_float_decl_global(stmp);
  519. }
  520. else if (expr->unode.opr.op[0]->type == CONST_PTR_NODE) {
  521. sprintf(stmp,"_p_tmp%i",allocateTemp());
  522. gsl_ptr_decl_global(stmp);
  523. }
  524. else {
  525. int type = gsl_type_of_var(expr->unode.opr.op[0]->vnamespace, expr->unode.opr.op[0]->str);
  526. if (type == INSTR_FLOAT) {
  527. sprintf(stmp,"_f_tmp_%i",allocateTemp());
  528. gsl_float_decl_global(stmp);
  529. }
  530. else if (type == INSTR_PTR) {
  531. sprintf(stmp,"_p_tmp_%i",allocateTemp());
  532. gsl_ptr_decl_global(stmp);
  533. }
  534. else if (type == INSTR_INT) {
  535. sprintf(stmp,"_i_tmp_%i",allocateTemp());
  536. gsl_int_decl_global(stmp);
  537. }
  538. else if (type == -1) {
  539. fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n",
  540. expr->line_number, expr->unode.opr.op[0]->str);
  541. exit(1);
  542. }
  543. else { /* type is a struct_id */
  544. sprintf(stmp,"_s_tmp_%i",allocateTemp());
  545. gsl_struct_decl_global_from_id(stmp,type);
  546. }
  547. }
  548. tmp = new_var(stmp,expr->line_number);
  549. /* set the tmp to the value of "op1" */
  550. tmpcpy = nodeClone(tmp);
  551. commit_node(new_set(tmp,expr->unode.opr.op[0]),0);
  552. toAdd = 1;
  553. tmp = tmpcpy;
  554. }
  555. /* add op2 to tmp */
  556. #ifdef VERBOSE
  557. if (expr->unode.opr.nbOp == 2)
  558. printf("%s %s %s\n", type, tmp->str, expr->unode.opr.op[toAdd]->str);
  559. else
  560. printf("%s %s\n", type, tmp->str);
  561. #endif
  562. currentGoomSL->instr = gsl_instr_init(currentGoomSL, type, instr_id, expr->unode.opr.nbOp, expr->line_number);
  563. tmpcpy = nodeClone(tmp);
  564. commit_node(tmp,0);
  565. if (expr->unode.opr.nbOp == 2) {
  566. commit_node(expr->unode.opr.op[toAdd],1);
  567. }
  568. /* redefine the ADD node now as the computed variable */
  569. nodeFreeInternals(expr);
  570. *expr = *tmpcpy;
  571. free(tmpcpy);
  572. } /* }}} */
  573. static NodeType *new_expr1(const char *name, int id, NodeType *expr1)
  574. { /* {{{ */
  575. NodeType *add = new_op(name, id, 1);
  576. add->unode.opr.op[0] = expr1;
  577. return add;
  578. } /* }}} */
  579. static NodeType *new_expr2(const char *name, int id, NodeType *expr1, NodeType *expr2)
  580. { /* {{{ */
  581. NodeType *add = new_op(name, id, 2);
  582. add->unode.opr.op[0] = expr1;
  583. add->unode.opr.op[1] = expr2;
  584. return add;
  585. } /* }}} */
  586. /* ADD */
  587. static NodeType *new_add(NodeType *expr1, NodeType *expr2) { /* {{{ */
  588. return new_expr2("add", OPR_ADD, expr1, expr2);
  589. }
  590. static void precommit_add(NodeType *add) {
  591. precommit_expr(add,"add",INSTR_ADD);
  592. } /* }}} */
  593. /* SUB */
  594. static NodeType *new_sub(NodeType *expr1, NodeType *expr2) { /* {{{ */
  595. return new_expr2("sub", OPR_SUB, expr1, expr2);
  596. }
  597. static void precommit_sub(NodeType *sub) {
  598. precommit_expr(sub,"sub",INSTR_SUB);
  599. } /* }}} */
  600. /* NEG */
  601. static NodeType *new_neg(NodeType *expr) { /* {{{ */
  602. NodeType *zeroConst = NULL;
  603. if (expr->type == CONST_INT_NODE)
  604. zeroConst = new_constInt("0", currentGoomSL->num_lines);
  605. else if (expr->type == CONST_FLOAT_NODE)
  606. zeroConst = new_constFloat("0.0", currentGoomSL->num_lines);
  607. else if (expr->type == CONST_PTR_NODE) {
  608. fprintf(stderr, "ERROR: Line %d, Could not negate const pointer.\n",
  609. currentGoomSL->num_lines);
  610. exit(1);
  611. }
  612. else {
  613. int type = gsl_type_of_var(expr->vnamespace, expr->str);
  614. if (type == INSTR_FLOAT)
  615. zeroConst = new_constFloat("0.0", currentGoomSL->num_lines);
  616. else if (type == INSTR_PTR) {
  617. fprintf(stderr, "ERROR: Line %d, Could not negate pointer.\n",
  618. currentGoomSL->num_lines);
  619. exit(1);
  620. }
  621. else if (type == INSTR_INT)
  622. zeroConst = new_constInt("0", currentGoomSL->num_lines);
  623. else if (type == -1) {
  624. fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n",
  625. expr->line_number, expr->unode.opr.op[0]->str);
  626. exit(1);
  627. }
  628. else { /* type is a struct_id */
  629. fprintf(stderr, "ERROR: Line %d, Could not negate struct '%s'\n",
  630. expr->line_number, expr->str);
  631. exit(1);
  632. }
  633. }
  634. return new_expr2("sub", OPR_SUB, zeroConst, expr);
  635. }
  636. /* }}} */
  637. /* MUL */
  638. static NodeType *new_mul(NodeType *expr1, NodeType *expr2) { /* {{{ */
  639. return new_expr2("mul", OPR_MUL, expr1, expr2);
  640. }
  641. static void precommit_mul(NodeType *mul) {
  642. precommit_expr(mul,"mul",INSTR_MUL);
  643. } /* }}} */
  644. /* DIV */
  645. static NodeType *new_div(NodeType *expr1, NodeType *expr2) { /* {{{ */
  646. return new_expr2("div", OPR_DIV, expr1, expr2);
  647. }
  648. static void precommit_div(NodeType *mul) {
  649. precommit_expr(mul,"div",INSTR_DIV);
  650. } /* }}} */
  651. /* CALL EXPRESSION */
  652. static NodeType *new_call_expr(const char *name, NodeType *affect_list) { /* {{{ */
  653. NodeType *call = new_call(name,affect_list);
  654. NodeType *node = new_expr1(name, OPR_CALL_EXPR, call);
  655. node->vnamespace = gsl_find_namespace(name);
  656. if (node->vnamespace == NULL)
  657. fprintf(stderr, "ERROR: Line %d, No return type for: '%s'\n", currentGoomSL->num_lines, name);
  658. return node;
  659. }
  660. static void precommit_call_expr(NodeType *call) {
  661. char stmp[256];
  662. NodeType *tmp,*tmpcpy;
  663. int type = gsl_type_of_var(call->vnamespace, call->str);
  664. if (type == INSTR_FLOAT) {
  665. sprintf(stmp,"_f_tmp_%i",allocateTemp());
  666. gsl_float_decl_global(stmp);
  667. }
  668. else if (type == INSTR_PTR) {
  669. sprintf(stmp,"_p_tmp_%i",allocateTemp());
  670. gsl_ptr_decl_global(stmp);
  671. }
  672. else if (type == INSTR_INT) {
  673. sprintf(stmp,"_i_tmp_%i",allocateTemp());
  674. gsl_int_decl_global(stmp);
  675. }
  676. else if (type == -1) {
  677. fprintf(stderr, "ERROR: Line %d, Could not find variable '%s'\n",
  678. call->line_number, call->str);
  679. exit(1);
  680. }
  681. else { /* type is a struct_id */
  682. sprintf(stmp,"_s_tmp_%i",allocateTemp());
  683. gsl_struct_decl_global_from_id(stmp,type);
  684. }
  685. tmp = new_var(stmp,call->line_number);
  686. commit_node(call->unode.opr.op[0],0);
  687. tmpcpy = nodeClone(tmp);
  688. commit_node(new_set(tmp,new_var(call->str,call->line_number)),0);
  689. nodeFreeInternals(call);
  690. *call = *tmpcpy;
  691. free(tmpcpy);
  692. } /* }}} */
  693. static void commit_test2(NodeType *set,const char *type, int instr)
  694. { /* {{{ */
  695. NodeType *tmp;
  696. char stmp[256];
  697. precommit_node(set->unode.opr.op[0]);
  698. precommit_node(set->unode.opr.op[1]);
  699. tmp = set->unode.opr.op[0];
  700. stmp[0] = 0;
  701. if (set->unode.opr.op[0]->type == CONST_INT_NODE) {
  702. sprintf(stmp,"_i_tmp_%i",allocateTemp());
  703. gsl_int_decl_global(stmp);
  704. }
  705. else if (set->unode.opr.op[0]->type == CONST_FLOAT_NODE) {
  706. sprintf(stmp,"_f_tmp%i",allocateTemp());
  707. gsl_float_decl_global(stmp);
  708. }
  709. else if (set->unode.opr.op[0]->type == CONST_PTR_NODE) {
  710. sprintf(stmp,"_p_tmp%i",allocateTemp());
  711. gsl_ptr_decl_global(stmp);
  712. }
  713. if (stmp[0]) {
  714. NodeType *tmpcpy;
  715. tmp = new_var(stmp, set->line_number);
  716. tmpcpy = nodeClone(tmp);
  717. commit_node(new_set(tmp,set->unode.opr.op[0]),0);
  718. tmp = tmpcpy;
  719. }
  720. #ifdef VERBOSE
  721. printf("%s %s %s\n", type, tmp->str, set->unode.opr.op[1]->str);
  722. #endif
  723. currentGoomSL->instr = gsl_instr_init(currentGoomSL, type, instr, 2, set->line_number);
  724. commit_node(tmp,instr!=INSTR_SET);
  725. commit_node(set->unode.opr.op[1],1);
  726. } /* }}} */
  727. /* NOT */
  728. static NodeType *new_not(NodeType *expr1) { /* {{{ */
  729. return new_expr1("not", OPR_NOT, expr1);
  730. }
  731. static void commit_not(NodeType *set)
  732. {
  733. commit_node(set->unode.opr.op[0],0);
  734. #ifdef VERBOSE
  735. printf("not\n");
  736. #endif
  737. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "not", INSTR_NOT, 1, set->line_number);
  738. gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL);
  739. } /* }}} */
  740. /* EQU */
  741. static NodeType *new_equ(NodeType *expr1, NodeType *expr2) { /* {{{ */
  742. return new_expr2("isequal", OPR_EQU, expr1, expr2);
  743. }
  744. static void commit_equ(NodeType *mul) {
  745. commit_test2(mul,"isequal",INSTR_ISEQUAL);
  746. } /* }}} */
  747. /* INF */
  748. static NodeType *new_low(NodeType *expr1, NodeType *expr2) { /* {{{ */
  749. return new_expr2("islower", OPR_LOW, expr1, expr2);
  750. }
  751. static void commit_low(NodeType *mul) {
  752. commit_test2(mul,"islower",INSTR_ISLOWER);
  753. } /* }}} */
  754. /* WHILE */
  755. static NodeType *new_while(NodeType *expression, NodeType *instr) { /* {{{ */
  756. NodeType *node = new_op("while", OPR_WHILE, 2);
  757. node->unode.opr.op[0] = expression;
  758. node->unode.opr.op[1] = instr;
  759. return node;
  760. }
  761. static void commit_while(NodeType *node)
  762. {
  763. int lbl = allocateLabel();
  764. char start_while[1024], test_while[1024];
  765. sprintf(start_while, "|start_while_%d|", lbl);
  766. sprintf(test_while, "|test_while_%d|", lbl);
  767. GSL_PUT_JUMP(test_while,node->line_number);
  768. GSL_PUT_LABEL(start_while,node->line_number);
  769. /* code */
  770. commit_node(node->unode.opr.op[1],0);
  771. GSL_PUT_LABEL(test_while,node->line_number);
  772. commit_node(node->unode.opr.op[0],0);
  773. GSL_PUT_JNZERO(start_while,node->line_number);
  774. } /* }}} */
  775. /* FOR EACH */
  776. static NodeType *new_static_foreach(NodeType *var, NodeType *var_list, NodeType *instr) { /* {{{ */
  777. NodeType *node = new_op("for", OPR_FOREACH, 3);
  778. node->unode.opr.op[0] = var;
  779. node->unode.opr.op[1] = var_list;
  780. node->unode.opr.op[2] = instr;
  781. node->line_number = currentGoomSL->num_lines;
  782. return node;
  783. }
  784. static void commit_foreach(NodeType *node)
  785. {
  786. NodeType *cur = node->unode.opr.op[1];
  787. char tmp_func[256], tmp_loop[256];
  788. int lbl = allocateLabel();
  789. sprintf(tmp_func, "|foreach_func_%d|", lbl);
  790. sprintf(tmp_loop, "|foreach_loop_%d|", lbl);
  791. GSL_PUT_JUMP(tmp_loop, node->line_number);
  792. GSL_PUT_LABEL(tmp_func, node->line_number);
  793. precommit_node(node->unode.opr.op[2]);
  794. commit_node(node->unode.opr.op[2], 0);
  795. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "ret", INSTR_RET, 1, node->line_number);
  796. gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL);
  797. #ifdef VERBOSE
  798. printf("ret\n");
  799. #endif
  800. GSL_PUT_LABEL(tmp_loop, node->line_number);
  801. while (cur != NULL)
  802. {
  803. NodeType *x, *var;
  804. /* 1: x=var */
  805. x = nodeClone(node->unode.opr.op[0]);
  806. var = nodeClone(cur->unode.opr.op[0]);
  807. commit_node(new_set(x, var),0);
  808. /* 2: instr */
  809. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "call", INSTR_CALL, 1, node->line_number);
  810. gsl_instr_add_param(currentGoomSL->instr, tmp_func, TYPE_LABEL);
  811. #ifdef VERBOSE
  812. printf("call %s\n", tmp_func);
  813. #endif
  814. /* 3: var=x */
  815. x = nodeClone(node->unode.opr.op[0]);
  816. var = cur->unode.opr.op[0];
  817. commit_node(new_set(var, x),0);
  818. cur = cur->unode.opr.op[1];
  819. }
  820. nodeFree(node->unode.opr.op[0]);
  821. } /* }}} */
  822. /* IF */
  823. static NodeType *new_if(NodeType *expression, NodeType *instr) { /* {{{ */
  824. NodeType *node = new_op("if", OPR_IF, 2);
  825. node->unode.opr.op[0] = expression;
  826. node->unode.opr.op[1] = instr;
  827. return node;
  828. }
  829. static void commit_if(NodeType *node) {
  830. char slab[1024];
  831. sprintf(slab, "|eif%d|", allocateLabel());
  832. commit_node(node->unode.opr.op[0],0);
  833. GSL_PUT_JZERO(slab,node->line_number);
  834. /* code */
  835. commit_node(node->unode.opr.op[1],0);
  836. GSL_PUT_LABEL(slab,node->line_number);
  837. } /* }}} */
  838. /* BLOCK */
  839. static NodeType *new_block(NodeType *lastNode) { /* {{{ */
  840. NodeType *blk = new_op("block", OPR_BLOCK, 2);
  841. blk->unode.opr.op[0] = new_nop("start_of_block");
  842. blk->unode.opr.op[1] = lastNode;
  843. return blk;
  844. }
  845. static void commit_block(NodeType *node) {
  846. commit_node(node->unode.opr.op[0]->unode.opr.next,0);
  847. } /* }}} */
  848. /* FUNCTION INTRO */
  849. static NodeType *new_function_intro(const char *name) { /* {{{ */
  850. char stmp[256];
  851. if (strlen(name) < 200) {
  852. sprintf(stmp, "|__func_%s|", name);
  853. }
  854. return new_op(stmp, OPR_FUNC_INTRO, 0);
  855. }
  856. static void commit_function_intro(NodeType *node) {
  857. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "label", INSTR_LABEL, 1, node->line_number);
  858. gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_LABEL);
  859. #ifdef VERBOSE
  860. printf("label %s\n", node->str);
  861. #endif
  862. } /* }}} */
  863. /* FUNCTION OUTRO */
  864. static NodeType *new_function_outro() { /* {{{ */
  865. return new_op("ret", OPR_FUNC_OUTRO, 0);
  866. }
  867. static void commit_function_outro(NodeType *node) {
  868. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "ret", INSTR_RET, 1, node->line_number);
  869. gsl_instr_add_param(currentGoomSL->instr, "|dummy|", TYPE_LABEL);
  870. releaseAllTemps();
  871. #ifdef VERBOSE
  872. printf("ret\n");
  873. #endif
  874. } /* }}} */
  875. /* AFFECTATION LIST */
  876. static NodeType *new_affec_list(NodeType *set, NodeType *next) /* {{{ */
  877. {
  878. NodeType *node = new_op("affect_list", OPR_AFFECT_LIST, 2);
  879. node->unode.opr.op[0] = set;
  880. node->unode.opr.op[1] = next;
  881. return node;
  882. }
  883. static NodeType *new_affect_list_after(NodeType *affect_list)
  884. {
  885. NodeType *ret = NULL;
  886. NodeType *cur = affect_list;
  887. while(cur != NULL) {
  888. NodeType *set = cur->unode.opr.op[0];
  889. NodeType *next = cur->unode.opr.op[1];
  890. NodeType *lvalue = set->unode.opr.op[0];
  891. NodeType *expression = set->unode.opr.op[1];
  892. if ((lvalue->str[0] == '&') && (expression->type == VAR_NODE)) {
  893. NodeType *nset = new_set(nodeClone(expression), nodeClone(lvalue));
  894. ret = new_affec_list(nset, ret);
  895. }
  896. cur = next;
  897. }
  898. return ret;
  899. }
  900. static void commit_affect_list(NodeType *node)
  901. {
  902. NodeType *cur = node;
  903. while(cur != NULL) {
  904. NodeType *set = cur->unode.opr.op[0];
  905. precommit_node(set->unode.opr.op[0]);
  906. precommit_node(set->unode.opr.op[1]);
  907. cur = cur->unode.opr.op[1];
  908. }
  909. cur = node;
  910. while(cur != NULL) {
  911. NodeType *set = cur->unode.opr.op[0];
  912. commit_node(set,0);
  913. cur = cur->unode.opr.op[1];
  914. }
  915. } /* }}} */
  916. /* VAR LIST */
  917. static NodeType *new_var_list(NodeType *var, NodeType *next) /* {{{ */
  918. {
  919. NodeType *node = new_op("var_list", OPR_VAR_LIST, 2);
  920. node->unode.opr.op[0] = var;
  921. node->unode.opr.op[1] = next;
  922. return node;
  923. }
  924. static void commit_var_list(NodeType *node)
  925. {
  926. } /* }}} */
  927. /* FUNCTION CALL */
  928. static NodeType *new_call(const char *name, NodeType *affect_list) { /* {{{ */
  929. HashValue *fval;
  930. fval = goom_hash_get(currentGoomSL->functions, name);
  931. if (!fval) {
  932. gsl_declare_task(name);
  933. fval = goom_hash_get(currentGoomSL->functions, name);
  934. }
  935. if (!fval) {
  936. fprintf(stderr, "ERROR: Line %d, Could not find function %s\n", currentGoomSL->num_lines, name);
  937. exit(1);
  938. return NULL;
  939. }
  940. else {
  941. ExternalFunctionStruct *gef = (ExternalFunctionStruct*)fval->ptr;
  942. if (gef->is_extern) {
  943. NodeType *node = new_op(name, OPR_EXT_CALL, 1);
  944. node->unode.opr.op[0] = affect_list;
  945. return node;
  946. }
  947. else {
  948. NodeType *node;
  949. char stmp[256];
  950. if (strlen(name) < 200) {
  951. sprintf(stmp, "|__func_%s|", name);
  952. }
  953. node = new_op(stmp, OPR_CALL, 1);
  954. node->unode.opr.op[0] = affect_list;
  955. return node;
  956. }
  957. }
  958. }
  959. static void commit_ext_call(NodeType *node) {
  960. NodeType *alafter = new_affect_list_after(node->unode.opr.op[0]);
  961. commit_node(node->unode.opr.op[0],0);
  962. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "extcall", INSTR_EXT_CALL, 1, node->line_number);
  963. gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_VAR);
  964. #ifdef VERBOSE
  965. printf("extcall %s\n", node->str);
  966. #endif
  967. commit_node(alafter,0);
  968. }
  969. static void commit_call(NodeType *node) {
  970. NodeType *alafter = new_affect_list_after(node->unode.opr.op[0]);
  971. commit_node(node->unode.opr.op[0],0);
  972. currentGoomSL->instr = gsl_instr_init(currentGoomSL, "call", INSTR_CALL, 1, node->line_number);
  973. gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_LABEL);
  974. #ifdef VERBOSE
  975. printf("call %s\n", node->str);
  976. #endif
  977. commit_node(alafter,0);
  978. } /* }}} */
  979. /** **/
  980. static NodeType *rootNode = 0; /* TODO: reinitialiser a chaque compilation. */
  981. static NodeType *lastNode = 0;
  982. static NodeType *gsl_append(NodeType *curNode) {
  983. if (curNode == 0) return 0; /* {{{ */
  984. if (lastNode)
  985. lastNode->unode.opr.next = curNode;
  986. lastNode = curNode;
  987. while(lastNode->unode.opr.next) lastNode = lastNode->unode.opr.next;
  988. if (rootNode == 0)
  989. rootNode = curNode;
  990. return curNode;
  991. } /* }}} */
  992. #if 1
  993. int allocateTemp() {
  994. return allocateLabel();
  995. }
  996. void releaseAllTemps() {}
  997. void releaseTemp(int n) {}
  998. #else
  999. static int nbTemp = 0;
  1000. static int *tempArray = 0;
  1001. static int tempArraySize = 0;
  1002. int allocateTemp() { /* TODO: allocateITemp, allocateFTemp */
  1003. int i = 0; /* {{{ */
  1004. if (tempArray == 0) {
  1005. tempArraySize = 256;
  1006. tempArray = (int*)malloc(tempArraySize * sizeof(int));
  1007. }
  1008. while (1) {
  1009. int j;
  1010. for (j=0;j<nbTemp;++j) {
  1011. if (tempArray[j] == i) break;
  1012. }
  1013. if (j == nbTemp) {
  1014. if (nbTemp == tempArraySize) {
  1015. tempArraySize *= 2;
  1016. tempArray = (int*)realloc(tempArray,tempArraySize * sizeof(int));
  1017. }
  1018. tempArray[nbTemp++] = i;
  1019. return i;
  1020. }
  1021. i++;
  1022. }
  1023. } /* }}} */
  1024. void releaseAllTemps() {
  1025. nbTemp = 0; /* {{{ */
  1026. } /* }}} */
  1027. void releaseTemp(int n) {
  1028. int j; /* {{{ */
  1029. for (j=0;j<nbTemp;++j) {
  1030. if (tempArray[j] == n) {
  1031. tempArray[j] = tempArray[--nbTemp];
  1032. break;
  1033. }
  1034. }
  1035. } /* }}} */
  1036. #endif
  1037. static int lastLabel = 0;
  1038. int allocateLabel() {
  1039. return ++lastLabel; /* {{{ */
  1040. } /* }}} */
  1041. void gsl_commit_compilation()
  1042. { /* {{{ */
  1043. commit_node(rootNode,0);
  1044. rootNode = 0;
  1045. lastNode = 0;
  1046. } /* }}} */
  1047. void precommit_node(NodeType *node)
  1048. { /* {{{ */
  1049. /* do here stuff for expression.. for exemple */
  1050. if (node->type == OPR_NODE)
  1051. switch(node->unode.opr.type) {
  1052. case OPR_ADD: precommit_add(node); break;
  1053. case OPR_SUB: precommit_sub(node); break;
  1054. case OPR_MUL: precommit_mul(node); break;
  1055. case OPR_DIV: precommit_div(node); break;
  1056. case OPR_CALL_EXPR: precommit_call_expr(node); break;
  1057. }
  1058. } /* }}} */
  1059. void commit_node(NodeType *node, int releaseIfTmp)
  1060. { /* {{{ */
  1061. if (node == 0) return;
  1062. switch(node->type) {
  1063. case OPR_NODE:
  1064. switch(node->unode.opr.type) {
  1065. case OPR_SET: commit_set(node); break;
  1066. case OPR_PLUS_EQ: commit_plus_eq(node); break;
  1067. case OPR_SUB_EQ: commit_sub_eq(node); break;
  1068. case OPR_MUL_EQ: commit_mul_eq(node); break;
  1069. case OPR_DIV_EQ: commit_div_eq(node); break;
  1070. case OPR_IF: commit_if(node); break;
  1071. case OPR_WHILE: commit_while(node); break;
  1072. case OPR_BLOCK: commit_block(node); break;
  1073. case OPR_FUNC_INTRO: commit_function_intro(node); break;
  1074. case OPR_FUNC_OUTRO: commit_function_outro(node); break;
  1075. case OPR_CALL: commit_call(node); break;
  1076. case OPR_EXT_CALL: commit_ext_call(node); break;
  1077. case OPR_EQU: commit_equ(node); break;
  1078. case OPR_LOW: commit_low(node); break;
  1079. case OPR_NOT: commit_not(node); break;
  1080. case OPR_AFFECT_LIST: commit_affect_list(node); break;
  1081. case OPR_FOREACH: commit_foreach(node); break;
  1082. case OPR_VAR_LIST: commit_var_list(node); break;
  1083. #ifdef VERBOSE
  1084. case EMPTY_NODE: printf("NOP\n"); break;
  1085. #endif
  1086. }
  1087. commit_node(node->unode.opr.next,0); /* recursive for the moment, maybe better to do something iterative? */
  1088. break;
  1089. case VAR_NODE: gsl_instr_set_namespace(currentGoomSL->instr, node->vnamespace);
  1090. gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_VAR); break;
  1091. case CONST_INT_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_INTEGER); break;
  1092. case CONST_FLOAT_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_FLOAT); break;
  1093. case CONST_PTR_NODE: gsl_instr_add_param(currentGoomSL->instr, node->str, TYPE_PTR); break;
  1094. }
  1095. if (releaseIfTmp && is_tmp_expr(node))
  1096. releaseTemp(get_tmp_id(node));
  1097. nodeFree(node);
  1098. } /* }}} */
  1099. NodeType *nodeNew(const char *str, int type, int line_number) {
  1100. NodeType *node = (NodeType*)malloc(sizeof(NodeType)); /* {{{ */
  1101. node->type = type;
  1102. node->str = (char*)malloc(strlen(str)+1);
  1103. node->vnamespace = NULL;
  1104. node->line_number = line_number;
  1105. strcpy(node->str, str);
  1106. return node;
  1107. } /* }}} */
  1108. static NodeType *nodeClone(NodeType *node) {
  1109. NodeType *ret = nodeNew(node->str, node->type, node->line_number); /* {{{ */
  1110. ret->vnamespace = node->vnamespace;
  1111. ret->unode = node->unode;
  1112. return ret;
  1113. } /* }}} */
  1114. void nodeFreeInternals(NodeType *node) {
  1115. free(node->str); /* {{{ */
  1116. } /* }}} */
  1117. void nodeFree(NodeType *node) {
  1118. nodeFreeInternals(node); /* {{{ */
  1119. free(node);
  1120. } /* }}} */
  1121. NodeType *new_constInt(const char *str, int line_number) {
  1122. NodeType *node = nodeNew(str, CONST_INT_NODE, line_number); /* {{{ */
  1123. node->unode.constInt.val = atoi(str);
  1124. return node;
  1125. } /* }}} */
  1126. NodeType *new_constPtr(const char *str, int line_number) {
  1127. NodeType *node = nodeNew(str, CONST_PTR_NODE, line_number); /* {{{ */
  1128. node->unode.constPtr.id = strtol(str,NULL,0);
  1129. return node;
  1130. } /* }}} */
  1131. NodeType *new_constFloat(const char *str, int line_number) {
  1132. NodeType *node = nodeNew(str, CONST_FLOAT_NODE, line_number); /* {{{ */
  1133. node->unode.constFloat.val = atof(str);
  1134. return node;
  1135. } /* }}} */
  1136. NodeType *new_var(const char *str, int line_number) {
  1137. NodeType *node = nodeNew(str, VAR_NODE, line_number); /* {{{ */
  1138. node->vnamespace = gsl_find_namespace(str);
  1139. if (node->vnamespace == 0) {
  1140. fprintf(stderr, "ERROR: Line %d, Variable not found: '%s'\n", line_number, str);
  1141. exit(1);
  1142. }
  1143. return node;
  1144. } /* }}} */
  1145. NodeType *new_nop(const char *str) {
  1146. NodeType *node = new_op(str, EMPTY_NODE, 0); /* {{{ */
  1147. return node;
  1148. } /* }}} */
  1149. NodeType *new_op(const char *str, int type, int nbOp) {
  1150. int i; /* {{{ */
  1151. NodeType *node = nodeNew(str, OPR_NODE, currentGoomSL->num_lines);
  1152. node->unode.opr.next = 0;
  1153. node->unode.opr.type = type;
  1154. node->unode.opr.nbOp = nbOp;
  1155. for (i=0;i<nbOp;++i) node->unode.opr.op[i] = 0;
  1156. return node;
  1157. } /* }}} */
  1158. void gsl_declare_global_variable(int type, char *name) {
  1159. switch(type){
  1160. case -1: break;
  1161. case FLOAT_TK:gsl_float_decl_global(name);break;
  1162. case INT_TK: gsl_int_decl_global(name);break;
  1163. case PTR_TK: gsl_ptr_decl_global(name);break;
  1164. default:
  1165. {
  1166. int id = type - 1000;
  1167. gsl_struct_decl_global_from_id(name,id);
  1168. }
  1169. }
  1170. }
  1171. /* Enabling traces. */
  1172. #ifndef YYDEBUG
  1173. # define YYDEBUG 0
  1174. #endif
  1175. /* Enabling verbose error messages. */
  1176. #ifdef YYERROR_VERBOSE
  1177. # undef YYERROR_VERBOSE
  1178. # define YYERROR_VERBOSE 1
  1179. #else
  1180. # define YYERROR_VERBOSE 0
  1181. #endif
  1182. #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
  1183. #line 1199 "goomsl_yacc.y"
  1184. typedef union YYSTYPE {
  1185. int intValue;
  1186. float floatValue;
  1187. char charValue;
  1188. char strValue[2048];
  1189. NodeType *nPtr;
  1190. GoomHash *namespace;
  1191. GSL_Struct *gsl_struct;
  1192. GSL_StructField *gsl_struct_field;
  1193. } YYSTYPE;
  1194. /* Line 191 of yacc.c. */
  1195. #line 1327 "goomsl_yacc.c"
  1196. # define yystype YYSTYPE /* obsolescent; will be withdrawn */
  1197. # define YYSTYPE_IS_DECLARED 1
  1198. # define YYSTYPE_IS_TRIVIAL 1
  1199. #endif
  1200. /* Copy the second part of user declarations. */
  1201. /* Line 214 of yacc.c. */
  1202. #line 1339 "goomsl_yacc.c"
  1203. #if ! defined (yyoverflow) || YYERROR_VERBOSE
  1204. /* The parser invokes alloca or malloc; define the necessary symbols. */
  1205. # if YYSTACK_USE_ALLOCA
  1206. # define YYSTACK_ALLOC alloca
  1207. # else
  1208. # ifndef YYSTACK_USE_ALLOCA
  1209. # if defined (alloca) || defined (_ALLOCA_H)
  1210. # define YYSTACK_ALLOC alloca
  1211. # else
  1212. # ifdef __GNUC__
  1213. # define YYSTACK_ALLOC __builtin_alloca
  1214. # endif
  1215. # endif
  1216. # endif
  1217. # endif
  1218. # ifdef YYSTACK_ALLOC
  1219. /* Pacify GCC's `empty if-body' warning. */
  1220. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  1221. # else
  1222. # if defined (__STDC__) || defined (__cplusplus)
  1223. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  1224. # define YYSIZE_T size_t
  1225. # endif
  1226. # define YYSTACK_ALLOC malloc
  1227. # define YYSTACK_FREE free
  1228. # endif
  1229. #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
  1230. #if (! defined (yyoverflow) \
  1231. && (! defined (__cplusplus) \
  1232. || (YYSTYPE_IS_TRIVIAL)))
  1233. /* A type that is properly aligned for any stack member. */
  1234. union yyalloc
  1235. {
  1236. short yyss;
  1237. YYSTYPE yyvs;
  1238. };
  1239. /* The size of the maximum gap between one aligned stack and the next. */
  1240. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  1241. /* The size of an array large to enough to hold all stacks, each with
  1242. N elements. */
  1243. # define YYSTACK_BYTES(N) \
  1244. ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
  1245. + YYSTACK_GAP_MAXIMUM)
  1246. /* Copy COUNT objects from FROM to TO. The source and destination do
  1247. not overlap. */
  1248. # ifndef YYCOPY
  1249. # if 1 < __GNUC__
  1250. # define YYCOPY(To, From, Count) \
  1251. __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
  1252. # else
  1253. # define YYCOPY(To, From, Count) \
  1254. do \
  1255. { \
  1256. register YYSIZE_T yyi; \
  1257. for (yyi = 0; yyi < (Count); yyi++) \
  1258. (To)[yyi] = (From)[yyi]; \
  1259. } \
  1260. while (0)
  1261. # endif
  1262. # endif
  1263. /* Relocate STACK from its old location to the new one. The
  1264. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  1265. elements in the stack, and YYPTR gives the new location of the
  1266. stack. Advance YYPTR to a properly aligned location for the next
  1267. stack. */
  1268. # define YYSTACK_RELOCATE(Stack) \
  1269. do \
  1270. { \
  1271. YYSIZE_T yynewbytes; \
  1272. YYCOPY (&yyptr->Stack, Stack, yysize); \
  1273. Stack = &yyptr->Stack; \
  1274. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  1275. yyptr += yynewbytes / sizeof (*yyptr); \
  1276. } \
  1277. while (0)
  1278. #endif
  1279. #if defined (__STDC__) || defined (__cplusplus)
  1280. typedef signed char yysigned_char;
  1281. #else
  1282. typedef short yysigned_char;
  1283. #endif
  1284. /* YYFINAL -- State number of the termination state. */
  1285. #define YYFINAL 3
  1286. /* YYLAST -- Last index in YYTABLE. */
  1287. #define YYLAST 229
  1288. /* YYNTOKENS -- Number of terminals. */
  1289. #define YYNTOKENS 42
  1290. /* YYNNTS -- Number of nonterminals. */
  1291. #define YYNNTS 30
  1292. /* YYNRULES -- Number of rules. */
  1293. #define YYNRULES 89
  1294. /* YYNRULES -- Number of states. */
  1295. #define YYNSTATES 217
  1296. /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
  1297. #define YYUNDEFTOK 2
  1298. #define YYMAXUTOK 279
  1299. #define YYTRANSLATE(YYX) \
  1300. ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  1301. /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
  1302. static const unsigned char yytranslate[] =
  1303. {
  1304. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1305. 25, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1306. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1307. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1308. 35, 36, 32, 29, 34, 30, 2, 31, 2, 2,
  1309. 2, 2, 2, 2, 2, 2, 2, 2, 33, 2,
  1310. 27, 26, 28, 37, 2, 2, 2, 2, 2, 2,
  1311. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1312. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1313. 2, 40, 2, 41, 2, 2, 2, 2, 2, 2,
  1314. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1315. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1316. 2, 2, 2, 38, 2, 39, 2, 2, 2, 2,
  1317. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1318. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1319. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1320. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1321. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1322. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1323. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1324. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1325. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1326. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1327. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1328. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  1329. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  1330. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  1331. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
  1332. };
  1333. #if YYDEBUG
  1334. /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
  1335. YYRHS. */
  1336. static const unsigned short yyprhs[] =
  1337. {
  1338. 0, 0, 3, 7, 10, 19, 30, 39, 50, 53,
  1339. 56, 57, 65, 68, 73, 76, 79, 82, 85, 87,
  1340. 89, 90, 93, 96, 99, 102, 104, 108, 111, 112,
  1341. 116, 122, 130, 131, 132, 137, 142, 147, 152, 154,
  1342. 157, 160, 163, 166, 169, 172, 179, 186, 193, 195,
  1343. 199, 203, 207, 211, 218, 222, 224, 227, 231, 232,
  1344. 234, 236, 240, 244, 248, 252, 255, 259, 261, 265,
  1345. 269, 273, 277, 281, 285, 288, 290, 292, 294, 298,
  1346. 304, 310, 318, 323, 330, 333, 335, 340, 344, 346
  1347. };
  1348. /* YYRHS -- A `-1'-separated list of the rules' RHS. */
  1349. static const yysigned_char yyrhs[] =
  1350. {
  1351. 43, 0, -1, 44, 55, 52, -1, 44, 59, -1,
  1352. 44, 11, 27, 48, 28, 50, 25, 56, -1, 44,
  1353. 11, 27, 48, 33, 51, 28, 50, 25, 56, -1,
  1354. 44, 10, 27, 49, 28, 50, 25, 56, -1, 44,
  1355. 10, 27, 49, 33, 51, 28, 50, 25, 56, -1,
  1356. 44, 45, -1, 44, 25, -1, -1, 22, 27, 5,
  1357. 33, 46, 28, 25, -1, 71, 47, -1, 46, 34,
  1358. 71, 47, -1, 8, 5, -1, 9, 5, -1, 7,
  1359. 5, -1, 5, 5, -1, 5, -1, 5, -1, -1,
  1360. 33, 8, -1, 33, 9, -1, 33, 7, -1, 33,
  1361. 5, -1, 58, -1, 58, 34, 51, -1, 52, 53,
  1362. -1, -1, 54, 44, 55, -1, 27, 49, 28, 50,
  1363. 25, -1, 27, 49, 33, 51, 28, 50, 25, -1,
  1364. -1, -1, 9, 5, 26, 64, -1, 8, 5, 26,
  1365. 64, -1, 7, 5, 26, 64, -1, 5, 5, 26,
  1366. 64, -1, 58, -1, 9, 5, -1, 8, 5, -1,
  1367. 7, 5, -1, 5, 5, -1, 62, 25, -1, 57,
  1368. 25, -1, 35, 65, 36, 37, 71, 59, -1, 12,
  1369. 65, 71, 13, 71, 59, -1, 38, 25, 63, 44,
  1370. 39, 25, -1, 67, -1, 5, 15, 64, -1, 5,
  1371. 16, 64, -1, 5, 18, 64, -1, 5, 17, 64,
  1372. -1, 23, 5, 24, 60, 13, 59, -1, 35, 61,
  1373. 36, -1, 5, -1, 5, 61, -1, 5, 26, 64,
  1374. -1, -1, 5, -1, 66, -1, 64, 32, 64, -1,
  1375. 64, 31, 64, -1, 64, 29, 64, -1, 64, 30,
  1376. 64, -1, 30, 64, -1, 35, 64, 36, -1, 68,
  1377. -1, 64, 26, 64, -1, 64, 27, 64, -1, 64,
  1378. 28, 64, -1, 64, 19, 64, -1, 64, 20, 64,
  1379. -1, 64, 21, 64, -1, 14, 65, -1, 4, -1,
  1380. 3, -1, 6, -1, 49, 25, 56, -1, 49, 33,
  1381. 69, 25, 56, -1, 40, 49, 41, 25, 56, -1,
  1382. 40, 49, 33, 69, 41, 25, 56, -1, 40, 49,
  1383. 56, 41, -1, 40, 49, 33, 69, 41, 56, -1,
  1384. 70, 69, -1, 70, -1, 5, 26, 56, 64, -1,
  1385. 33, 56, 64, -1, 25, -1, -1
  1386. };
  1387. /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  1388. static const unsigned short yyrline[] =
  1389. {
  1390. 0, 1236, 1236, 1238, 1239, 1240, 1241, 1242, 1243, 1244,
  1391. 1245, 1250, 1253, 1254, 1257, 1258, 1259, 1260, 1265, 1267,
  1392. 1270, 1271, 1272, 1273, 1274, 1277, 1278, 1283, 1284, 1287,
  1393. 1289, 1291, 1294, 1296, 1300, 1301, 1302, 1303, 1304, 1307,
  1394. 1308, 1309, 1310, 1315, 1316, 1317, 1318, 1319, 1320, 1321,
  1395. 1322, 1323, 1324, 1325, 1328, 1330, 1331, 1334, 1336, 1339,
  1396. 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1350, 1351,
  1397. 1352, 1353, 1354, 1355, 1356, 1359, 1360, 1361, 1366, 1367,
  1398. 1368, 1369, 1373, 1374, 1377, 1378, 1380, 1384, 1393, 1393
  1399. };
  1400. #endif
  1401. #if YYDEBUG || YYERROR_VERBOSE
  1402. /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  1403. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  1404. static const char *const yytname[] =
  1405. {
  1406. "$end", "error", "$undefined", "LTYPE_INTEGER", "LTYPE_FLOAT",
  1407. "LTYPE_VAR", "LTYPE_PTR", "PTR_TK", "INT_TK", "FLOAT_TK", "DECLARE",
  1408. "EXTERNAL", "WHILE", "DO", "NOT", "PLUS_EQ", "SUB_EQ", "DIV_EQ",
  1409. "MUL_EQ", "SUP_EQ", "LOW_EQ", "NOT_EQ", "STRUCT", "FOR", "IN", "'\\n'",
  1410. "'='", "'<'", "'>'", "'+'", "'-'", "'/'", "'*'", "':'", "','", "'('",
  1411. "')'", "'?'", "'{'", "'}'", "'['", "']'", "$accept", "gsl", "gsl_code",
  1412. "struct_declaration", "struct_members", "struct_member",
  1413. "ext_task_name", "task_name", "return_type", "arglist",
  1414. "gsl_def_functions", "function", "function_intro", "function_outro",
  1415. "leave_namespace", "declaration", "empty_declaration", "instruction",
  1416. "var_list", "var_list_content", "affectation", "start_block",
  1417. "expression", "test", "constValue", "func_call", "func_call_expression",
  1418. "affectation_list", "affectation_in_list", "opt_nl", 0
  1419. };
  1420. #endif
  1421. # ifdef YYPRINT
  1422. /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
  1423. token YYLEX-NUM. */
  1424. static const unsigned short yytoknum[] =
  1425. {
  1426. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  1427. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  1428. 275, 276, 277, 278, 279, 10, 61, 60, 62, 43,
  1429. 45, 47, 42, 58, 44, 40, 41, 63, 123, 125,
  1430. 91, 93
  1431. };
  1432. # endif
  1433. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  1434. static const unsigned char yyr1[] =
  1435. {
  1436. 0, 42, 43, 44, 44, 44, 44, 44, 44, 44,
  1437. 44, 45, 46, 46, 47, 47, 47, 47, 48, 49,
  1438. 50, 50, 50, 50, 50, 51, 51, 52, 52, 53,
  1439. 54, 54, 55, 56, 57, 57, 57, 57, 57, 58,
  1440. 58, 58, 58, 59, 59, 59, 59, 59, 59, 59,
  1441. 59, 59, 59, 59, 60, 61, 61, 62, 63, 64,
  1442. 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
  1443. 65, 65, 65, 65, 65, 66, 66, 66, 67, 67,
  1444. 67, 67, 68, 68, 69, 69, 70, 70, 71, 71
  1445. };
  1446. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  1447. static const unsigned char yyr2[] =
  1448. {
  1449. 0, 2, 3, 2, 8, 10, 8, 10, 2, 2,
  1450. 0, 7, 2, 4, 2, 2, 2, 2, 1, 1,
  1451. 0, 2, 2, 2, 2, 1, 3, 2, 0, 3,
  1452. 5, 7, 0, 0, 4, 4, 4, 4, 1, 2,
  1453. 2, 2, 2, 2, 2, 6, 6, 6, 1, 3,
  1454. 3, 3, 3, 6, 3, 1, 2, 3, 0, 1,
  1455. 1, 3, 3, 3, 3, 2, 3, 1, 3, 3,
  1456. 3, 3, 3, 3, 2, 1, 1, 1, 3, 5,
  1457. 5, 7, 4, 6, 2, 1, 4, 3, 1, 0
  1458. };
  1459. /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
  1460. STATE-NUM when YYTABLE doesn't specify something else to do. Zero
  1461. means the default is an error. */
  1462. static const unsigned char yydefact[] =
  1463. {
  1464. 10, 0, 32, 1, 19, 0, 0, 0, 0, 0,
  1465. 0, 0, 0, 9, 0, 0, 0, 8, 0, 28,
  1466. 0, 38, 3, 0, 48, 42, 0, 0, 0, 0,
  1467. 0, 41, 40, 39, 0, 0, 76, 75, 59, 77,
  1468. 0, 0, 0, 0, 0, 89, 60, 67, 0, 0,
  1469. 0, 58, 19, 0, 33, 0, 2, 44, 43, 0,
  1470. 49, 50, 52, 51, 57, 0, 0, 0, 0, 18,
  1471. 0, 74, 65, 0, 33, 0, 0, 0, 0, 0,
  1472. 0, 0, 0, 0, 0, 88, 0, 0, 0, 0,
  1473. 10, 0, 0, 78, 0, 33, 0, 85, 0, 27,
  1474. 10, 37, 36, 35, 34, 20, 0, 20, 0, 66,
  1475. 0, 0, 71, 72, 73, 68, 69, 70, 63, 64,
  1476. 62, 61, 89, 89, 0, 0, 89, 0, 0, 33,
  1477. 33, 0, 33, 84, 0, 32, 0, 0, 0, 0,
  1478. 0, 0, 0, 25, 0, 0, 0, 82, 0, 0,
  1479. 0, 55, 0, 0, 0, 0, 0, 80, 0, 87,
  1480. 79, 20, 0, 29, 24, 23, 21, 22, 33, 42,
  1481. 41, 40, 39, 20, 0, 33, 20, 33, 46, 0,
  1482. 89, 0, 0, 0, 0, 12, 56, 54, 53, 45,
  1483. 47, 33, 86, 0, 0, 6, 0, 26, 4, 0,
  1484. 83, 11, 0, 17, 16, 14, 15, 81, 30, 20,
  1485. 33, 33, 13, 0, 7, 5, 31
  1486. };
  1487. /* YYDEFGOTO[NTERM-NUM]. */
  1488. static const short yydefgoto[] =
  1489. {
  1490. -1, 1, 2, 17, 149, 185, 70, 18, 137, 142,
  1491. 56, 99, 100, 19, 93, 20, 21, 22, 125, 152,
  1492. 23, 90, 44, 45, 46, 24, 47, 96, 97, 86
  1493. };
  1494. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  1495. STATE-NUM. */
  1496. #define YYPACT_NINF -116
  1497. static const short yypact[] =
  1498. {
  1499. -116, 40, 136, -116, 103, 39, 66, 68, 61, 65,
  1500. 1, 77, 101, -116, 1, 84, 109, -116, 12, -116,
  1501. 91, -116, -116, 97, -116, 98, 72, 72, 72, 72,
  1502. 72, 99, 104, 113, 109, 130, -116, -116, -116, -116,
  1503. 1, 72, 72, 109, 166, 115, -116, -116, 145, 131,
  1504. 118, -116, -116, -24, -116, -3, 138, -116, -116, 72,
  1505. 159, 159, 159, 159, 159, 72, 72, 72, 14, -116,
  1506. 51, -116, 22, 102, 124, 72, 72, 72, 72, 72,
  1507. 72, 72, 72, 72, 72, -116, 160, 139, 140, 141,
  1508. -116, -3, 152, -116, 154, -116, 156, -3, 109, -116,
  1509. -116, 159, 159, 159, 159, 150, 82, 150, 82, -116,
  1510. -3, 158, 159, 159, 159, 159, 159, 159, 22, 22,
  1511. -116, -116, 115, 115, 195, 188, 115, 88, 162, -116,
  1512. -116, 72, -116, -116, 52, 136, 155, 177, 199, 200,
  1513. 201, 202, 180, 175, 185, 183, 171, -116, 144, 18,
  1514. 161, 195, 178, 144, 144, 190, 191, -116, 72, 159,
  1515. -116, 150, 82, -116, -116, -116, -116, -116, -116, -116,
  1516. -116, -116, -116, 150, 82, -116, 150, -116, -116, 192,
  1517. 115, 208, 213, 214, 215, -116, -116, -116, -116, -116,
  1518. -116, -116, 159, 196, 194, -116, 198, -116, -116, 203,
  1519. -116, -116, 161, -116, -116, -116, -116, -116, -116, 150,
  1520. -116, -116, -116, 204, -116, -116, -116
  1521. };
  1522. /* YYPGOTO[NTERM-NUM]. */
  1523. static const yysigned_char yypgoto[] =
  1524. {
  1525. -116, -116, -68, -116, -116, 23, -116, -15, -104, -92,
  1526. -116, -116, -116, 89, -74, -116, -88, -115, -116, 75,
  1527. -116, -116, -16, -6, -116, -116, -116, -62, -116, -99
  1528. };
  1529. /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
  1530. positive, shift that token. If negative, reduce the rule which
  1531. number is the opposite. If zero, do what YYDEFACT says.
  1532. If YYTABLE_NINF, syntax error. */
  1533. #define YYTABLE_NINF -1
  1534. static const unsigned char yytable[] =
  1535. {
  1536. 111, 53, 94, 144, 36, 37, 38, 39, 50, 91,
  1537. 60, 61, 62, 63, 64, 40, 145, 92, 143, 68,
  1538. 143, 131, 127, 148, 150, 72, 73, 154, 74, 128,
  1539. 95, 41, 135, 178, 71, 133, 42, 54, 188, 189,
  1540. 3, 43, 105, 101, 31, 55, 179, 106, 146, 102,
  1541. 103, 104, 180, 83, 84, 157, 158, 193, 160, 112,
  1542. 113, 114, 115, 116, 117, 118, 119, 120, 121, 196,
  1543. 194, 32, 199, 33, 143, 36, 37, 38, 39, 107,
  1544. 161, 202, 197, 134, 108, 162, 143, 138, 34, 139,
  1545. 140, 141, 35, 4, 195, 5, 6, 7, 8, 9,
  1546. 10, 198, 41, 200, 48, 213, 49, 42, 25, 51,
  1547. 11, 12, 43, 13, 52, 159, 57, 207, 26, 27,
  1548. 28, 29, 58, 14, 59, 65, 15, 155, 16, 30,
  1549. 66, 81, 82, 83, 84, 69, 214, 215, 109, 67,
  1550. 85, 4, 192, 5, 6, 7, 8, 9, 10, 4,
  1551. 87, 5, 6, 7, 89, 88, 10, 110, 11, 12,
  1552. 164, 13, 165, 166, 167, 98, 181, 12, 182, 183,
  1553. 184, 14, 123, 122, 15, 124, 16, 129, 126, 14,
  1554. 130, 132, 15, 136, 16, 75, 76, 77, 81, 82,
  1555. 83, 84, 78, 79, 80, 81, 82, 83, 84, 147,
  1556. 151, 153, 168, 156, 169, 170, 171, 172, 173, 174,
  1557. 175, 176, 177, 203, 187, 190, 191, 201, 204, 205,
  1558. 206, 208, 209, 210, 163, 212, 186, 0, 211, 216
  1559. };
  1560. static const short yycheck[] =
  1561. {
  1562. 74, 16, 5, 107, 3, 4, 5, 6, 14, 33,
  1563. 26, 27, 28, 29, 30, 14, 108, 41, 106, 34,
  1564. 108, 95, 90, 122, 123, 41, 42, 126, 43, 91,
  1565. 33, 30, 100, 148, 40, 97, 35, 25, 153, 154,
  1566. 0, 40, 28, 59, 5, 33, 28, 33, 110, 65,
  1567. 66, 67, 34, 31, 32, 129, 130, 161, 132, 75,
  1568. 76, 77, 78, 79, 80, 81, 82, 83, 84, 173,
  1569. 162, 5, 176, 5, 162, 3, 4, 5, 6, 28,
  1570. 28, 180, 174, 98, 33, 33, 174, 5, 27, 7,
  1571. 8, 9, 27, 5, 168, 7, 8, 9, 10, 11,
  1572. 12, 175, 30, 177, 27, 209, 5, 35, 5, 25,
  1573. 22, 23, 40, 25, 5, 131, 25, 191, 15, 16,
  1574. 17, 18, 25, 35, 26, 26, 38, 39, 40, 26,
  1575. 26, 29, 30, 31, 32, 5, 210, 211, 36, 26,
  1576. 25, 5, 158, 7, 8, 9, 10, 11, 12, 5,
  1577. 5, 7, 8, 9, 36, 24, 12, 33, 22, 23,
  1578. 5, 25, 7, 8, 9, 27, 5, 23, 7, 8,
  1579. 9, 35, 33, 13, 38, 35, 40, 25, 37, 35,
  1580. 26, 25, 38, 33, 40, 19, 20, 21, 29, 30,
  1581. 31, 32, 26, 27, 28, 29, 30, 31, 32, 41,
  1582. 5, 13, 25, 41, 5, 5, 5, 5, 28, 34,
  1583. 25, 28, 41, 5, 36, 25, 25, 25, 5, 5,
  1584. 5, 25, 28, 25, 135, 202, 151, -1, 25, 25
  1585. };
  1586. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  1587. symbol of state STATE-NUM. */
  1588. static const unsigned char yystos[] =
  1589. {
  1590. 0, 43, 44, 0, 5, 7, 8, 9, 10, 11,
  1591. 12, 22, 23, 25, 35, 38, 40, 45, 49, 55,
  1592. 57, 58, 59, 62, 67, 5, 15, 16, 17, 18,
  1593. 26, 5, 5, 5, 27, 27, 3, 4, 5, 6,
  1594. 14, 30, 35, 40, 64, 65, 66, 68, 27, 5,
  1595. 65, 25, 5, 49, 25, 33, 52, 25, 25, 26,
  1596. 64, 64, 64, 64, 64, 26, 26, 26, 49, 5,
  1597. 48, 65, 64, 64, 49, 19, 20, 21, 26, 27,
  1598. 28, 29, 30, 31, 32, 25, 71, 5, 24, 36,
  1599. 63, 33, 41, 56, 5, 33, 69, 70, 27, 53,
  1600. 54, 64, 64, 64, 64, 28, 33, 28, 33, 36,
  1601. 33, 56, 64, 64, 64, 64, 64, 64, 64, 64,
  1602. 64, 64, 13, 33, 35, 60, 37, 44, 69, 25,
  1603. 26, 56, 25, 69, 49, 44, 33, 50, 5, 7,
  1604. 8, 9, 51, 58, 50, 51, 69, 41, 71, 46,
  1605. 71, 5, 61, 13, 71, 39, 41, 56, 56, 64,
  1606. 56, 28, 33, 55, 5, 7, 8, 9, 25, 5,
  1607. 5, 5, 5, 28, 34, 25, 28, 41, 59, 28,
  1608. 34, 5, 7, 8, 9, 47, 61, 36, 59, 59,
  1609. 25, 25, 64, 50, 51, 56, 50, 51, 56, 50,
  1610. 56, 25, 71, 5, 5, 5, 5, 56, 25, 28,
  1611. 25, 25, 47, 50, 56, 56, 25
  1612. };
  1613. #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
  1614. # define YYSIZE_T __SIZE_TYPE__
  1615. #endif
  1616. #if ! defined (YYSIZE_T) && defined (size_t)
  1617. # define YYSIZE_T size_t
  1618. #endif
  1619. #if ! defined (YYSIZE_T)
  1620. # if defined (__STDC__) || defined (__cplusplus)
  1621. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  1622. # define YYSIZE_T size_t
  1623. # endif
  1624. #endif
  1625. #if ! defined (YYSIZE_T)
  1626. # define YYSIZE_T unsigned int
  1627. #endif
  1628. #define yyerrok (yyerrstatus = 0)
  1629. #define yyclearin (yychar = YYEMPTY)
  1630. #define YYEMPTY (-2)
  1631. #define YYEOF 0
  1632. #define YYACCEPT goto yyacceptlab
  1633. #define YYABORT goto yyabortlab
  1634. #define YYERROR goto yyerrlab1
  1635. /* Like YYERROR except do call yyerror. This remains here temporarily
  1636. to ease the transition to the new meaning of YYERROR, for GCC.
  1637. Once GCC version 2 has supplanted version 1, this can go. */
  1638. #define YYFAIL goto yyerrlab
  1639. #define YYRECOVERING() (!!yyerrstatus)
  1640. #define YYBACKUP(Token, Value) \
  1641. do \
  1642. if (yychar == YYEMPTY && yylen == 1) \
  1643. { \
  1644. yychar = (Token); \
  1645. yylval = (Value); \
  1646. yytoken = YYTRANSLATE (yychar); \
  1647. YYPOPSTACK; \
  1648. goto yybackup; \
  1649. } \
  1650. else \
  1651. { \
  1652. yyerror ("syntax error: cannot back up");\
  1653. YYERROR; \
  1654. } \
  1655. while (0)
  1656. #define YYTERROR 1
  1657. #define YYERRCODE 256
  1658. /* YYLLOC_DEFAULT -- Compute the default location (before the actions
  1659. are run). */
  1660. #ifndef YYLLOC_DEFAULT
  1661. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  1662. Current.first_line = Rhs[1].first_line; \
  1663. Current.first_column = Rhs[1].first_column; \
  1664. Current.last_line = Rhs[N].last_line; \
  1665. Current.last_column = Rhs[N].last_column;
  1666. #endif
  1667. /* YYLEX -- calling `yylex' with the right arguments. */
  1668. #ifdef YYLEX_PARAM
  1669. # define YYLEX yylex (YYLEX_PARAM)
  1670. #else
  1671. # define YYLEX yylex ()
  1672. #endif
  1673. /* Enable debugging if requested. */
  1674. #if YYDEBUG
  1675. # ifndef YYFPRINTF
  1676. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  1677. # define YYFPRINTF fprintf
  1678. # endif
  1679. # define YYDPRINTF(Args) \
  1680. do { \
  1681. if (yydebug) \
  1682. YYFPRINTF Args; \
  1683. } while (0)
  1684. # define YYDSYMPRINT(Args) \
  1685. do { \
  1686. if (yydebug) \
  1687. yysymprint Args; \
  1688. } while (0)
  1689. # define YYDSYMPRINTF(Title, Token, Value, Location) \
  1690. do { \
  1691. if (yydebug) \
  1692. { \
  1693. YYFPRINTF (stderr, "%s ", Title); \
  1694. yysymprint (stderr, \
  1695. Token, Value); \
  1696. YYFPRINTF (stderr, "\n"); \
  1697. } \
  1698. } while (0)
  1699. /*------------------------------------------------------------------.
  1700. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  1701. | TOP (cinluded). |
  1702. `------------------------------------------------------------------*/
  1703. #if defined (__STDC__) || defined (__cplusplus)
  1704. static void
  1705. yy_stack_print (short *bottom, short *top)
  1706. #else
  1707. static void
  1708. yy_stack_print (bottom, top)
  1709. short *bottom;
  1710. short *top;
  1711. #endif
  1712. {
  1713. YYFPRINTF (stderr, "Stack now");
  1714. for (/* Nothing. */; bottom <= top; ++bottom)
  1715. YYFPRINTF (stderr, " %d", *bottom);
  1716. YYFPRINTF (stderr, "\n");
  1717. }
  1718. # define YY_STACK_PRINT(Bottom, Top) \
  1719. do { \
  1720. if (yydebug) \
  1721. yy_stack_print ((Bottom), (Top)); \
  1722. } while (0)
  1723. /*------------------------------------------------.
  1724. | Report that the YYRULE is going to be reduced. |
  1725. `------------------------------------------------*/
  1726. #if defined (__STDC__) || defined (__cplusplus)
  1727. static void
  1728. yy_reduce_print (int yyrule)
  1729. #else
  1730. static void
  1731. yy_reduce_print (yyrule)
  1732. int yyrule;
  1733. #endif
  1734. {
  1735. int yyi;
  1736. unsigned int yylineno = yyrline[yyrule];
  1737. YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
  1738. yyrule - 1, yylineno);
  1739. /* Print the symbols being reduced, and their result. */
  1740. for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
  1741. YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  1742. YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
  1743. }
  1744. # define YY_REDUCE_PRINT(Rule) \
  1745. do { \
  1746. if (yydebug) \
  1747. yy_reduce_print (Rule); \
  1748. } while (0)
  1749. /* Nonzero means print parse trace. It is left uninitialized so that
  1750. multiple parsers can coexist. */
  1751. int yydebug;
  1752. #else /* !YYDEBUG */
  1753. # define YYDPRINTF(Args)
  1754. # define YYDSYMPRINT(Args)
  1755. # define YYDSYMPRINTF(Title, Token, Value, Location)
  1756. # define YY_STACK_PRINT(Bottom, Top)
  1757. # define YY_REDUCE_PRINT(Rule)
  1758. #endif /* !YYDEBUG */
  1759. /* YYINITDEPTH -- initial size of the parser's stacks. */
  1760. #ifndef YYINITDEPTH
  1761. # define YYINITDEPTH 200
  1762. #endif
  1763. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  1764. if the built-in stack extension method is used).
  1765. Do not make this value too large; the results are undefined if
  1766. SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
  1767. evaluated with infinite-precision integer arithmetic. */
  1768. #if YYMAXDEPTH == 0
  1769. # undef YYMAXDEPTH
  1770. #endif
  1771. #ifndef YYMAXDEPTH
  1772. # define YYMAXDEPTH 10000
  1773. #endif
  1774. #if YYERROR_VERBOSE
  1775. # ifndef yystrlen
  1776. # if defined (__GLIBC__) && defined (_STRING_H)
  1777. # define yystrlen strlen
  1778. # else
  1779. /* Return the length of YYSTR. */
  1780. static YYSIZE_T
  1781. # if defined (__STDC__) || defined (__cplusplus)
  1782. yystrlen (const char *yystr)
  1783. # else
  1784. yystrlen (yystr)
  1785. const char *yystr;
  1786. # endif
  1787. {
  1788. register const char *yys = yystr;
  1789. while (*yys++ != '\0')
  1790. continue;
  1791. return yys - yystr - 1;
  1792. }
  1793. # endif
  1794. # endif
  1795. # ifndef yystpcpy
  1796. # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
  1797. # define yystpcpy stpcpy
  1798. # else
  1799. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  1800. YYDEST. */
  1801. static char *
  1802. # if defined (__STDC__) || defined (__cplusplus)
  1803. yystpcpy (char *yydest, const char *yysrc)
  1804. # else
  1805. yystpcpy (yydest, yysrc)
  1806. char *yydest;
  1807. const char *yysrc;
  1808. # endif
  1809. {
  1810. register char *yyd = yydest;
  1811. register const char *yys = yysrc;
  1812. while ((*yyd++ = *yys++) != '\0')
  1813. continue;
  1814. return yyd - 1;
  1815. }
  1816. # endif
  1817. # endif
  1818. #endif /* !YYERROR_VERBOSE */
  1819. #if YYDEBUG
  1820. /*--------------------------------.
  1821. | Print this symbol on YYOUTPUT. |
  1822. `--------------------------------*/
  1823. #if defined (__STDC__) || defined (__cplusplus)
  1824. static void
  1825. yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
  1826. #else
  1827. static void
  1828. yysymprint (yyoutput, yytype, yyvaluep)
  1829. FILE *yyoutput;
  1830. int yytype;
  1831. YYSTYPE *yyvaluep;
  1832. #endif
  1833. {
  1834. /* Pacify ``unused variable'' warnings. */
  1835. (void) yyvaluep;
  1836. if (yytype < YYNTOKENS)
  1837. {
  1838. YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
  1839. # ifdef YYPRINT
  1840. YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
  1841. # endif
  1842. }
  1843. else
  1844. YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
  1845. switch (yytype)
  1846. {
  1847. default:
  1848. break;
  1849. }
  1850. YYFPRINTF (yyoutput, ")");
  1851. }
  1852. #endif /* ! YYDEBUG */
  1853. /*-----------------------------------------------.
  1854. | Release the memory associated to this symbol. |
  1855. `-----------------------------------------------*/
  1856. #if defined (__STDC__) || defined (__cplusplus)
  1857. static void
  1858. yydestruct (int yytype, YYSTYPE *yyvaluep)
  1859. #else
  1860. static void
  1861. yydestruct (yytype, yyvaluep)
  1862. int yytype;
  1863. YYSTYPE *yyvaluep;
  1864. #endif
  1865. {
  1866. /* Pacify ``unused variable'' warnings. */
  1867. (void) yyvaluep;
  1868. switch (yytype)
  1869. {
  1870. default:
  1871. break;
  1872. }
  1873. }
  1874. /* Prevent warnings from -Wmissing-prototypes. */
  1875. #ifdef YYPARSE_PARAM
  1876. # if defined (__STDC__) || defined (__cplusplus)
  1877. int yyparse (void *YYPARSE_PARAM);
  1878. # else
  1879. int yyparse ();
  1880. # endif
  1881. #else /* ! YYPARSE_PARAM */
  1882. #if defined (__STDC__) || defined (__cplusplus)
  1883. int yyparse (void);
  1884. #else
  1885. int yyparse ();
  1886. #endif
  1887. #endif /* ! YYPARSE_PARAM */
  1888. /* The lookahead symbol. */
  1889. int yychar;
  1890. /* The semantic value of the lookahead symbol. */
  1891. YYSTYPE yylval;
  1892. /* Number of syntax errors so far. */
  1893. int yynerrs;
  1894. /*----------.
  1895. | yyparse. |
  1896. `----------*/
  1897. #ifdef YYPARSE_PARAM
  1898. # if defined (__STDC__) || defined (__cplusplus)
  1899. int yyparse (void *YYPARSE_PARAM)
  1900. # else
  1901. int yyparse (YYPARSE_PARAM)
  1902. void *YYPARSE_PARAM;
  1903. # endif
  1904. #else /* ! YYPARSE_PARAM */
  1905. #if defined (__STDC__) || defined (__cplusplus)
  1906. int
  1907. yyparse (void)
  1908. #else
  1909. int
  1910. yyparse ()
  1911. #endif
  1912. #endif
  1913. {
  1914. register int yystate;
  1915. register int yyn;
  1916. int yyresult;
  1917. /* Number of tokens to shift before error messages enabled. */
  1918. int yyerrstatus;
  1919. /* Lookahead token as an internal (translated) token number. */
  1920. int yytoken = 0;
  1921. /* Three stacks and their tools:
  1922. `yyss': related to states,
  1923. `yyvs': related to semantic values,
  1924. `yyls': related to locations.
  1925. Refer to the stacks thru separate pointers, to allow yyoverflow
  1926. to reallocate them elsewhere. */
  1927. /* The state stack. */
  1928. short yyssa[YYINITDEPTH];
  1929. short *yyss = yyssa;
  1930. register short *yyssp;
  1931. /* The semantic value stack. */
  1932. YYSTYPE yyvsa[YYINITDEPTH];
  1933. YYSTYPE *yyvs = yyvsa;
  1934. register YYSTYPE *yyvsp;
  1935. #define YYPOPSTACK (yyvsp--, yyssp--)
  1936. YYSIZE_T yystacksize = YYINITDEPTH;
  1937. /* The variables used to return semantic value and location from the
  1938. action routines. */
  1939. YYSTYPE yyval;
  1940. /* When reducing, the number of symbols on the RHS of the reduced
  1941. rule. */
  1942. int yylen;
  1943. YYDPRINTF ((stderr, "Starting parse\n"));
  1944. yystate = 0;
  1945. yyerrstatus = 0;
  1946. yynerrs = 0;
  1947. yychar = YYEMPTY; /* Cause a token to be read. */
  1948. /* Initialize stack pointers.
  1949. Waste one element of value and location stack
  1950. so that they stay on the same level as the state stack.
  1951. The wasted elements are never initialized. */
  1952. yyssp = yyss;
  1953. yyvsp = yyvs;
  1954. goto yysetstate;
  1955. /*------------------------------------------------------------.
  1956. | yynewstate -- Push a new state, which is found in yystate. |
  1957. `------------------------------------------------------------*/
  1958. yynewstate:
  1959. /* In all cases, when you get here, the value and location stacks
  1960. have just been pushed. so pushing a state here evens the stacks.
  1961. */
  1962. yyssp++;
  1963. yysetstate:
  1964. *yyssp = yystate;
  1965. if (yyss + yystacksize - 1 <= yyssp)
  1966. {
  1967. /* Get the current used size of the three stacks, in elements. */
  1968. YYSIZE_T yysize = yyssp - yyss + 1;
  1969. #ifdef yyoverflow
  1970. {
  1971. /* Give user a chance to reallocate the stack. Use copies of
  1972. these so that the &'s don't force the real ones into
  1973. memory. */
  1974. YYSTYPE *yyvs1 = yyvs;
  1975. short *yyss1 = yyss;
  1976. /* Each stack pointer address is followed by the size of the
  1977. data in use in that stack, in bytes. This used to be a
  1978. conditional around just the two extra args, but that might
  1979. be undefined if yyoverflow is a macro. */
  1980. yyoverflow ("parser stack overflow",
  1981. &yyss1, yysize * sizeof (*yyssp),
  1982. &yyvs1, yysize * sizeof (*yyvsp),
  1983. &yystacksize);
  1984. yyss = yyss1;
  1985. yyvs = yyvs1;
  1986. }
  1987. #else /* no yyoverflow */
  1988. # ifndef YYSTACK_RELOCATE
  1989. goto yyoverflowlab;
  1990. # else
  1991. /* Extend the stack our own way. */
  1992. if (YYMAXDEPTH <= yystacksize)
  1993. goto yyoverflowlab;
  1994. yystacksize *= 2;
  1995. if (YYMAXDEPTH < yystacksize)
  1996. yystacksize = YYMAXDEPTH;
  1997. {
  1998. short *yyss1 = yyss;
  1999. union yyalloc *yyptr =
  2000. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  2001. if (! yyptr)
  2002. goto yyoverflowlab;
  2003. YYSTACK_RELOCATE (yyss);
  2004. YYSTACK_RELOCATE (yyvs);
  2005. # undef YYSTACK_RELOCATE
  2006. if (yyss1 != yyssa)
  2007. YYSTACK_FREE (yyss1);
  2008. }
  2009. # endif
  2010. #endif /* no yyoverflow */
  2011. yyssp = yyss + yysize - 1;
  2012. yyvsp = yyvs + yysize - 1;
  2013. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  2014. (unsigned long int) yystacksize));
  2015. if (yyss + yystacksize - 1 <= yyssp)
  2016. YYABORT;
  2017. }
  2018. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  2019. goto yybackup;
  2020. /*-----------.
  2021. | yybackup. |
  2022. `-----------*/
  2023. yybackup:
  2024. /* Do appropriate processing given the current state. */
  2025. /* Read a lookahead token if we need one and don't already have one. */
  2026. /* yyresume: */
  2027. /* First try to decide what to do without reference to lookahead token. */
  2028. yyn = yypact[yystate];
  2029. if (yyn == YYPACT_NINF)
  2030. goto yydefault;
  2031. /* Not known => get a lookahead token if don't already have one. */
  2032. /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
  2033. if (yychar == YYEMPTY)
  2034. {
  2035. YYDPRINTF ((stderr, "Reading a token: "));
  2036. yychar = YYLEX;
  2037. }
  2038. if (yychar <= YYEOF)
  2039. {
  2040. yychar = yytoken = YYEOF;
  2041. YYDPRINTF ((stderr, "Now at end of input.\n"));
  2042. }
  2043. else
  2044. {
  2045. yytoken = YYTRANSLATE (yychar);
  2046. YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
  2047. }
  2048. /* If the proper action on seeing token YYTOKEN is to reduce or to
  2049. detect an error, take that action. */
  2050. yyn += yytoken;
  2051. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  2052. goto yydefault;
  2053. yyn = yytable[yyn];
  2054. if (yyn <= 0)
  2055. {
  2056. if (yyn == 0 || yyn == YYTABLE_NINF)
  2057. goto yyerrlab;
  2058. yyn = -yyn;
  2059. goto yyreduce;
  2060. }
  2061. if (yyn == YYFINAL)
  2062. YYACCEPT;
  2063. /* Shift the lookahead token. */
  2064. YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
  2065. /* Discard the token being shifted unless it is eof. */
  2066. if (yychar != YYEOF)
  2067. yychar = YYEMPTY;
  2068. *++yyvsp = yylval;
  2069. /* Count tokens shifted since error; after three, turn off error
  2070. status. */
  2071. if (yyerrstatus)
  2072. yyerrstatus--;
  2073. yystate = yyn;
  2074. goto yynewstate;
  2075. /*-----------------------------------------------------------.
  2076. | yydefault -- do the default action for the current state. |
  2077. `-----------------------------------------------------------*/
  2078. yydefault:
  2079. yyn = yydefact[yystate];
  2080. if (yyn == 0)
  2081. goto yyerrlab;
  2082. goto yyreduce;
  2083. /*-----------------------------.
  2084. | yyreduce -- Do a reduction. |
  2085. `-----------------------------*/
  2086. yyreduce:
  2087. /* yyn is the number of a rule to reduce with. */
  2088. yylen = yyr2[yyn];
  2089. /* If YYLEN is nonzero, implement the default value of the action:
  2090. `$$ = $1'.
  2091. Otherwise, the following line sets YYVAL to garbage.
  2092. This behavior is undocumented and Bison
  2093. users should not rely upon it. Assigning to YYVAL
  2094. unconditionally makes the parser a bit smaller, and it avoids a
  2095. GCC warning that YYVAL may be used uninitialized. */
  2096. yyval = yyvsp[1-yylen];
  2097. YY_REDUCE_PRINT (yyn);
  2098. switch (yyn)
  2099. {
  2100. case 3:
  2101. #line 1238 "goomsl_yacc.y"
  2102. { gsl_append(yyvsp[0].nPtr); }
  2103. break;
  2104. case 4:
  2105. #line 1239 "goomsl_yacc.y"
  2106. { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-4].strValue); }
  2107. break;
  2108. case 5:
  2109. #line 1240 "goomsl_yacc.y"
  2110. { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-6].strValue); }
  2111. break;
  2112. case 6:
  2113. #line 1241 "goomsl_yacc.y"
  2114. { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-4].strValue); }
  2115. break;
  2116. case 7:
  2117. #line 1242 "goomsl_yacc.y"
  2118. { gsl_declare_global_variable(yyvsp[-2].intValue,yyvsp[-6].strValue); }
  2119. break;
  2120. case 11:
  2121. #line 1250 "goomsl_yacc.y"
  2122. { gsl_add_struct(yyvsp[-4].strValue, yyvsp[-2].gsl_struct); }
  2123. break;
  2124. case 12:
  2125. #line 1253 "goomsl_yacc.y"
  2126. { yyval.gsl_struct = gsl_new_struct(yyvsp[0].gsl_struct_field); }
  2127. break;
  2128. case 13:
  2129. #line 1254 "goomsl_yacc.y"
  2130. { yyval.gsl_struct = yyvsp[-3].gsl_struct; gsl_add_struct_field(yyvsp[-3].gsl_struct, yyvsp[0].gsl_struct_field); }
  2131. break;
  2132. case 14:
  2133. #line 1257 "goomsl_yacc.y"
  2134. { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_INT); }
  2135. break;
  2136. case 15:
  2137. #line 1258 "goomsl_yacc.y"
  2138. { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_FLOAT); }
  2139. break;
  2140. case 16:
  2141. #line 1259 "goomsl_yacc.y"
  2142. { yyval.gsl_struct_field = gsl_new_struct_field(yyvsp[0].strValue, INSTR_PTR); }
  2143. break;
  2144. case 17:
  2145. #line 1260 "goomsl_yacc.y"
  2146. { yyval.gsl_struct_field = gsl_new_struct_field_struct(yyvsp[0].strValue, yyvsp[-1].strValue); }
  2147. break;
  2148. case 18:
  2149. #line 1265 "goomsl_yacc.y"
  2150. { gsl_declare_external_task(yyvsp[0].strValue); gsl_enternamespace(yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); }
  2151. break;
  2152. case 19:
  2153. #line 1267 "goomsl_yacc.y"
  2154. { gsl_declare_task(yyvsp[0].strValue); gsl_enternamespace(yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); strcpy(yyval.strValue,yyvsp[0].strValue); }
  2155. break;
  2156. case 20:
  2157. #line 1270 "goomsl_yacc.y"
  2158. { yyval.intValue=-1; }
  2159. break;
  2160. case 21:
  2161. #line 1271 "goomsl_yacc.y"
  2162. { yyval.intValue=INT_TK; }
  2163. break;
  2164. case 22:
  2165. #line 1272 "goomsl_yacc.y"
  2166. { yyval.intValue=FLOAT_TK; }
  2167. break;
  2168. case 23:
  2169. #line 1273 "goomsl_yacc.y"
  2170. { yyval.intValue=PTR_TK; }
  2171. break;
  2172. case 24:
  2173. #line 1274 "goomsl_yacc.y"
  2174. { yyval.intValue= 1000 + gsl_get_struct_id(yyvsp[0].strValue); }
  2175. break;
  2176. case 29:
  2177. #line 1287 "goomsl_yacc.y"
  2178. { gsl_leavenamespace(); }
  2179. break;
  2180. case 30:
  2181. #line 1289 "goomsl_yacc.y"
  2182. { gsl_append(new_function_intro(yyvsp[-3].strValue));
  2183. gsl_declare_global_variable(yyvsp[-1].intValue,yyvsp[-3].strValue); }
  2184. break;
  2185. case 31:
  2186. #line 1291 "goomsl_yacc.y"
  2187. { gsl_append(new_function_intro(yyvsp[-5].strValue));
  2188. gsl_declare_global_variable(yyvsp[-1].intValue,yyvsp[-5].strValue); }
  2189. break;
  2190. case 32:
  2191. #line 1294 "goomsl_yacc.y"
  2192. { gsl_append(new_function_outro()); }
  2193. break;
  2194. case 33:
  2195. #line 1296 "goomsl_yacc.y"
  2196. { yyval.namespace = gsl_leavenamespace(); }
  2197. break;
  2198. case 34:
  2199. #line 1300 "goomsl_yacc.y"
  2200. { gsl_float_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); }
  2201. break;
  2202. case 35:
  2203. #line 1301 "goomsl_yacc.y"
  2204. { gsl_int_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); }
  2205. break;
  2206. case 36:
  2207. #line 1302 "goomsl_yacc.y"
  2208. { gsl_ptr_decl_local(yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); }
  2209. break;
  2210. case 37:
  2211. #line 1303 "goomsl_yacc.y"
  2212. { gsl_struct_decl_local(yyvsp[-3].strValue,yyvsp[-2].strValue); yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); }
  2213. break;
  2214. case 38:
  2215. #line 1304 "goomsl_yacc.y"
  2216. { yyval.nPtr = 0; }
  2217. break;
  2218. case 39:
  2219. #line 1307 "goomsl_yacc.y"
  2220. { gsl_float_decl_local(yyvsp[0].strValue); }
  2221. break;
  2222. case 40:
  2223. #line 1308 "goomsl_yacc.y"
  2224. { gsl_int_decl_local(yyvsp[0].strValue); }
  2225. break;
  2226. case 41:
  2227. #line 1309 "goomsl_yacc.y"
  2228. { gsl_ptr_decl_local(yyvsp[0].strValue); }
  2229. break;
  2230. case 42:
  2231. #line 1310 "goomsl_yacc.y"
  2232. { gsl_struct_decl_local(yyvsp[-1].strValue,yyvsp[0].strValue); }
  2233. break;
  2234. case 43:
  2235. #line 1315 "goomsl_yacc.y"
  2236. { yyval.nPtr = yyvsp[-1].nPtr; }
  2237. break;
  2238. case 44:
  2239. #line 1316 "goomsl_yacc.y"
  2240. { yyval.nPtr = yyvsp[-1].nPtr; }
  2241. break;
  2242. case 45:
  2243. #line 1317 "goomsl_yacc.y"
  2244. { yyval.nPtr = new_if(yyvsp[-4].nPtr,yyvsp[0].nPtr); }
  2245. break;
  2246. case 46:
  2247. #line 1318 "goomsl_yacc.y"
  2248. { yyval.nPtr = new_while(yyvsp[-4].nPtr,yyvsp[0].nPtr); }
  2249. break;
  2250. case 47:
  2251. #line 1319 "goomsl_yacc.y"
  2252. { lastNode = yyvsp[-3].nPtr->unode.opr.op[1]; yyval.nPtr=yyvsp[-3].nPtr; }
  2253. break;
  2254. case 48:
  2255. #line 1320 "goomsl_yacc.y"
  2256. { yyval.nPtr = yyvsp[0].nPtr; }
  2257. break;
  2258. case 49:
  2259. #line 1321 "goomsl_yacc.y"
  2260. { yyval.nPtr = new_plus_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); }
  2261. break;
  2262. case 50:
  2263. #line 1322 "goomsl_yacc.y"
  2264. { yyval.nPtr = new_sub_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); }
  2265. break;
  2266. case 51:
  2267. #line 1323 "goomsl_yacc.y"
  2268. { yyval.nPtr = new_mul_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); }
  2269. break;
  2270. case 52:
  2271. #line 1324 "goomsl_yacc.y"
  2272. { yyval.nPtr = new_div_eq(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); }
  2273. break;
  2274. case 53:
  2275. #line 1325 "goomsl_yacc.y"
  2276. { yyval.nPtr = new_static_foreach(new_var(yyvsp[-4].strValue, currentGoomSL->num_lines), yyvsp[-2].nPtr, yyvsp[0].nPtr); }
  2277. break;
  2278. case 54:
  2279. #line 1328 "goomsl_yacc.y"
  2280. { yyval.nPtr = yyvsp[-1].nPtr; }
  2281. break;
  2282. case 55:
  2283. #line 1330 "goomsl_yacc.y"
  2284. { yyval.nPtr = new_var_list(new_var(yyvsp[0].strValue,currentGoomSL->num_lines), NULL); }
  2285. break;
  2286. case 56:
  2287. #line 1331 "goomsl_yacc.y"
  2288. { yyval.nPtr = new_var_list(new_var(yyvsp[-1].strValue,currentGoomSL->num_lines), yyvsp[0].nPtr); }
  2289. break;
  2290. case 57:
  2291. #line 1334 "goomsl_yacc.y"
  2292. { yyval.nPtr = new_set(new_var(yyvsp[-2].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr); }
  2293. break;
  2294. case 58:
  2295. #line 1336 "goomsl_yacc.y"
  2296. { yyval.nPtr = new_block(lastNode); lastNode = yyval.nPtr->unode.opr.op[0]; }
  2297. break;
  2298. case 59:
  2299. #line 1339 "goomsl_yacc.y"
  2300. { yyval.nPtr = new_var(yyvsp[0].strValue,currentGoomSL->num_lines); }
  2301. break;
  2302. case 60:
  2303. #line 1340 "goomsl_yacc.y"
  2304. { yyval.nPtr = yyvsp[0].nPtr; }
  2305. break;
  2306. case 61:
  2307. #line 1341 "goomsl_yacc.y"
  2308. { yyval.nPtr = new_mul(yyvsp[-2].nPtr,yyvsp[0].nPtr); }
  2309. break;
  2310. case 62:
  2311. #line 1342 "goomsl_yacc.y"
  2312. { yyval.nPtr = new_div(yyvsp[-2].nPtr,yyvsp[0].nPtr); }
  2313. break;
  2314. case 63:
  2315. #line 1343 "goomsl_yacc.y"
  2316. { yyval.nPtr = new_add(yyvsp[-2].nPtr,yyvsp[0].nPtr); }
  2317. break;
  2318. case 64:
  2319. #line 1344 "goomsl_yacc.y"
  2320. { yyval.nPtr = new_sub(yyvsp[-2].nPtr,yyvsp[0].nPtr); }
  2321. break;
  2322. case 65:
  2323. #line 1345 "goomsl_yacc.y"
  2324. { yyval.nPtr = new_neg(yyvsp[0].nPtr); }
  2325. break;
  2326. case 66:
  2327. #line 1346 "goomsl_yacc.y"
  2328. { yyval.nPtr = yyvsp[-1].nPtr; }
  2329. break;
  2330. case 67:
  2331. #line 1347 "goomsl_yacc.y"
  2332. { yyval.nPtr = yyvsp[0].nPtr; }
  2333. break;
  2334. case 68:
  2335. #line 1350 "goomsl_yacc.y"
  2336. { yyval.nPtr = new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr); }
  2337. break;
  2338. case 69:
  2339. #line 1351 "goomsl_yacc.y"
  2340. { yyval.nPtr = new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr); }
  2341. break;
  2342. case 70:
  2343. #line 1352 "goomsl_yacc.y"
  2344. { yyval.nPtr = new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr); }
  2345. break;
  2346. case 71:
  2347. #line 1353 "goomsl_yacc.y"
  2348. { yyval.nPtr = new_not(new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr)); }
  2349. break;
  2350. case 72:
  2351. #line 1354 "goomsl_yacc.y"
  2352. { yyval.nPtr = new_not(new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr)); }
  2353. break;
  2354. case 73:
  2355. #line 1355 "goomsl_yacc.y"
  2356. { yyval.nPtr = new_not(new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr)); }
  2357. break;
  2358. case 74:
  2359. #line 1356 "goomsl_yacc.y"
  2360. { yyval.nPtr = new_not(yyvsp[0].nPtr); }
  2361. break;
  2362. case 75:
  2363. #line 1359 "goomsl_yacc.y"
  2364. { yyval.nPtr = new_constFloat(yyvsp[0].strValue,currentGoomSL->num_lines); }
  2365. break;
  2366. case 76:
  2367. #line 1360 "goomsl_yacc.y"
  2368. { yyval.nPtr = new_constInt(yyvsp[0].strValue,currentGoomSL->num_lines); }
  2369. break;
  2370. case 77:
  2371. #line 1361 "goomsl_yacc.y"
  2372. { yyval.nPtr = new_constPtr(yyvsp[0].strValue,currentGoomSL->num_lines); }
  2373. break;
  2374. case 78:
  2375. #line 1366 "goomsl_yacc.y"
  2376. { yyval.nPtr = new_call(yyvsp[-2].strValue,NULL); }
  2377. break;
  2378. case 79:
  2379. #line 1367 "goomsl_yacc.y"
  2380. { yyval.nPtr = new_call(yyvsp[-4].strValue,yyvsp[-2].nPtr); }
  2381. break;
  2382. case 80:
  2383. #line 1368 "goomsl_yacc.y"
  2384. { yyval.nPtr = new_call(yyvsp[-3].strValue,NULL); }
  2385. break;
  2386. case 81:
  2387. #line 1369 "goomsl_yacc.y"
  2388. { yyval.nPtr = new_call(yyvsp[-5].strValue,yyvsp[-3].nPtr); }
  2389. break;
  2390. case 82:
  2391. #line 1373 "goomsl_yacc.y"
  2392. { yyval.nPtr = new_call_expr(yyvsp[-2].strValue,NULL); }
  2393. break;
  2394. case 83:
  2395. #line 1374 "goomsl_yacc.y"
  2396. { yyval.nPtr = new_call_expr(yyvsp[-4].strValue,yyvsp[-2].nPtr); }
  2397. break;
  2398. case 84:
  2399. #line 1377 "goomsl_yacc.y"
  2400. { yyval.nPtr = new_affec_list(yyvsp[-1].nPtr,yyvsp[0].nPtr); }
  2401. break;
  2402. case 85:
  2403. #line 1378 "goomsl_yacc.y"
  2404. { yyval.nPtr = new_affec_list(yyvsp[0].nPtr,NULL); }
  2405. break;
  2406. case 86:
  2407. #line 1380 "goomsl_yacc.y"
  2408. {
  2409. gsl_reenternamespace(yyvsp[-1].namespace);
  2410. yyval.nPtr = new_set(new_var(yyvsp[-3].strValue,currentGoomSL->num_lines),yyvsp[0].nPtr);
  2411. }
  2412. break;
  2413. case 87:
  2414. #line 1384 "goomsl_yacc.y"
  2415. {
  2416. gsl_reenternamespace(yyvsp[-1].namespace);
  2417. yyval.nPtr = new_set(new_var("&this", currentGoomSL->num_lines),yyvsp[0].nPtr);
  2418. }
  2419. break;
  2420. }
  2421. /* Line 999 of yacc.c. */
  2422. #line 2792 "goomsl_yacc.c"
  2423. yyvsp -= yylen;
  2424. yyssp -= yylen;
  2425. YY_STACK_PRINT (yyss, yyssp);
  2426. *++yyvsp = yyval;
  2427. /* Now `shift' the result of the reduction. Determine what state
  2428. that goes to, based on the state we popped back to and the rule
  2429. number reduced by. */
  2430. yyn = yyr1[yyn];
  2431. yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  2432. if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  2433. yystate = yytable[yystate];
  2434. else
  2435. yystate = yydefgoto[yyn - YYNTOKENS];
  2436. goto yynewstate;
  2437. /*------------------------------------.
  2438. | yyerrlab -- here on detecting error |
  2439. `------------------------------------*/
  2440. yyerrlab:
  2441. /* If not already recovering from an error, report this error. */
  2442. if (!yyerrstatus)
  2443. {
  2444. ++yynerrs;
  2445. #if YYERROR_VERBOSE
  2446. yyn = yypact[yystate];
  2447. if (YYPACT_NINF < yyn && yyn < YYLAST)
  2448. {
  2449. YYSIZE_T yysize = 0;
  2450. int yytype = YYTRANSLATE (yychar);
  2451. char *yymsg;
  2452. int yyx, yycount;
  2453. yycount = 0;
  2454. /* Start YYX at -YYN if negative to avoid negative indexes in
  2455. YYCHECK. */
  2456. for (yyx = yyn < 0 ? -yyn : 0;
  2457. yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
  2458. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
  2459. yysize += yystrlen (yytname[yyx]) + 15, yycount++;
  2460. yysize += yystrlen ("syntax error, unexpected ") + 1;
  2461. yysize += yystrlen (yytname[yytype]);
  2462. yymsg = (char *) YYSTACK_ALLOC (yysize);
  2463. if (yymsg != 0)
  2464. {
  2465. char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
  2466. yyp = yystpcpy (yyp, yytname[yytype]);
  2467. if (yycount < 5)
  2468. {
  2469. yycount = 0;
  2470. for (yyx = yyn < 0 ? -yyn : 0;
  2471. yyx < (int) (sizeof (yytname) / sizeof (char *));
  2472. yyx++)
  2473. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
  2474. {
  2475. const char *yyq = ! yycount ? ", expecting " : " or ";
  2476. yyp = yystpcpy (yyp, yyq);
  2477. yyp = yystpcpy (yyp, yytname[yyx]);
  2478. yycount++;
  2479. }
  2480. }
  2481. yyerror (yymsg);
  2482. YYSTACK_FREE (yymsg);
  2483. }
  2484. else
  2485. yyerror ("syntax error; also virtual memory exhausted");
  2486. }
  2487. else
  2488. #endif /* YYERROR_VERBOSE */
  2489. yyerror ("syntax error");
  2490. }
  2491. if (yyerrstatus == 3)
  2492. {
  2493. /* If just tried and failed to reuse lookahead token after an
  2494. error, discard it. */
  2495. /* Return failure if at end of input. */
  2496. if (yychar == YYEOF)
  2497. {
  2498. /* Pop the error token. */
  2499. YYPOPSTACK;
  2500. /* Pop the rest of the stack. */
  2501. while (yyss < yyssp)
  2502. {
  2503. YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
  2504. yydestruct (yystos[*yyssp], yyvsp);
  2505. YYPOPSTACK;
  2506. }
  2507. YYABORT;
  2508. }
  2509. YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
  2510. yydestruct (yytoken, &yylval);
  2511. yychar = YYEMPTY;
  2512. }
  2513. /* Else will try to reuse lookahead token after shifting the error
  2514. token. */
  2515. goto yyerrlab1;
  2516. /*----------------------------------------------------.
  2517. | yyerrlab1 -- error raised explicitly by an action. |
  2518. `----------------------------------------------------*/
  2519. yyerrlab1:
  2520. yyerrstatus = 3; /* Each real token shifted decrements this. */
  2521. for (;;)
  2522. {
  2523. yyn = yypact[yystate];
  2524. if (yyn != YYPACT_NINF)
  2525. {
  2526. yyn += YYTERROR;
  2527. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  2528. {
  2529. yyn = yytable[yyn];
  2530. if (0 < yyn)
  2531. break;
  2532. }
  2533. }
  2534. /* Pop the current state because it cannot handle the error token. */
  2535. if (yyssp == yyss)
  2536. YYABORT;
  2537. YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
  2538. yydestruct (yystos[yystate], yyvsp);
  2539. yyvsp--;
  2540. yystate = *--yyssp;
  2541. YY_STACK_PRINT (yyss, yyssp);
  2542. }
  2543. if (yyn == YYFINAL)
  2544. YYACCEPT;
  2545. YYDPRINTF ((stderr, "Shifting error token, "));
  2546. *++yyvsp = yylval;
  2547. yystate = yyn;
  2548. goto yynewstate;
  2549. /*-------------------------------------.
  2550. | yyacceptlab -- YYACCEPT comes here. |
  2551. `-------------------------------------*/
  2552. yyacceptlab:
  2553. yyresult = 0;
  2554. goto yyreturn;
  2555. /*-----------------------------------.
  2556. | yyabortlab -- YYABORT comes here. |
  2557. `-----------------------------------*/
  2558. yyabortlab:
  2559. yyresult = 1;
  2560. goto yyreturn;
  2561. #ifndef yyoverflow
  2562. /*----------------------------------------------.
  2563. | yyoverflowlab -- parser overflow comes here. |
  2564. `----------------------------------------------*/
  2565. yyoverflowlab:
  2566. yyerror ("parser stack overflow");
  2567. yyresult = 2;
  2568. /* Fall through. */
  2569. #endif
  2570. yyreturn:
  2571. #ifndef yyoverflow
  2572. if (yyss != yyssa)
  2573. YYSTACK_FREE (yyss);
  2574. #endif
  2575. return yyresult;
  2576. }
  2577. #line 1396 "goomsl_yacc.y"
  2578. void yyerror(char *str)
  2579. { /* {{{ */
  2580. fprintf(stderr, "ERROR: Line %d, %s\n", currentGoomSL->num_lines, str);
  2581. currentGoomSL->compilationOK = 0;
  2582. exit(1);
  2583. } /* }}} */