-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.c
71 lines (58 loc) · 1.37 KB
/
misc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "defs.h"
#include "data.h"
#include "decl.h"
void match(int t, char *what) {
if (Token.token == t) {
scan(&Token);
} else {
fatals("Expected", what);
}
}
void ident(void) {
match(T_IDENT, "identifier");
}
void semi(void) {
match(T_SEMI, ";");
}
void lbrace(void) {
match(T_LBRACE, "{");
}
void rbrace(void) {
match(T_RBRACE, "}");
}
void lparen(void) {
match(T_LPAREN, "(");
}
void rparen(void) {
match(T_RPAREN, ")");
}
void comma(void) {
match(T_COMMA, ",");
}
void warn(char *s) {
fprintf(stderr, "[Warning]: %s on line %d of %s\n", s, Line, Infilename);
}
void fatal(char *s) {
fprintf(stderr, "[Error]: %s on line %d of %s\n", s, Line, Infilename);
fclose(Outfile);
unlink(Outfilename);
exit(1);
}
void fatals(char *s1, char *s2) {
fprintf(stderr, "[Error]: %s: '%s' on line %d of %s\n", s1, s2, Line, Infilename);
fclose(Outfile);
unlink(Outfilename);
exit(1);
}
void fatald(char *s, int d) {
fprintf(stderr, "[Error]: %s: '%d' on line %d of %s\n", s, d, Line, Infilename);
fclose(Outfile);
unlink(Outfilename);
exit(1);
}
void fatalc(char *s, int c) {
fprintf(stderr, "[Error]: %s: '%c' on line %d of %s\n", s, c, Line, Infilename);
fclose(Outfile);
unlink(Outfilename);
exit(1);
}