diff options
| author | Patrick Schönberger | 2021-08-11 17:18:26 +0200 |
|---|---|---|
| committer | Patrick Schönberger | 2021-08-11 17:18:26 +0200 |
| commit | 3715a3f575b615f66e8ea7e57f83849e8bae4deb (patch) | |
| tree | 58b7d31e766e937f51ee7f5b6c9211038e9e242f | |
| parent | b9322dfb8efe37f6f88a899269bdf21015f4db9a (diff) | |
| download | toc-3715a3f575b615f66e8ea7e57f83849e8bae4deb.tar.gz toc-3715a3f575b615f66e8ea7e57f83849e8bae4deb.zip | |
example and todo
| -rw-r--r-- | src/main.cpp | 6 | ||||
| -rw-r--r-- | src/repr.h | 6 | ||||
| -rw-r--r-- | test/test2.toc | 8 | ||||
| -rw-r--r-- | todo.txt | 7 |
4 files changed, 17 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index e7c03e6..3523cdf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,8 +31,7 @@ int main(int argc, const char * argv[]) return 1;
}
- std::string s = tree->toStringTree(&parser) + "\n";
-
+ //std::string s = tree->toStringTree(&parser) + "\n";
//std::cout << "Parse Tree: " << s << std::endl;
Program prg = getProgram(prog, nullptr);
@@ -41,9 +40,6 @@ int main(int argc, const char * argv[]) {
tocProgram(std::cout, prg);
- // if (!checkProgram(prg))
- // std::cerr << "Error" << std::endl;
-
std::ofstream ofs("output.c");
tocProgram(ofs, prg);
ofs.close();
@@ -79,11 +79,13 @@ struct Body struct Function
{
std::string name;
- std::vector<std::string> genericTypeNames;
- std::vector<std::vector<Type>> genericInstantiations;
Type returnType;
std::vector<Variable> parameters;
bool defined;
+
+ std::vector<std::string> genericTypeNames;
+ std::vector<std::vector<Type>> genericInstantiations;
+
Body body;
};
diff --git a/test/test2.toc b/test/test2.toc index 6e8d4f8..1447c8f 100644 --- a/test/test2.toc +++ b/test/test2.toc @@ -35,6 +35,11 @@ struct S1<T> { }
}
+struct S2 {
+ abc(): S2 { }
+ xyz(): S2 { }
+}
+
func generic1<A>(a1 : A, a2 : A) : A {
return a1 + a2;
}
@@ -57,5 +62,8 @@ func main(argc : int, argv : char**) : int { generic1<int>(1, 2);
generic1<double>(3.4, 5.6);
+ var s: S2;
+ s.abc().xyz();
+
return 0;
}
\ No newline at end of file @@ -44,17 +44,18 @@ define grammar: -
+~14.08 Abgabe Paper/Code
Missing:
-- unions
+- unions/enums
- const/static/extern
-- operator precedence
+- operator precedence(given by C compiler)
- bitfields
- nested bodies {}
- multiple files
- call outer functions with same name (::f1())
+- automatically select function/var/struct from namespace recursively
- generic methods
- nested type instantiation
- automatic dereference/->
|
