-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI_Testing.cpp
More file actions
72 lines (55 loc) · 1.91 KB
/
AI_Testing.cpp
File metadata and controls
72 lines (55 loc) · 1.91 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
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
// Write a c++ program that reads a file called "input.co" that contains the following:
// "
// (lit, int | lit, lit)function(int in)
// {
// if (in == 1) return ok, 10
// if (in == 2) return ok, 88
// else return error, unexpected_int
// }
// "
// and converts it to a c++ program and outputs it to a file called "output.cpp" that contains the following:
// "
// variant<tuple<lit, int>, tuple<lit, lit>> function(int in)
// {
// if (in == 1) return make_tuple((lit)"ok", 10);
// if (in == 2) return make_tuple((lit)"not", 88);
// else return make_tuple((lit)"error", (lit)"unexpected_int");
// }
// "
Write a c++ program that reads a file called "input.co" that contains the following:
"
match (varTuple)
{
(int i, str s) => cout << "int, str: " << i << " - " << s << "\n"
(str s1, str s2) => cout << "str, str: " << s1 << " - " << s2 << "\n"
}
"
and converts it to a c++ program and outputs it to a file called "output.cpp" that contains the following:
"
match (varTuple)
(
pattern(as<tuple<int, str>>(ds(arg, arg))) = [](int i, str s) { cout << "int, str: " << i << " - " << s << "\n"; },
pattern(as<tuple<str, str>>(ds(arg, arg))) = [](str s1, str s2) { cout << "str, str: " << s1 << " - " << s2 << "\n"; }
);
"
match (varTuple)
{
(int i, str s) => cout << "int, str: " << i << " - " << s << "\n"
(str s1, str s2) => cout << "str, str: " << s1 << " - " << s2 << "\n"
}
match (varTuple)
(
pattern(as<tuple<int, str>>(ds(arg, arg))) = [](int i, str s) { cout << "int, str: " << i << " - " << s << "\n"; },
pattern(as<tuple<str, str>>(ds(arg, arg))) = [](str s1, str s2) { cout << "str, str: " << s1 << " - " << s2 << "\n"; }
);
int main()
{
bool insideFunction = false;
int depth = 0;
ifstream in("input.co");
ofstream out("output.cpp");
out.close();
system("g++ -std=c++11 First.cpp -o First");
system("./First");
return 0;
}