/** * compile one file if filename is NULL redirect do to stdin/stdout * @param file filename * @return */ void compile(char *file) { if (file == NULL || filename_typeof(file) == 'c') { global_table_index = 0; local_table_index = NUMBER_OF_GLOBALS; while_table_index = 0; tag_table_index = 0; inclsp = iflevel = skiplevel = swstp = litptr = stkp = errcnt = ncmp = lastst = //quote[1] = 0; input2 = -1; //quote[0] = '"'; cmode = 1; glbflag = 1; nxtlab = 0; litlab = getlabel(); defmac("end\tmemory"); //add_global("memory", ARRAY, CCHAR, 0, EXTERN); //add_global("stack", ARRAY, CCHAR, 0, EXTERN); rglobal_table_index = global_table_index; //rglbptr = glbptr; //add_global("etext", ARRAY, CCHAR, 0, EXTERN); //add_global("edata", ARRAY, CCHAR, 0, EXTERN); defmac("short\tint"); initmac(); // compiler body if (file == NULL) { input = 0; } else if (!openin(file)) return; if (file == NULL) { output = 1; } else if (!openout()) return; header(); code_segment_gtext(); parse(); close(input); data_segment_gdata(); dumplits(); dumpglbs(); errorsummary(); trailer(); oflush(); close(output); pl(""); errs = errs || errfile; } else { writee("Don't understand file "); writee(file); errs = 1; } }
/** * prints usage * @return exits the execution */ void usage(void) { writee("unknown argument.\n"); exit(1); }
int main() { int s, len; char num[10]; while (scanf("%d %s",&s, num)==2&&s) { len=strlen(num); for (int i=1; i<=2*s+3; ++i) for (int j=1; j<=len*(s+2); ++j) lc[i][j]=' '; for (int k=0; k<len; k++) { int x=1, y=k*(s+2)+1; if (num[k] == '0') { writea(x, y, s); writeb(x, y, s); writec(x, y, s); writed(x, y, s); writee(x, y, s); writef(x, y, s); } else if (num[k] == '1') { writee(x, y, s); writed(x, y, s); } else if (num[k] == '2') { writeb(x, y, s); writec(x, y, s); writee(x, y, s); writef(x, y, s); writeg(x, y, s); } else if (num[k] == '3') { writef(x, y, s); writee(x, y, s); writeg(x, y, s); writed(x, y, s); writec(x, y, s); } else if (num[k] == '4') { writea(x, y, s); writeg(x, y, s); writee(x, y, s); writed(x, y, s); } else if (num[k] == '5') { writef(x, y, s); writea(x, y, s); writeg(x, y, s); writed(x, y, s); writec(x, y, s); } else if (num[k] == '6') { writef(x, y, s); writea(x, y, s); writeb(x, y, s); writec(x, y, s); writed(x, y, s); writeg(x, y, s); } else if (num[k] == '7') { writef(x, y, s); writee(x, y, s); writed(x, y, s); } else if (num[k] == '8') { writea(x, y, s); writeb(x, y, s); writec(x, y, s); writed(x, y, s); writee(x, y, s); writef(x, y, s); writeg(x, y, s); } else { writef(x, y, s); writea(x, y, s); writeg(x, y, s); writee(x, y, s); writed(x, y, s); writec(x, y, s); } } for (int i=1; i<=2*s+3; i++) { for (int j=1; j<=len*(s+2); j++) { printf("%c",lc[i][j]); if (j%(s+2)==0&&(j<len*(s+2))) printf(" "); } puts(""); } puts(""); } return 0; }