Acse.y 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. %{
  2. /*
  3. * Andrea Di Biagio
  4. * Politecnico di Milano, 2007
  5. *
  6. * Acse.y
  7. * Formal Languages & Compilers Machine, 2007/2008
  8. *
  9. */
  10. /*************************************************************************
  11. Compiler for the language LANCE
  12. ***************************************************************************/
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <stdint.h>
  16. #include <assert.h>
  17. #include "axe_struct.h"
  18. #include "axe_engine.h"
  19. #include "symbol_table.h"
  20. #include "axe_errors.h"
  21. #include "collections.h"
  22. #include "axe_expressions.h"
  23. #include "axe_gencode.h"
  24. #include "axe_utils.h"
  25. #include "axe_array.h"
  26. #include "axe_cflow_graph.h"
  27. #include "cflow_constants.h"
  28. #include "axe_transform.h"
  29. #include "axe_reg_alloc.h"
  30. #include "reg_alloc_constants.h"
  31. #include "axe_io_manager.h"
  32. #ifndef NDEBUG
  33. # include "axe_debug.h"
  34. #endif
  35. /* global variables */
  36. int line_num; /* this variable will keep track of the
  37. * source code line number. Every time that a newline
  38. * is encountered while parsing the input file, this
  39. * value is increased by 1. This value is then used
  40. * for error tracking: if the parser returns an error
  41. * or a warning, this value is used in order to notify
  42. * in which line of code the error has been found */
  43. int num_error; /* the number of errors found in the code. This value
  44. * is increased by 1 every time a new error is found
  45. * in the code. */
  46. int num_warning; /* As for the `num_error' global variable, this one
  47. * keeps track of all the warning messages displayed */
  48. /* errorcode is defined inside "axe_engine.c" */
  49. extern int errorcode; /* this variable is used to test if an error is found
  50. * while parsing the input file. It also is set
  51. * to notify if the compiler internal state is invalid.
  52. * When the parsing process is started, the value
  53. * of `errorcode' is set to the value of the macro
  54. * `AXE_OK' defined in "axe_constants.h".
  55. * As long as everything (the parsed source code and
  56. * the internal state of the compiler) is correct,
  57. * the value of `errorcode' is set to `AXE_OK'.
  58. * When an error occurs (because the input file contains
  59. * one or more syntax errors or because something went
  60. * wrong in the machine internal state), the errorcode
  61. * is set to a value that is different from `AXE_OK'. */
  62. extern int cflow_errorcode; /* As for `errorcode' this value is used to
  63. * test if an error occurs during the creation process of
  64. * a control flow graph. More informations can be found
  65. * analyzing the file `axe_cflow_graph.h'. */
  66. /* program informations */
  67. t_program_infos *program; /* The singleton instance of `program'.
  68. * An instance of `t_program_infos' holds in its
  69. * internal structure, all the useful informations
  70. * about a program. For example: the assembly
  71. * (code and directives); the symbol table;
  72. * the label manager (see axe_labels.h) etc. */
  73. t_cflow_Graph *graph; /* An instance of a control flow graph. This instance
  74. * will be generated starting from `program' and will
  75. * be used during the register allocation process */
  76. t_reg_allocator *RA; /* Register allocator. It implements the "Linear scan"
  77. * algorythm */
  78. t_io_infos *file_infos; /* input and output files used by the compiler */
  79. %}
  80. %expect 1
  81. /*=========================================================================
  82. SEMANTIC RECORDS
  83. =========================================================================*/
  84. %union {
  85. int intval;
  86. char *svalue;
  87. t_axe_expression expr;
  88. t_axe_declaration *decl;
  89. t_list *list;
  90. t_axe_label *label;
  91. t_while_statement while_stmt;
  92. }
  93. /*=========================================================================
  94. TOKENS
  95. =========================================================================*/
  96. %start program
  97. %token LBRACE RBRACE LPAR RPAR LSQUARE RSQUARE
  98. %token SEMI COLON PLUS MINUS MUL_OP DIV_OP MOD_OP
  99. %token AND_OP OR_OP NOT_OP
  100. %token ASSIGN LT GT SHL_OP SHR_OP EQ NOTEQ LTEQ GTEQ
  101. %token ANDAND OROR
  102. %token COMMA
  103. %token FOR
  104. %token RETURN
  105. %token READ
  106. %token WRITE
  107. %token PERMUTATE LXSQ RXSQ
  108. %token <label> DO
  109. %token <while_stmt> WHILE
  110. %token <label> IF
  111. %token <label> ELSE
  112. %token <intval> TYPE
  113. %token <svalue> IDENTIFIER
  114. %token <intval> NUMBER
  115. %type <expr> exp
  116. %type <decl> declaration
  117. %type <list> declaration_list
  118. %type <label> if_stmt
  119. %type <list> cst_list
  120. /*=========================================================================
  121. OPERATOR PRECEDENCES
  122. =========================================================================*/
  123. %left COMMA
  124. %left ASSIGN
  125. %left OROR
  126. %left ANDAND
  127. %left OR_OP
  128. %left AND_OP
  129. %left EQ NOTEQ
  130. %left LT GT LTEQ GTEQ
  131. %left SHL_OP SHR_OP
  132. %left MINUS PLUS
  133. %left MUL_OP DIV_OP
  134. %right NOT
  135. /*=========================================================================
  136. BISON GRAMMAR
  137. =========================================================================*/
  138. %%
  139. /* `program' is the starting non-terminal of the grammar.
  140. * A program is composed by:
  141. 1. declarations (zero or more);
  142. 2. A list of instructions. (at least one instruction!).
  143. * When the rule associated with the non-terminal `program' is executed,
  144. * the parser notify it to the `program' singleton instance. */
  145. program : var_declarations statements
  146. {
  147. /* Notify the end of the program. Once called
  148. * the function `set_end_Program' - if necessary -
  149. * introduces a `HALT' instruction into the
  150. * list of instructions. */
  151. set_end_Program(program);
  152. /* return from yyparse() */
  153. YYACCEPT;
  154. }
  155. ;
  156. var_declarations : var_declarations var_declaration { /* does nothing */ }
  157. | /* empty */ { /* does nothing */ }
  158. ;
  159. var_declaration : TYPE declaration_list SEMI
  160. {
  161. /* update the program infos by adding new variables */
  162. set_new_variables(program, $1, $2);
  163. }
  164. ;
  165. declaration_list : declaration_list COMMA declaration
  166. { /* add the new declaration to the list of declarations */
  167. $$ = addElement($1, $3, -1);
  168. }
  169. | declaration
  170. {
  171. /* add the new declaration to the list of declarations */
  172. $$ = addElement(NULL, $1, -1);
  173. }
  174. ;
  175. declaration : IDENTIFIER ASSIGN NUMBER
  176. {
  177. /* create a new instance of t_axe_declaration */
  178. $$ = alloc_declaration($1, 0, 0, $3);
  179. /* test if an `out of memory' occurred */
  180. if ($$ == NULL)
  181. notifyError(AXE_OUT_OF_MEMORY);
  182. }
  183. | IDENTIFIER LSQUARE NUMBER RSQUARE
  184. {
  185. /* create a new instance of t_axe_declaration */
  186. $$ = alloc_declaration($1, 1, $3, 0);
  187. /* test if an `out of memory' occurred */
  188. if ($$ == NULL)
  189. notifyError(AXE_OUT_OF_MEMORY);
  190. }
  191. | IDENTIFIER
  192. {
  193. /* create a new instance of t_axe_declaration */
  194. $$ = alloc_declaration($1, 0, 0, 0);
  195. /* test if an `out of memory' occurred */
  196. if ($$ == NULL)
  197. notifyError(AXE_OUT_OF_MEMORY);
  198. }
  199. ;
  200. /* A block of code can be either a single statement or
  201. * a set of statements enclosed between braces */
  202. code_block : statement { /* does nothing */ }
  203. | LBRACE statements RBRACE { /* does nothing */ }
  204. ;
  205. /* One or more code statements */
  206. statements : statements statement { /* does nothing */ }
  207. | statement { /* does nothing */ }
  208. ;
  209. /* A statement can be either an assignment statement or a control statement
  210. * or a read/write statement or a semicolon */
  211. statement : assign_statement SEMI { /* does nothing */ }
  212. | control_statement { /* does nothing */ }
  213. | read_write_statement SEMI { /* does nothing */ }
  214. | SEMI { gen_nop_instruction(program); }
  215. ;
  216. control_statement : if_statement { /* does nothing */ }
  217. | while_statement { /* does nothing */ }
  218. | do_while_statement SEMI { /* does nothing */ }
  219. | permutate_statement SEMI { /* does nothung */ }
  220. | return_statement SEMI { /* does nothing */ }
  221. ;
  222. cst_list : NUMBER { $$ = addFirst(NULL, (void *)(intptr_t)$1); }
  223. | NUMBER COMMA cst_list { $$ = addFirst($3, (void*)(intptr_t)$1); }
  224. ;
  225. permutate_statement : PERMUTATE LPAR IDENTIFIER COMMA LXSQ cst_list RXSQ RPAR
  226. {
  227. t_axe_variable *arr = getVariable(program, $3);
  228. if (!arr || !arr->isArray) {
  229. fprintf(stderr, "Permutate works only on array!");
  230. exit(-1);
  231. }
  232. t_list *cst_list = $6;
  233. int len = getLength(cst_list);
  234. t_list *regs = NULL;
  235. for (t_list *cur = cst_list; cur != 0; cur =LNEXT(cur)){
  236. int cst_idx = (int)(intptr_t)LDATA(cur);
  237. if (cst_idx >= arr->arraySize) {
  238. fprintf(stderr, "Illegal permutation index");
  239. exit(-1);
  240. }
  241. t_axe_expression idx = create_expression(cst_idx,
  242. IMMEDIATE);
  243. int tmp = loadArrayElement(program, $3, idx);
  244. regs = addLast(regs, (void *)(intptr_t)(tmp));
  245. }
  246. cst_list = removeFirst(addLast(cst_list,
  247. LDATA(cst_list)));
  248. for (t_list *cur = cst_list, *cur_reg = regs;
  249. cur != 0; cur = LNEXT(cur),
  250. cur_reg = LNEXT(cur_reg)) {
  251. int cst_idx = (int)(intptr_t)LDATA(cur);
  252. int reg = (int)(intptr_t)LDATA(cur_reg);
  253. t_axe_expression idx = create_expression(cst_idx,
  254. IMMEDIATE);
  255. t_axe_expression elem = create_expression(reg,
  256. REGISTER);
  257. storeArrayElement(program, $3, idx, elem);
  258. }
  259. free(regs);
  260. free(cst_list);
  261. free $3;
  262. }
  263. ;
  264. read_write_statement : read_statement { /* does nothing */ }
  265. | write_statement { /* does nothing */ }
  266. ;
  267. assign_statement : IDENTIFIER LSQUARE exp RSQUARE ASSIGN exp
  268. {
  269. /* Notify to `program' that the value $6
  270. * have to be assigned to the location
  271. * addressed by $1[$3]. Where $1 is obviously
  272. * the array/pointer identifier, $3 is an expression
  273. * that holds an integer value. That value will be
  274. * used as an index for the array $1 */
  275. storeArrayElement(program, $1, $3, $6);
  276. /* free the memory associated with the IDENTIFIER.
  277. * The use of the free instruction is required
  278. * because of the value associated with IDENTIFIER.
  279. * The value of IDENTIFIER is a string created
  280. * by a call to the function `strdup' (see Acse.lex) */
  281. free($1);
  282. }
  283. | IDENTIFIER ASSIGN exp
  284. {
  285. int location;
  286. t_axe_instruction *instr;
  287. /* in order to assign a value to a variable, we have to
  288. * know where the variable is located (i.e. in which register).
  289. * the function `get_symbol_location' is used in order
  290. * to retrieve the register location assigned to
  291. * a given identifier.
  292. * A symbol table keeps track of the location of every
  293. * declared variable.
  294. * `get_symbol_location' perform a query on the symbol table
  295. * in order to discover the correct location of
  296. * the variable with $1 as identifier */
  297. /* get the location of the symbol with the given ID. */
  298. location = get_symbol_location(program, $1, 0);
  299. /* update the value of location */
  300. if ($3.expression_type == IMMEDIATE)
  301. gen_move_immediate(program, location, $3.value);
  302. else
  303. instr = gen_add_instruction
  304. (program, location, REG_0, $3.value, CG_DIRECT_ALL);
  305. /* free the memory associated with the IDENTIFIER */
  306. free($1);
  307. }
  308. ;
  309. if_statement : if_stmt
  310. {
  311. /* fix the `label_else' */
  312. assignLabel(program, $1);
  313. }
  314. | if_stmt ELSE
  315. {
  316. /* reserve a new label that points to the address where to jump if
  317. * `exp' is verified */
  318. $2 = newLabel(program);
  319. /* exit from the if-else */
  320. gen_bt_instruction (program, $2, 0);
  321. /* fix the `label_else' */
  322. assignLabel(program, $1);
  323. }
  324. code_block
  325. {
  326. /* fix the `label_else' */
  327. assignLabel(program, $2);
  328. }
  329. ;
  330. if_stmt : IF
  331. {
  332. /* the label that points to the address where to jump if
  333. * `exp' is not verified */
  334. $1 = newLabel(program);
  335. }
  336. LPAR exp RPAR
  337. {
  338. if ($4.expression_type == IMMEDIATE)
  339. gen_load_immediate(program, $4.value);
  340. else
  341. gen_andb_instruction(program, $4.value,
  342. $4.value, $4.value, CG_DIRECT_ALL);
  343. /* if `exp' returns FALSE, jump to the label $1 */
  344. gen_beq_instruction (program, $1, 0);
  345. }
  346. code_block { $$ = $1; }
  347. ;
  348. while_statement : WHILE
  349. {
  350. /* initialize the value of the non-terminal */
  351. $1 = create_while_statement();
  352. /* reserve and fix a new label */
  353. $1.label_condition
  354. = assignNewLabel(program);
  355. }
  356. LPAR exp RPAR
  357. {
  358. if ($4.expression_type == IMMEDIATE)
  359. gen_load_immediate(program, $4.value);
  360. else
  361. gen_andb_instruction(program, $4.value,
  362. $4.value, $4.value, CG_DIRECT_ALL);
  363. /* reserve a new label. This new label will point
  364. * to the first instruction after the while code
  365. * block */
  366. $1.label_end = newLabel(program);
  367. /* if `exp' returns FALSE, jump to the label $1.label_end */
  368. gen_beq_instruction (program, $1.label_end, 0);
  369. }
  370. code_block
  371. {
  372. /* jump to the beginning of the loop */
  373. gen_bt_instruction
  374. (program, $1.label_condition, 0);
  375. /* fix the label `label_end' */
  376. assignLabel(program, $1.label_end);
  377. }
  378. ;
  379. do_while_statement : DO
  380. {
  381. /* the label that points to the address where to jump if
  382. * `exp' is not verified */
  383. $1 = newLabel(program);
  384. /* fix the label */
  385. assignLabel(program, $1);
  386. }
  387. code_block WHILE LPAR exp RPAR
  388. {
  389. if ($6.expression_type == IMMEDIATE)
  390. gen_load_immediate(program, $6.value);
  391. else
  392. gen_andb_instruction(program, $6.value,
  393. $6.value, $6.value, CG_DIRECT_ALL);
  394. /* if `exp' returns TRUE, jump to the label $1 */
  395. gen_bne_instruction (program, $1, 0);
  396. }
  397. ;
  398. return_statement : RETURN
  399. {
  400. /* insert an HALT instruction */
  401. gen_halt_instruction(program);
  402. }
  403. ;
  404. read_statement : READ LPAR IDENTIFIER RPAR
  405. {
  406. int location;
  407. /* read from standard input an integer value and assign
  408. * it to a variable associated with the given identifier */
  409. /* get the location of the symbol with the given ID */
  410. /* lookup the symbol table and fetch the register location
  411. * associated with the IDENTIFIER $3. */
  412. location = get_symbol_location(program, $3, 0);
  413. /* insert a read instruction */
  414. gen_read_instruction (program, location);
  415. /* free the memory associated with the IDENTIFIER */
  416. free($3);
  417. }
  418. ;
  419. write_statement : WRITE LPAR exp RPAR
  420. {
  421. int location;
  422. if ($3.expression_type == IMMEDIATE)
  423. {
  424. /* load `immediate' into a new register. Returns the new register
  425. * identifier or REG_INVALID if an error occurs */
  426. location = gen_load_immediate(program, $3.value);
  427. }
  428. else
  429. location = $3.value;
  430. /* write to standard output an integer value */
  431. gen_write_instruction (program, location);
  432. }
  433. ;
  434. exp: NUMBER { $$ = create_expression ($1, IMMEDIATE); }
  435. | IDENTIFIER {
  436. int location;
  437. /* get the location of the symbol with the given ID */
  438. location = get_symbol_location(program, $1, 0);
  439. /* return the register location of IDENTIFIER as
  440. * a value for `exp' */
  441. $$ = create_expression (location, REGISTER);
  442. /* free the memory associated with the IDENTIFIER */
  443. free($1);
  444. }
  445. | IDENTIFIER LSQUARE exp RSQUARE {
  446. int reg;
  447. /* load the value IDENTIFIER[exp]
  448. * into `arrayElement' */
  449. reg = loadArrayElement(program, $1, $3);
  450. /* create a new expression */
  451. $$ = create_expression (reg, REGISTER);
  452. /* free the memory associated with the IDENTIFIER */
  453. free($1);
  454. }
  455. | NOT_OP NUMBER { if ($2 == 0)
  456. $$ = create_expression (1, IMMEDIATE);
  457. else
  458. $$ = create_expression (0, IMMEDIATE);
  459. }
  460. | NOT_OP IDENTIFIER {
  461. int identifier_location;
  462. int output_register;
  463. /* get the location of the symbol with the given ID */
  464. identifier_location =
  465. get_symbol_location(program, $2, 0);
  466. /* generate a NOT instruction. In order to do this,
  467. * at first we have to ask for a free register where
  468. * to store the result of the NOT instruction. */
  469. output_register = getNewRegister(program);
  470. /* Now we are able to generate a NOT instruction */
  471. gen_notl_instruction (program, output_register
  472. , identifier_location);
  473. $$ = create_expression (output_register, REGISTER);
  474. /* free the memory associated with the IDENTIFIER */
  475. free($2);
  476. }
  477. | exp AND_OP exp {
  478. $$ = handle_bin_numeric_op(program, $1, $3, ANDB);
  479. }
  480. | exp OR_OP exp {
  481. $$ = handle_bin_numeric_op(program, $1, $3, ORB);
  482. }
  483. | exp PLUS exp {
  484. $$ = handle_bin_numeric_op(program, $1, $3, ADD);
  485. }
  486. | exp MINUS exp {
  487. $$ = handle_bin_numeric_op(program, $1, $3, SUB);
  488. }
  489. | exp MUL_OP exp {
  490. $$ = handle_bin_numeric_op(program, $1, $3, MUL);
  491. }
  492. | exp DIV_OP exp {
  493. $$ = handle_bin_numeric_op(program, $1, $3, DIV);
  494. }
  495. | exp LT exp {
  496. $$ = handle_binary_comparison (program, $1, $3, _LT_);
  497. }
  498. | exp GT exp {
  499. $$ = handle_binary_comparison (program, $1, $3, _GT_);
  500. }
  501. | exp EQ exp {
  502. $$ = handle_binary_comparison (program, $1, $3, _EQ_);
  503. }
  504. | exp NOTEQ exp {
  505. $$ = handle_binary_comparison (program, $1, $3, _NOTEQ_);
  506. }
  507. | exp LTEQ exp {
  508. $$ = handle_binary_comparison (program, $1, $3, _LTEQ_);
  509. }
  510. | exp GTEQ exp {
  511. $$ = handle_binary_comparison (program, $1, $3, _GTEQ_);
  512. }
  513. | exp SHL_OP exp { $$ = handle_bin_numeric_op(program, $1, $3, SHL); }
  514. | exp SHR_OP exp { $$ = handle_bin_numeric_op(program, $1, $3, SHR); }
  515. | exp ANDAND exp { $$ = handle_bin_numeric_op(program, $1, $3, ANDL); }
  516. | exp OROR exp { $$ = handle_bin_numeric_op(program, $1, $3, ORL); }
  517. | LPAR exp RPAR { $$ = $2; }
  518. | MINUS exp {
  519. if ($2.expression_type == IMMEDIATE)
  520. {
  521. $$ = $2;
  522. $$.value = - ($$.value);
  523. }
  524. else
  525. {
  526. t_axe_expression exp_r0;
  527. /* create an expression for regisrer REG_0 */
  528. exp_r0.value = REG_0;
  529. exp_r0.expression_type = REGISTER;
  530. $$ = handle_bin_numeric_op
  531. (program, exp_r0, $2, SUB);
  532. }
  533. }
  534. ;
  535. %%
  536. /*=========================================================================
  537. MAIN
  538. =========================================================================*/
  539. int main (int argc, char **argv)
  540. {
  541. /* initialize all the compiler data structures and global variables */
  542. init_compiler(argc, argv);
  543. /* start the parsing procedure */
  544. yyparse();
  545. #ifndef NDEBUG
  546. fprintf(stdout, "Parsing process completed. \n");
  547. #endif
  548. /* test if the parsing process completed succesfully */
  549. checkConsistency();
  550. #ifndef NDEBUG
  551. fprintf(stdout, "Creating a control flow graph. \n");
  552. #endif
  553. /* create the control flow graph */
  554. graph = createFlowGraph(program->instructions);
  555. checkConsistency();
  556. #ifndef NDEBUG
  557. assert(program != NULL);
  558. assert(program->sy_table != NULL);
  559. assert(file_infos != NULL);
  560. assert(file_infos->syTable_output != NULL);
  561. printSymbolTable(program->sy_table, file_infos->syTable_output);
  562. printGraphInfos(graph, file_infos->cfg_1, 0);
  563. fprintf(stdout, "Updating the basic blocks. \n");
  564. #endif
  565. /* update the control flow graph by inserting load and stores inside
  566. * every basic block */
  567. graph = insertLoadAndStoreInstr(program, graph);
  568. #ifndef NDEBUG
  569. fprintf(stdout, "Executing a liveness analysis on the intermediate code \n");
  570. #endif
  571. performLivenessAnalysis(graph);
  572. checkConsistency();
  573. #ifndef NDEBUG
  574. printGraphInfos(graph, file_infos->cfg_2, 1);
  575. #endif
  576. #ifndef NDEBUG
  577. fprintf(stdout, "Starting the register allocation process. \n");
  578. #endif
  579. /* initialize the register allocator by using the control flow
  580. * informations stored into the control flow graph */
  581. RA = initializeRegAlloc(graph);
  582. /* execute the linear scan algorythm */
  583. execute_linear_scan(RA);
  584. #ifndef NDEBUG
  585. printRegAllocInfos(RA, file_infos->reg_alloc_output);
  586. #endif
  587. #ifndef NDEBUG
  588. fprintf(stdout, "Updating the control flow informations. \n");
  589. #endif
  590. /* apply changes to the program informations by using the informations
  591. * of the register allocation process */
  592. updateProgramInfos(program, graph, RA);
  593. #ifndef NDEBUG
  594. fprintf(stdout, "Writing the assembly file... \n");
  595. #endif
  596. writeAssembly(program, file_infos->output_file_name);
  597. #ifndef NDEBUG
  598. fprintf(stdout, "Assembly written on file \"%s\".\n", file_infos->output_file_name);
  599. #endif
  600. /* shutdown the compiler */
  601. shutdownCompiler(0);
  602. return 0;
  603. }
  604. /*=========================================================================
  605. YYERROR
  606. =========================================================================*/
  607. int yyerror(const char* errmsg)
  608. {
  609. errorcode = AXE_SYNTAX_ERROR;
  610. return 0;
  611. }