printer.c

来自「Creation d un mini-interpreteur C」· C语言 代码 · 共 48 行

C
48
字号
/* Printer.c de Grobost Frederick */#include <stdio.h>#include <stdlib.h>#include <ast.h>#include <symbtab.h>void PrintStmtList(stmtList s);void PrintStmt(statement s);int PrintArithExpr(statement s);int PrintrExprBool(statement s); int PrintBinaryOp(arithBinaryOp e);/* Pour savoir si l'on est a l'interieur d'une boucle */int inloop = 0;/* ------------------ Partie principale pour la transformation ------------------------ */void printProgram(program p) {  printf("\n /* ----   Printer du program \"%s\" realisee par Grobost Frederick   ----  */ \n \n",programGetName(p));  /* -- On affiche le nom du programme -- */  printf("#include <stdio.h>\n");  printf("#include <stdlib.h>\n");    printf("\n void %s () { \n", programGetName(p));  printf("\n");  /* -- On affiche la liste des declarations -- */  declList l = programGetDecls(p);  declListGoToHead(l); /* on se positionne en t阾e de la liste */  while(declListHasMoreElt(l)) {    /* tant qu'il y a encore des elements dans la liste */    printf(" int %s ; \n",declListGetCurrent(l));    declListMoveCurrent(l);  /* on se deplace 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?