compilers-lab1/main.c

27 lines
455 B
C
Raw Permalink Normal View History

2025-03-24 18:40:16 +08:00
#include "node.h"
#include <stdio.h>
extern int yyparse();
extern pNode root;
extern void yyrestart(FILE *);
extern int errors;
int main(int argc, char **argv) {
if (argc > 1) {
FILE *f = fopen(argv[1], "r");
if (!f) {
perror(argv[1]);
return 1;
}
yyrestart(f);
}
int running_res = 0;
do {
running_res = 0;
running_res = yyparse();
} while (running_res);
if (!errors) {
DFS(root, 0);
}
return 0;
}