console.c

Sommaire du document

Description du code

Projet Compilateur LSD010

Compilateur LSD010 développé dans le cadre du cours de syntaxe et sémantique[ref 1]

Code source ou contenu du fichier


Code c (console.c) (706 lignes) :
  1. /*
  2.  * console.c : output (terminal and files) helper file
  3.  * Part of the compiler project for LSD10 language
  4.  * Gaudry Stéphane
  5.  * More information on http://www.gaudry.be/langages-lex-yacc-intro.html
  6.  */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #if(VERBOSE_LEVEL<=DEB_E)
  11. #include <errno.h>
  12. #endif
  13. #if(VERBOSE_LEVEL<=DEB_I)
  14. #include <time.h>
  15. #endif
  16.  
  17. //includes for the var args
  18. #include <stdarg.h>
  19. //end of var args includes
  20. #include "common.h"
  21. #include "graphVizHelper.h"
  22. #include "symbolsTableDataRepresentation.h"
  23.  
  24.  
  25. extern int lexLinesCount;
  26. extern char* yytext;
  27. extern int *yylineno;
  28. extern FILE *yyin;
  29. extern AstNode *rootNode;
  30. extern DebugInfo *debugInfo;
  31.  
  32. void printHTMLTree(FILE *htmlFile, AstNode *node, int depth);
  33. void printHTMLNode(FILE *htmlFile, AstNode *node, int depth);
  34. void printXMLTree(FILE *htmlFile, AstNode *node, int depth);
  35. void printXMLNode(FILE *htmlFile, AstNode *node, int depth);
  36. /**************************************************************/
  37. /**
  38.  * Generates Yacc error with custom message
  39.  * todo: 2 function; this is used only to call the yyerror function and producing a exit(EXIT_SUCCESS),
  40.  * and another to print KO with an exit(EXIT_FAILURE) on compiler inexpected bug (like allocation error)
  41.  * Exposed method
  42.  */
  43. void onError(char* errorMsg, char* compilerFile, int compilerLine, AstNode *node)
  44. {
  45. if(node!=NULL)
  46. {
  47. lexLinesCount=node->debug->line;
  48. //lexCharsCountBeforeToken=node->debug->line; todo : yylloc.first_line??
  49. debugInfo=node->debug;
  50. }
  51. yytext=NULL;
  52. #if(VERBOSE_LEVEL<=DEB_EXEC)
  53. printMsg(DEB_W, errorMsg, compilerFile, compilerLine);
  54. #endif
  55. yyerror(errorMsg);
  56. }
  57. void onNotForwardDeclarationError(AstNode *current, AstNode *found)
  58. {
  59. char errorStr[1024];//todo: minimize length
  60. char *str = errorStr;
  61. if(current!=found)
  62. {
  63. sprintf(
  64. str,
  65. "Backward declaration failure for %s %s line %d char %d, possible forward declaration on %s %s line %d col %d",
  66. typeToString(current->type),
  67. current->info->name,
  68. current->debug->line,
  69. current->debug->linePsn,
  70.  
  71. typeToString(found->type),
  72. found->info->name,
  73. found->debug->line,
  74. found->debug->linePsn
  75. );
  76. }
  77. else
  78. {
  79. sprintf(
  80. str,
  81. "Backward declaration failure for %s %s line %d col %d",
  82. typeToString(current->type),
  83. current->info->name,
  84. current->debug->line,
  85. current->debug->linePsn
  86. );
  87. }
  88. onError(str, __FILE__, __LINE__, current);
  89. }
  90. void onNotIntegerNotBooleanTypeError(AstNode *node, char *file, int line)
  91. {
  92. char errorStr[1024];//todo: minimize length
  93. char *str = errorStr;
  94. sprintf(
  95. str,
  96. "Type check failure : %s or %s expected, but %s found for '%s' line %d col %d (compiler %s, line %d)",
  97. typeToString(AST_INTEGER_VAR_TYPE),
  98. typeToString(AST_BOOLEAN_VAR_TYPE),
  99. typeToString(node->info->computedType),
  100. node->info->name,
  101. node->debug->line,
  102. node->debug->linePsn,
  103. file,
  104. line
  105. );
  106. lexLinesCount=node->debug->line;
  107. yytext=NULL;
  108. yyerror(str);
  109. //failure for the parsed code, but success for the compiler (it must stop here)
  110. exit(EXIT_SUCCESS);
  111. }
  112. /**
  113.  * Generates Yacc error if a type is not recognized
  114.  * Exposed method
  115.  */
  116. void onUnrecognizedTypeError(int type, char* file, int line)
  117. {
  118. char errorStr[1024];//todo: minimize length
  119. sprintf(errorStr, "Unrecognized type=%s (%d) on %s line %d", typeToString(type), type, file, line);
  120. onError(errorStr, file, line, NULL);
  121. }
  122. /**
  123.  * Print custom message on stdout, depending on the Debug level
  124.  * Exposed method
  125.  */
  126. void printMsg(int msgType, char *msg, char *file, int line)
  127. {
  128. /*if(VERBOSE_LEVEL>msgType)return;*/
  129. switch(msgType)
  130. {
  131. case DEB_W :
  132. printf(";\n;\tWarning : '%s' On %s, Line %d\n;\t-------------------------------------------------------------\n", msg, file, line);
  133. break;
  134. case DEB_E :
  135. printf(";\n;\tError : '%s' On %s, Line %d\n;\t-------------------------------------------------------------\n", msg, file, line);
  136. break;
  137. case DEB_EXEC :
  138. printf("\n; %s\n",msg);
  139. break;
  140. default :
  141. printf("\n;\tMessage : '%s' On %s, Line %d\n", msg, file, line);
  142. break;
  143. }
  144. return;
  145. }
  146. /******************************************************************************/
  147.  
  148. void printDebugTree(char *htmlFileName, char *xmlFileName)
  149. {
  150.  
  151. FILE * htmlFile;
  152. time_t genTime = time(NULL);
  153. if(htmlFileName==NULL)htmlFileName=AST_HTML_FILE;
  154. if(xmlFileName==NULL)xmlFileName=AST_XML_FILE;
  155. htmlFile = fopen(htmlFileName, "w");
  156. if(htmlFile!=NULL)
  157. {
  158. printf("\n;\tPrinting AST into %s file ... (%s, col %d)", htmlFileName, __FILE__, __LINE__);
  159. fprintf(htmlFile, "<html><head><title>AST</title></head><body>\n");
  160. fprintf(htmlFile, "<h1>LSD010 AST</h1>\n");
  161. fprintf(htmlFile, "<p>Document g&eacute;n&eacute;r&eacute; le %s par le compilateur LSD0<sup>10</sup></p>", asctime(localtime(&genTime)));
  162. printHTMLTree(htmlFile, rootNode, 0);
  163. fprintf(htmlFile, "</body></html>\n");
  164. fclose(htmlFile);
  165.  
  166. #if(VERBOSE_LEVEL<=DEB_EXEC)
  167. printMsg(DEB_EXEC,"\t...OK HTML printed", __FILE__, __LINE__);
  168. #endif
  169. }
  170. else
  171. {
  172. #if(VERBOSE_LEVEL<=DEB_EXEC)
  173. printMsg(DEB_EXEC,"Printing AST into HTML file ... Can't open file", __FILE__, __LINE__);
  174. printMsg(DEB_E, (char *)strerror(errno), __FILE__, __LINE__);
  175. #endif
  176. }
  177. htmlFile = fopen(xmlFileName==NULL?AST_XML_FILE:xmlFileName, "w");
  178. if(htmlFile!=NULL)
  179. {
  180. printf("\n;\tPrinting AST into %s file ... (%s, col %d)", xmlFileName, __FILE__, __LINE__);
  181. fprintf(htmlFile, "<lsd010>\n");
  182. fprintf(htmlFile, "<![CDATA[\nDocument généré le %s par le compilateur LSD010\n]]>\n", asctime(localtime(&genTime)));
  183. printXMLTree(htmlFile, rootNode, 0);
  184. fprintf(htmlFile, "</lsd010>\n");
  185. fclose(htmlFile);
  186.  
  187. #if(VERBOSE_LEVEL<=DEB_EXEC)
  188. printMsg(DEB_EXEC,"\t...OK XML printed", __FILE__, __LINE__);
  189. #endif
  190. }
  191. else
  192. {
  193. #if(VERBOSE_LEVEL<=DEB_EXEC)
  194. printMsg(DEB_EXEC,"Printing AST into XML file ... Can't open file", __FILE__, __LINE__);
  195. printMsg(DEB_E, (char *)strerror(errno), __FILE__, __LINE__);
  196. #endif
  197. }
  198. }
  199. /**
  200.  * Generates an HTML file and an XML file with AST nodes.
  201.  * These files are generated on the current directory.
  202.  * An error message is displayed if a problem occurs on opening files
  203.  * Exposed method
  204.  */
  205. void printTree()
  206. {
  207. printDebugTree(NULL, NULL);
  208. }
  209.  
  210. //alternate row
  211. int altRowSTI=0;
  212. void printScopeStack(ScopeStack *scopeStack, FILE * htmlFile, int topItem)
  213. {
  214. if(scopeStack!=NULL)
  215. {
  216. int altRow=0;
  217. altRowSTI=0;
  218. if(topItem!=0)
  219. {
  220. fprintf(
  221. htmlFile,
  222. //"<table width=\"100%%\">",
  223. "<table width=\"100%%\" border=\"1\" cellpadding=\"2\" cellspacing=\"1\" class=\"table\">"
  224. );
  225. fprintf(
  226. htmlFile,
  227. "<thead><tr><td colspan=\"5\">Pile du symbole&nbsp;: %s</td></tr>",
  228. scopeStack->declarationNode->info->name
  229. );
  230. fprintf(htmlFile, "<tr><th>Profondeur</th><th>Port&eacute;e</th><th>Type</th><th>Ligne</th><th>Col</th></tr>");
  231. fprintf(htmlFile, "</thead><tbody>");
  232. }
  233. fprintf(
  234. htmlFile,
  235. (++altRow%2==0)? "<tr class=\"td\">": "<tr class=\"td2\">"
  236. );
  237. fprintf(
  238. htmlFile,
  239. "<td>%d</td><td>%d</td><td>%s</td><td>%d</td><td>%d</td></tr>",
  240. scopeStack->declarationNode->info->scopeDepth,
  241. scopeStack->declarationNode->info->scopeId,
  242. typeToString(scopeStack->declarationNode->info->type),
  243. scopeStack->declarationNode->debug->line,
  244. scopeStack->declarationNode->debug->linePsn
  245. );
  246. printScopeStack(scopeStack->parentPtr, htmlFile, 0);
  247. if(topItem!=0)
  248. {
  249. fprintf(htmlFile, "</tbody></table>");
  250. }
  251. }
  252. }
  253. int printSymbolsTableHeader()
  254. {
  255. FILE * htmlFile;
  256. time_t genTime = time(NULL);
  257. char *htmlFileName=SYMBOLSTABLE_HTML_FILE;
  258. htmlFile = fopen(htmlFileName, "w");
  259. if(htmlFile==NULL)
  260. {
  261. return EXIT_FAILURE;
  262. }
  263. fprintf(htmlFile, "<html><head><title>Table des symboles</title></head><body>\n");
  264. fprintf(htmlFile, "<h1>Etats de la table des symboles LSD010</h1>\n");
  265. fprintf(htmlFile, "<p>Document g&eacute;n&eacute;r&eacute; le %s par le compilateur LSD0<sup>10</sup></p>", asctime(localtime(&genTime)));
  266.  
  267. fclose(htmlFile);
  268. return EXIT_SUCCESS;
  269. }
  270. int printSymbolsTableFooter()
  271. {
  272. //printSymbolsTableItem();
  273. FILE * htmlFile;
  274. //time_t genTime = time(NULL);
  275. char *htmlFileName=SYMBOLSTABLE_HTML_FILE;
  276. htmlFile = fopen(htmlFileName, "a+");
  277. if(htmlFile==NULL)
  278. {
  279. return EXIT_FAILURE;
  280. }
  281. fprintf(htmlFile, "\n</body></html>\n");
  282.  
  283. fclose(htmlFile);
  284. return EXIT_SUCCESS;
  285. }
  286. // first null index
  287. int startNull = INITIAL_INT;
  288. // @todo: define a astnodedebug as parameter to show where
  289. // this scope enter/exit was found
  290.  
  291. int printSymbolsTableItem(char *title)
  292. {
  293. if(declarations!=NULL)
  294. {
  295. FILE * htmlFile;
  296. //time_t genTime = time(NULL);
  297. char *htmlFileName=SYMBOLSTABLE_HTML_FILE;
  298. htmlFile = fopen(htmlFileName, "a+");
  299. if(htmlFile!=NULL)
  300. {
  301. fprintf(htmlFile, "<?php \n?><h2>%s&nbsp;(port&eacute;e actuelle&nbsp;: %d)</h2>", title, scopeHelperGetCurrentScope());
  302. //fprintf(htmlFile, "<table width=\"100%%\" border=\"1\"><thead>");
  303. fprintf(htmlFile, "<?php \n?><table width=\"100%%\" border=\"1\" cellpadding=\"2\" cellspacing=\"1\" class=\"table\"><thead>");
  304. fprintf(htmlFile, "<tr><td>Index</td><td>Liste cha&icirc;n&eacute;e de <pre>SymTableEntry</pre></td></tr>");
  305. fprintf(htmlFile, "</thead><tbody>");
  306. int i;
  307. for(i=0;i<TABLES_SIZE;i++)
  308. {
  309. if(declarations[i]==NULL)
  310. {
  311. if(startNull==INITIAL_INT)
  312. {
  313. startNull=i;
  314. }
  315. }
  316. else
  317. {
  318. if(startNull!=-INITIAL_INT)
  319. {
  320. fprintf(htmlFile, ++altRowSTI%2==0?"<tr class=\"td\">":"<tr class=\"td2\">");
  321. if(startNull<-i-1)
  322. {
  323. fprintf(htmlFile, "<td>%d...%d</td><td>NULL</td></tr>", startNull, i-1);
  324. }
  325. else
  326. {
  327. fprintf(htmlFile, "<td>%d</td><td>NULL</td></tr>", i-1);
  328. }
  329. startNull = INITIAL_INT;
  330. }
  331. fprintf(htmlFile, ++altRowSTI%2==0?"<tr class=\"td\">":"<tr class=\"td2\">");
  332. fprintf(htmlFile, "<td>%d</td><td>",i);
  333. SymTableEntry *entry = declarations[i];
  334. while(entry!=NULL)
  335. {
  336. printScopeStack(entry->scopeStack, htmlFile, 1);
  337. entry = entry->next;
  338. }
  339. fprintf(htmlFile, "</td></tr>");
  340. }
  341. }
  342. if(startNull!=INITIAL_INT)
  343. {
  344. fprintf(htmlFile, ++altRowSTI%2==0?"<tr class=\"td\">":"<tr class=\"td2\">");
  345. if(startNull<i-1)
  346. {
  347. fprintf(htmlFile, "<td>%d...%d</td><td>NULL</td></tr>", startNull, i-1);
  348. }
  349. else
  350. {
  351. fprintf(htmlFile, "<td>%d</td><td>NULL</td></tr>", i-1);
  352. }
  353. startNull = INITIAL_INT;
  354. }
  355. fprintf(htmlFile, "</tbody></table>");
  356. fclose(htmlFile);
  357. return EXIT_SUCCESS;
  358. }
  359. }
  360. else
  361. {
  362. printMsg(DEB_EXEC,"-------------------------Symbols table is null", __FILE__, __LINE__);
  363. }
  364. return EXIT_FAILURE;
  365. }
  366. char *variableUsageToString(VariableUsage usage)
  367. {
  368. switch(usage)
  369. {
  370. case VAR_USAGE_NEVER:
  371. return "n'est jamais utilisée";
  372. break;
  373. case VAR_USAGE_SOMETIMES:
  374. return "est parfois utilisée";
  375. break;
  376. case VAR_USAGE_ALWAYS:
  377. return "est toujours utilisée";
  378. break;
  379. default:
  380. return "[Erreur (valeur hors norme)]";
  381. }
  382. }
  383. void printScopeUsage(ScopeStack *scopeStack)
  384. {
  385. if(scopeStack!=NULL)
  386. {
  387. "; %s(...) : la %s '%s' %s\n",
  388. scopeStack->functionNode==NULL?"Program":scopeStack->functionNode->info->name,
  389. scopeStack->declarationNode->type==NODE_TYPE_FUNCTION?"fonction":"variable",
  390. scopeStack->declarationNode->info->name,
  391. variableUsageToString(scopeStack->usage)
  392. );
  393. printScopeUsage(scopeStack->parentPtr);
  394. }
  395. }
  396. int printSymbolsUsage()
  397. {
  398. printf("\n;\n;Symbols usage\n");
  399. if(declarations!=NULL)
  400. {
  401. int i;
  402. for(i=0;i<TABLES_SIZE;i++)
  403. {
  404. if(declarations[i]!=NULL)
  405. {
  406. SymTableEntry *entry = declarations[i];
  407. while(entry!=NULL)
  408. {
  409. printScopeUsage(entry->scopeStack);
  410. entry = entry->next;
  411. }
  412. }
  413. }
  414. return EXIT_SUCCESS;
  415. }
  416. else
  417. {
  418. printMsg(DEB_EXEC,"Can't print it: Symbols table is null", __FILE__, __LINE__);
  419. }
  420. return EXIT_FAILURE;
  421. }
  422. void printScopeDebug(ScopeStack *scopeStack, int tableId, int stackId)
  423. {
  424. if(scopeStack!=NULL)
  425. {
  426. "\n; Table[%3d][%2d]= %7s %10s line %3d, col %3d; scope %d; %s function, ",
  427. tableId,
  428. stackId,
  429. typeToString(scopeStack->declarationNode->info->type),
  430. scopeStack->declarationNode->info->name,
  431. scopeStack->declarationNode->debug->line,
  432. scopeStack->declarationNode->debug->linePsn,
  433. scopeStack->declarationNode->info->scopeId,
  434. scopeStack->functionNode==NULL?"No ":scopeStack->functionNode->info->name
  435. );
  436. printScopeDebug(scopeStack->parentPtr, tableId, ++stackId);
  437. }
  438. }
  439. int printSymbolsTableDebug(char*file, int line)
  440. {
  441. printMsg(DEB_EXEC,"-------------------------Symbols table state", file, line);
  442. if(declarations!=NULL)
  443. {
  444. int i;
  445. for(i=0;i<TABLES_SIZE;i++)
  446. {
  447. if(declarations[i]!=NULL)
  448. {
  449. SymTableEntry *entry = declarations[i];
  450. while(entry!=NULL)
  451. {
  452. printScopeDebug(entry->scopeStack, i, 0);
  453. entry = entry->next;
  454. }
  455. }
  456. }
  457. return EXIT_SUCCESS;
  458. }
  459. else
  460. {
  461. printMsg(DEB_EXEC,"-------------------------Symbols table is null", __FILE__, __LINE__);
  462. }
  463. return EXIT_FAILURE;
  464. }
  465. /******************************************************************************/
  466. /**
  467.  * Prints an AST node into the html file
  468.  * Internal business
  469.  */
  470. void printHTMLNode(FILE *file, AstNode *node, int depth)
  471. {
  472. if(node!=NULL)
  473. {
  474. fprintf(file, "<li><b>Noeud&nbsp;:</b> %s&nbsp;(%d)\n", typeToString(node->type), node->type);
  475. if(node->info!=NULL)
  476. {
  477. fprintf(
  478. file,
  479. "<br /><b>Type&nbsp;:</b> %s&nbsp;<br /><b>Nom&nbsp;:</b> %s<br /><b>Valeur&nbsp;:</b> %d\n",
  480. typeToString(node->info->type),
  481. node->info->name,
  482. node->info->value
  483. );
  484. }else fprintf(file, "<li>Info null (%d)\n",depth);
  485. fprintf(file, "</li>\n");/*char *name, int type, int value
  486. while(node->rightBrother!=NULL)
  487. {
  488. printNode(file, node->rightBrother, depth);
  489. }*/
  490. }else fprintf(file, "<li>Noeud null (%d)</li>\n",depth);
  491. }
  492. /**
  493.  * Prints the AST into the html file
  494.  * Internal business
  495.  */
  496. void printHTMLTree(FILE *file, AstNode *node, int depth)
  497. {
  498. if(node!=NULL)
  499. {
  500. fprintf(file, "<ul>\n");
  501. printHTMLNode(file, node, depth);
  502. printHTMLTree(file, node->left, depth+1);
  503. printHTMLTree(file, node->right, depth+1);
  504. fprintf(file, "</ul>\n");
  505. }else fprintf(file, "<ul><li>Noeud null (%d)</li></ul>\n",depth);
  506.  
  507. }/**
  508.  * Prints an AST node into the xml file
  509.  * Internal business
  510.  */
  511. void printXMLNode(FILE *file, AstNode *node, int depth)
  512. {
  513. if(node!=NULL)
  514. {
  515. fprintf(file, "%s<depth>%d</depth>", typeToString(node->type), depth);
  516. fprintf(file, "<memaddress>%p</memaddress>", node);
  517. if(node->parent!=NULL)
  518. {
  519. fprintf(file, "<parent><type>%s</type><pmemaddress>%p</pmemaddress></parent>", typeToString(node->parent->type), node->parent);
  520. }else
  521. {
  522. fprintf(file, "<parent>NULL</parent>");
  523. }
  524. if(node->info!=NULL)
  525. {
  526. fprintf(
  527. file,
  528. "<info><rightmemaddress>%p</rightmemaddress><leftmemaddress>%p</leftmemaddress><infotype>%s</infotype><infoname>%s</infoname><infoval>%d</infoval></info>\n",
  529. node->right,
  530. node->left,
  531. typeToString(node->info->type),
  532. node->info->name,
  533. node->info->value,
  534. depth
  535. );
  536. }
  537. }
  538. else fprintf(file, "null");
  539. }/**
  540.  * Prints the AST into the xml file
  541.  * Internal business
  542.  */
  543. void printXMLTree(FILE *file, AstNode *node, int depth)
  544. {
  545. fprintf(file, "<node%d>\n", depth);
  546. printXMLNode(file, node, depth);
  547. if(node!=NULL)
  548. {
  549. printXMLTree(file, node->left, depth+1);
  550. printXMLTree(file, node->right, depth+1);
  551. }
  552. fprintf(file, "</node%d>\n", depth);
  553.  
  554. }
  555. /******************************************************************************/
  556. /**
  557.  * Returns a human readable string from a given type constant value
  558.  * Expected : one of the DEB_xxx constants
  559.  * Exposed method
  560.  */
  561. char* debugLevelToString(int type)
  562. {
  563. char *str = NULL;
  564. switch(type)
  565. {
  566. case DEB_L:
  567. str = "Lex tokens";
  568. break;
  569. case DEB_Y:
  570. str = "Yacc parsing";
  571. break;
  572. case DEB_O:
  573. str = "Misc files";
  574. break;
  575. case DEB_I:
  576. str = "Information messages";
  577. break;
  578. case DEB_P:
  579. str = "P-code generation";
  580. break;
  581. case DEB_W:
  582. str = "Warning messages";
  583. break;
  584. case DEB_EXEC:
  585. str = "Minimum excution messages";
  586. break;
  587. case DEB_E:
  588. str = "Error messages";
  589. break;
  590. case DEB_NONE:
  591. str = "Silent (no other output than p-code, and OK or KO)";
  592. break;
  593. default:
  594. str = "undefined";
  595. #if(VERBOSE_LEVEL<=DEB_W)
  596. char str[1024];//todo: minimize length
  597. sprintf(str, "Undefined constant value '%d'", type);
  598. printMsg(DEB_W, str, __FILE__, __LINE__);
  599. #endif
  600. break;
  601. }
  602. return str;
  603. }
  604. /******************************************************************************/
  605. /**
  606.  * Generates p-code output on stdout,
  607.  * and (if GENERATE_PCODE_FILE is set to 1) write it into a file
  608.  * source http://www.pps.jussieu.fr/~rifflet/enseignements/LC4/vararg.html
  609.  * Only one digit format allowed (examples %s, %d, %f, %l)
  610.  */
  611. void printPCode(FILE* pcodeFile, char *format, ...)
  612. {
  613. if(PCODE_GENERATION_BYPASS)
  614. {
  615. return;
  616. }
  617. va_list p_list;
  618. int i;
  619. long l;
  620. double f;
  621. char *s;
  622. int validFormat;
  623. validFormat=0;
  624.  
  625. va_start(p_list, format);
  626.  
  627. #if(VERBOSE_LEVEL==DEB_NONE)
  628. if(*format!=';')
  629. {
  630. #endif
  631.  
  632. while (*format != 0) {
  633. switch(*format){
  634. case '%' :
  635. validFormat=1;
  636. break;
  637. case 'd': /* type int */
  638. if(validFormat==1)
  639. {
  640. i = va_arg(p_list, int);
  641. if(pcodeFile!=NULL){
  642. fprintf(pcodeFile, "%d", i);
  643. }
  644. printf("%d", i);
  645. }
  646. break;
  647. case 'l': /* type long */
  648. if(validFormat==1)
  649. {
  650. l = va_arg(p_list, long);
  651. if(pcodeFile!=NULL){
  652. fprintf(pcodeFile, "%ld", l);
  653. }
  654. printf("%ld", l);
  655. }
  656. break;
  657. case 'f' : /* type double */
  658. if(validFormat==1)
  659. {
  660. f = va_arg(p_list, double);
  661. if(pcodeFile!=NULL){
  662. fprintf(pcodeFile, "%lf", f);
  663. }
  664. printf("%lf", f);
  665. }
  666. break;
  667. case 's' : /* type char[] */
  668. if(validFormat==1)
  669. {
  670. s = va_arg(p_list, char *);
  671. if(pcodeFile!=NULL){
  672. fprintf(pcodeFile, "%s", s);
  673. }
  674. printf("%s", s);
  675. }
  676. break;
  677. // case 'c' : /* type char * */
  678. // if(validFormat==1)
  679. // {
  680. // s = va_arg(p_list, char *);
  681. // if(pcodeFile!=NULL){
  682. // fprintf(pcodeFile, "%s", s);
  683. // }
  684. // printf("%s", s);
  685. // }
  686. // break;
  687. default : /* type char[] */
  688. validFormat=0;
  689. break;
  690. }
  691. if(validFormat==0)
  692. {
  693. printf("%c",format[0]);
  694. if(pcodeFile!=NULL){
  695. fprintf(pcodeFile, "%c",format[0]);
  696. }
  697. }
  698. format++;
  699. }
  700. #if(VERBOSE_LEVEL==DEB_NONE)
  701. }
  702. #endif
  703. va_end(p_list);
  704. }

