hello
unknown
plain_text
10 months ago
2.0 kB
4
Indexable
char toPrint[100]; int bufIdx = 0; char *getObjName(int in){ switch (in) { case 0: return "undefine"; break; case 1: return "auto"; break; case 2: return "void"; break; case 3: return "char"; break; case 4: return "int"; break; case 5: return "long"; break; case 6: return "float"; break; case 7: return "double"; break; case 8: return "bool"; case 9: return "string"; case 10: return "function"; } return "undefine"; } void pushFunInParm(Object* variable) { if(bufIdx == 0) strcpy(toPrint,"cout"); char *temp = getObjName(variable->type); char *space = " "; strcat(toPrint, space); strcat(toPrint, temp); bufIdx++; } void stdoutPrint() { printf("%s\n", toPrint); bufIdx = 0; } int main(int argc, char* argv[]) { if (argc == 2) { yyin = fopen(yyInputFileName = argv[1], "r"); } else { yyin = stdin; } if (!yyin) { printf("file `%s` doesn't exists or cannot be opened\n", yyInputFileName); exit(1); } toPrint[0] = '\0'; // Start parsing struct list_scope *currentTemp = malloc(sizeof(struct list_scope)); if (!currentTemp) { perror("Failed to allocate memory for currentTemp"); exit(1); } INIT_LIST_HEAD(&chainHead); struct list_head *new_qhead = malloc(sizeof(struct list_head)); if (!new_qhead) { perror("Failed to allocate memory for new_qhead"); exit(1); } INIT_LIST_HEAD(new_qhead); currentTemp->queue = new_qhead; INIT_LIST_HEAD(¤tTemp->chain); list_add_tail(¤tTemp->chain, &chainHead); current = currentTemp; yyparse(); printf("Total lines: %d\n", yylineno); fclose(yyin); yylex_destroy(); return 0; }
Editor is loading...
Leave a Comment