-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler_main.cpp
More file actions
44 lines (34 loc) · 903 Bytes
/
compiler_main.cpp
File metadata and controls
44 lines (34 loc) · 903 Bytes
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
#include "compiler_main.h"
#include "preprocessor.h"
#include "preproc_define.h"
#include "mudconfig.h"
#include "filemanagement.h"
#include <iostream>
#include <string>
using namespace std;
int compile(const char *fn,bool preprocess_only)
{
#ifdef MY_YY_INPUT_INIT
MY_YY_INPUT_INIT;
#endif
curfile=fn+string(".c");
FILE *real_file;
real_file=myfopen(curfile,"r");
if(!real_file)
{
std::cerr<<"There is no such file "<<curfile<<std::endl;
return 1;
}
set_real_file(real_file,curfile);
string globalinclude=getval("global include file");
bool other=globalinclude[0]=='<';
globalinclude=globalinclude.substr(1,globalinclude.length()-2);
yyin=include_file(globalinclude,other);
curfile=globalinclude;
init_define_table();
curline=1;
skipping=false;
set_preprocess_only(preprocess_only);
report_file();
return preprocess_only?yylex():yyparse();
}