Structure et Fichiers du projet

Afficher/masquer...


Trier par...


NomTailleModification
| _ Parent0 octets|00000000000002/06/2012 10:17:47
Pas de sous-répertoires.
NomTailleModificationAction
Afficher le fichier .h|.hscopeStack.h2.2 Ko|00000000225117/06/2011 12:33:50
Afficher le fichier .o|.ographVizHelper.o4.72 Ko|00000000483617/06/2011 12:33:46
Afficher le fichier .c|.cconsole.c18.01 Ko|00000001844417/06/2011 12:33:45
Afficher le fichier .o|.osymbolsTable.o5.2 Ko|00000000532417/06/2011 12:33:51
Afficher le fichier .sd10|lsd10lsd1075.26 Ko|00000007706717/06/2011 12:33:48
Afficher le fichier .c|.cpcode.c23.45 Ko|00000002401017/06/2011 12:33:49
Afficher le fichier .h|.hcommon.h1.08 Ko|00000000110717/06/2011 12:33:45
Afficher le fichier .h|.hsymbolsTable.h2.65 Ko|00000000271117/06/2011 12:33:50
Afficher le fichier .h|.hgraphVizHelper.h573 octets|00000000057317/06/2011 12:33:46
Afficher le fichier .o|.oscopeStack.o1.34 Ko|00000000136817/06/2011 12:33:50
Afficher le fichier .c|.cast.c27.73 Ko|00000002839317/06/2011 12:33:44
Afficher le fichier .o|.olex.yy.o18.88 Ko|00000001932817/06/2011 12:33:47
Afficher le fichier .h|.hsymbolsTableDataRepresentation.h1.31 Ko|00000000134417/06/2011 12:33:51
Afficher le fichier .o|.oy.tab.o24.45 Ko|00000002504017/06/2011 12:33:52
Afficher le fichier .h|.hscopeHelper.h719 octets|00000000071917/06/2011 12:33:49
Afficher le fichier .o|.oscopeHelper.o2.59 Ko|00000000265217/06/2011 12:33:49
Afficher le fichier .c|.chashCode.c3.94 Ko|00000000403117/06/2011 12:33:46
Afficher le fichier .l|.llsd10.l6.46 Ko|00000000661317/06/2011 12:33:48
Afficher le fichier .h|.hy.tab.h4.69 Ko|00000000480017/06/2011 12:33:52
Afficher le fichier .o|.oconsole.o12.23 Ko|00000001252417/06/2011 12:33:45
Afficher le fichier .c|.csymbolsTable.c14.91 Ko|00000001527017/06/2011 12:33:50
Afficher le fichier .c|.cgraphVizHelper.c6.11 Ko|00000000626017/06/2011 12:33:46
Afficher le fichier .h|.hpcode.h417 octets|00000000041717/06/2011 12:33:49
Afficher le fichier .c|.cscopeStack.c3.69 Ko|00000000377717/06/2011 12:33:49
Afficher le fichier .h|.hconsole.h2.21 Ko|00000000226317/06/2011 12:33:45
Afficher le fichier .c|.clex.yy.c57.93 Ko|00000005931817/06/2011 12:33:48
Afficher le fichier .h|.hhashCode.h1020 octets|00000000102017/06/2011 12:33:47
Afficher le fichier .c|.cy.tab.c84.53 Ko|00000008655817/06/2011 12:33:52
Afficher le fichier .y|.ylsd10.y22.88 Ko|00000002343417/06/2011 12:33:48
Afficher le fichier .o|.oast.o11.45 Ko|00000001172017/06/2011 12:33:45
Afficher le fichier .output|.outputy.output81.69 Ko|00000008364717/06/2011 12:33:52
Afficher le fichier .c|.cscopeHelper.c4.09 Ko|00000000418517/06/2011 12:33:49
Afficher le fichier .h|.hastDataRepresentation.h1.87 Ko|00000000191217/06/2011 12:33:45
Afficher le fichier .h|.hconst.h4.01 Ko|00000000410217/06/2011 12:33:46
Afficher le fichier .h|.hast.h2.39 Ko|00000000245117/06/2011 12:33:44
Afficher le fichier .o|.ohashCode.o1.45 Ko|00000000148017/06/2011 12:33:47

