Repository navigation
Expand file tree
/
Copy pathtest.cpp
More file actions
46 lines (28 loc) · 1.55 KB
/
Copy pathtest.cpp
File metadata and controls
46 lines (28 loc) · 1.55 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
45
46
#include <iostream>
#include "include/hlcog_structure.hpp"
#include "include/hlcog_syntax_rules.hpp"
#include "include/hlcog_cg_main.hpp"
#include "include/cg/hlcog_cg_python.hpp"
#include "include/cg/hlcog_cg_cpp.hpp"
int main() {
HlCoG::HLCoG_Codegen cog(HLCoGLanguages::Python);
HlCoG_Metadata meta;
meta.metadata = std::make_tuple(HlCoGTokens::If, "", "test == 'Hi'", "");
cog.VariableType(HlCoGTokens::If, meta, HlCoGPython::InitSyntax(), HlCoGPython::InitRules());
// TODO: More syntax rules
meta.metadata = std::make_tuple(HlCoGTokens::Print, "", "'Hello, world!'", "");
cog.VariableType(HlCoGTokens::Print, meta, HlCoGPython::InitSyntax(), HlCoGPython::InitRules());
meta.metadata = std::make_tuple(HlCoGTokens::Variable, "hi", "Hello, world!", "");
cog.VariableType(HlCoGTokens::Variable, meta, HlCoGPython::InitSyntax(), HlCoGPython::InitRules());
meta.metadata = std::make_tuple(HlCoGTokens::Return, "", "20", "");
cog.VariableType(HlCoGTokens::Return, meta, HlCoGPython::InitSyntax(), HlCoGPython::InitRules());
meta.metadata = std::make_tuple(HlCoGTokens::Function, "", "idk", "my_variable");
// Set return type of function.
// C++ : basic_string class
// Python: str
meta.function_return_type = HlCoGVariableTypes::String;
cog.VariableType(HlCoGTokens::Function, meta, HlCoGPython::InitSyntax(), HlCoGPython::InitRules());
cog.VariableType(HlCoGTokens::Function, meta, HlCoGCPP::InitSyntax(), HlCoGCPP::InitRules());
std::cout << cog.GetGenerated() << '\n';
return 0;
}