-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeGenerator.cpp
More file actions
44 lines (39 loc) · 1.33 KB
/
Copy pathCodeGenerator.cpp
File metadata and controls
44 lines (39 loc) · 1.33 KB
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 <iostream>
#include <fstream>
#include "CodeGenerator.h"
using namespace std;
/********************************************************************************/
/* This function will */
/********************************************************************************/
CodeGen::CodeGen (string filename)
{
string cppname = filename.substr (0, filename.length()-3) + ".cpp";
cpp.open(cppname.c_str(), std::ios::out);
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;
}
string CodeGen::Tabs (int tabs){
string tabsStr = string();
for(int i = 0; i < tabs; ++i)
tabsStr += '\t';
return tabsStr;
}