Avertissement

Ce code présente une manière possible d'implémenter un compilateur, et certains choix peuvent être discutés.
Cependant, il peut donner des pistes pour démarrer, ou approcher certains concepts, et je tenterais par la suite de mettre à jour le code.

Avertissement : Erreurs sur le site de l'infobrol

Sommaire du document

La base de données est temporairement indisponible

Le site rencontre momentanément quelques problèmes...

La base de données est temporairement indisponible (), ce qui explique que de nombreuses fonctions ne soient temporairement pas accessibles (par exemple les liens de navigation, les sommaires, etc.) et que l'affichage des pages soit beaucoup plus lent.

Veuillez réessayer dans quelques minutes (les tests automatiques sont effectués toutes les 15 minutes).

Je vous présente mes excuses pour le désagrément que cela engendre.

Steph.

 

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Notes

  1. a,b LSD010 : Langage Simple et Didactique Il existe une un certain nombre d'interprétations de l'acronyme LSD (Langage Symbolique Didactique, Langage Sans Difficulté, Langage Simple et Didactique). LSD010 est la version 2010 de la suite LSD80, LSD_02, LSD03, LSD04, LSD05, LSD06, LSD07, LSD08, et LSD09.

 

Références

  1. livre Langue du document: fr IHDCB332 - Théorie des langages : Syntaxe et sémantique : PY Schobbens, Syntaxe et sémantique (Janvier 2010)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-8061
Document créé le 01/01/70 &am12Thu, 01 Jan 1970 00:00:00 +0000amvUTC; 00:00, dernière modification le Vendredi 17 Juin 2011, 10:12
Source du document imprimé : http://www.gaudry.be/ Document affiché 0 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (afficher)

La gestion des membres est momentanement desactivee pour des raisons de maintenance.

Navigation (masquer)
Apparence (afficher)
Stats (afficher)
867 documents
astuces.
niouzes.
definitions.
membres.
2290 messages.

Document genere en :
0,42 seconde
Citation (masquer)
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 08:17, toutes les heures sont au format GMTs