8 void exit_error(const int err_num
, const char *err_msg
)
10 fprintf(stderr
, "ERROR %d: %s\n", err_num
, err_msg
);
12 if(pInfile != NULL) { fclose(pInfile); }
13 if(pOutfile != NULL) { fclose(pOutfile); }
18 void warning_error(const int err_num
, const char *err_msg
)
20 fprintf(stderr
, "WARNING: %d: %s\n", err_num
, err_msg
);
23 void compiler_error(const int comp_num
, const char *err_msg
, char *pS
, char *pC
, char pT
[])
27 int sp_count
= 0; /* space count */
34 /* backup pointer to token to beginning of previous token. */
35 token_len
= strlen(pT
);
38 } while (strncmp(pT
, pC
, token_len
) != 0);
41 /* set pTemp to beginning of current line */
42 while(pTemp
> pS
&& *pTemp
!= '\n')
48 /* count line number to beginning of file print for user later */
51 if(*pC
== '\n') { line_num
++; }
54 pTemp
++; /* move past newline */
57 /* print last line to stderr */
58 while((*pTemp
!= '\n') && (*pTemp
!= '\0'))
63 fprintf(stderr
, "\n");
65 sp_count
--; /* off by one because of arrow printed at end of line*/
67 /* print arrow pointing to token compiler cannot comprehend */
72 fprintf(stderr
, "^\n");
76 fprintf(stderr
, "\t");
85 fprintf(stderr
, "ERROR %d: %s On Line %d.\n\n", comp_num
, err_msg
, line_num
);
90 void line_notification(const int line_num
)
92 fprintf(stderr
, "ERROR FOUND ON LINE: %d.\n", line_num
);