-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeGenerator.cpp
35 lines (31 loc) · 1001 Bytes
/
CodeGenerator.cpp
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
#include <iostream>
#include <fstream>
#include "CodeGenerator.h"
using namespace std;
CodeGen::CodeGen (string filename, LexicalAnalyzer * L)
{
lex = L;
string cppname = filename.substr (0, filename.length()-3) + ".cpp";
cpp.open (cppname.c_str());
cpp << "// Autogenerated Scheme to C++ Code\n";
cpp << "// File: " << cppname << "\n";
cpp << "#include <iostream>\n";
cpp << "#include \"Object.h\"\n";
cpp << "using namespace std;\n\n";
}
/********************************************************************************/
/* This function will */
/********************************************************************************/
CodeGen::~CodeGen ()
{
cpp.close();
}
/********************************************************************************/
/* This function will */
/********************************************************************************/
void CodeGen::WriteCode (int tabs, string code)
{
for (int t = 0; t < tabs; t++)
cpp << '\t';
cpp << code;
}