-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.c
46 lines (40 loc) · 869 Bytes
/
parse.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
/*
* parse.c - Parse source file.
*/
#include <stdio.h>
#include <stdlib.h>
#include "absyn.h"
#include "assem.h"
#include "env.h"
#include "errormsg.h"
#include "frame.h"
#include "parse.h"
#include "semant.h"
#include "symbol.h"
#include "temp.h"
#include "translate.h"
#include "tree.h"
#include "types.h"
#include "util.h"
#define YYERROR_VERBOSE
extern int yyparse(void);
extern A_exp absyn_root;
/* parse source file fname;
return abstract syntax data structure */
A_exp parse(string fname) {
EM_reset(fname);
if (yyparse() == 0) /* parsing worked */
return absyn_root;
else {
exit(123);
return NULL;
}
}
/*int main(int argc, char **argv) {
if (argc!=2) {fprintf(stderr,"usage: a.out filename\n"); exit(1);}
A_exp exp = parse(argv[1]);
pr_exp(stdout,exp,0);
SEM_transProg(exp);
printf("\n");
return 0;
}*/