-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
113 lines (83 loc) · 3.31 KB
/
main.cc
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*********************************************************************************************
cfglp : A CFG Language Processor
--------------------------------
About:
Implemented by Uday Khedker (http://www.cse.iitb.ac.in/~uday) for
the courses cs302+cs306: Language Processors (theory and lab) at
IIT Bombay. Release date Jan 6, 2013. Copyrights reserved by Uday
Khedker. This implemenation has been made available purely for
academic purposes without any warranty of any kind.
Please see the README file for some details. A doxygen generated
documentation can be found at http://www.cse.iitb.ac.in/~uday/cfglp
***********************************************************************************************/
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <stdio.h>
using namespace std;
#include "common-classes.hh"
#include "evaluate.hh"
#include "support.hh"
#include "reg-alloc.hh"
#include "symtab.hh"
#include "ast.hh"
#include "program.hh"
#include "options.hh"
#include "cfglp-ctx.hh"
#include "parse.tab.hh"
extern FILE * yyin;
extern void init_Scanner();
cfglp_ctx::cfglp_ctx() { init_Scanner(); }
int
main(int argc, char * argv[])
{
/* Process command line options and set up files etc. */
cmd_options.process_Options(argc, argv);
/* Set up the contex of parsing, initialize the scanner */
cfglp_ctx ctx;
/* Create the parser object and parse the input program */
yy::cfglp parser(ctx);
int v = parser.parse();
// map<string, proc_Ptr>::iterator i;
// for (i = proc_list->begin(); i != proc_list->end(); i++)
// i->second->print_AST(ast_fp);
/*
Ensure that parsing has succeded before
proceeding to the rest of compilation
*/
// report_Violation_and_Abort (v==0, "Cannot parse the input program");
// /* Produce various dumps by checking the command line options */
if ((error_Status() == false) && (cmd_options.show_Ast()))
program_object_P->print_AST();
if ((error_Status() == false) && (cmd_options.show_Symtab()))
program_object_P->print_Symtab();
if ((error_Status() == false) && (cmd_options.show_Program()))
program_object_P->print_Program();
/****************** Evaluate ******************/
if ((error_Status() == false) && (cmd_options.do_Eval()))
program_object_P->evaluate();
// /****************** Compile ******************/
// if ((error_Status() == false) && (cmd_options.do_Compile()))
// {
// program_object_P->compile();
//
// /*
// Compilation assigns the offsets so we
// should produce symtab dumps again.
// */
// if ((error_Status() == false) && (cmd_options.show_Program()))
// program_object_P->print_Program();
// if ((error_Status() == false) && (cmd_options.show_Symtab()))
// program_object_P->print_Symtab();
// }
return 0;
}
namespace yy {
void
cfglp::error(location const &loc, const std::string& s)
{
std::cerr << "\n cfglp error at " << loc << ": " << s << "\n";
}
}