#include #include #include "token.h" #include "getch.h" #define OUTLEN 1000 char out[OUTLEN]; int main(void) { int errstat; char temp[OUTLEN + MAXTOKEN], type; while (gettoken() != EOF) { errstat = 0; strcpy(out, token); while ((type = gettoken()) != '\n') { if (type == PARENS || type == BRACKETS ) { strcat(out, token); } else if (type == '*') { if ((type = peaktoken()) == PARENS || type == BRACKETS) sprintf(temp, "(*%s)", out); else sprintf(temp, "*%s", out); strcpy(out, temp); } else if (type == NAME) { sprintf(temp, "%s %s", token, out); out[0] = '\0'; /* rust sisters btfo */ strncat(out, temp, OUTLEN - 1); } else { errstat = 1; printf("err: invalid input at %s\n", token); while ((type = gettoken()) != '\n') ; ungetch('\n'); } } if (!errstat) printf("%s\n", out); } return 0; }