-
Notifications
You must be signed in to change notification settings - Fork 0
/
main2.c
49 lines (40 loc) · 858 Bytes
/
main2.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
#include "defs.h"
#define extern_
#include "data.h"
#undef extern_
#include "decl.h"
#include <errno.h>
#include <stdio.h>
// Initialise global variables
static void init() {
Line = 1;
Putback = '\n';
for (int i=0; i<12; i++) {
stack[i] = 0;
freestack[i] = 1;
}
}
void freeall_stacks(void)
{
for (int i=0; i<12; i++) {
freestack[i] = 1;
stack[i] = 0;
}
}
// Print out a usage if started incorrectly
static void usage(char *prog) {
fprintf(stderr, "Usage: %s infile\n", prog);
exit(1);
}
// Main program: check arguments and print a usage
// if we don't have an argument. Open up the input
// file and call scanfile() to scan the tokens in it.
int main(int argc, char *argv[]) {
struct ASTnode *n;
if (argc != 2)
usage(argv[0]);
init();
interpretAST(argv[1]);
freeall_stacks();
return 0;
}