-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
51 lines (38 loc) · 1007 Bytes
/
main.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
/****************************************************************************
main.c:
Contains the main() function which drives the whole parsing process.
*****************************************************************************/
#include <stdio.h>
#include "c++2python.h"
#include "c++2python.tab.h"
#define DEBUG
static ast_node *g_parse_tree;
void yyerror(char const *s)
{
fprintf(stdout, "Error.\n");
fprintf(stderr, "%s\n", s);
}
void set_parse_tree(ast_node *tree)
{
g_parse_tree = tree;
}
int main(int argc, char **argv)
{
if (argc > 1) {
freopen(argv[1], "r", stdin);
}
if (argc > 2) freopen(argv[2], "w", stdout);
yyparse();
if (g_parse_tree)
{
check_semantics(g_parse_tree);
transtext_ast(g_parse_tree);
printf("\nmain()");
#ifdef DEBUG
freopen("tree.htm", "w", stdout);
printf("Parse tree:\n");
print_ast(g_parse_tree);
#endif
}
return 0;
}