From c6ad2948bb98d42f8e0883ef82cd14cd2d5eda60 Mon Sep 17 00:00:00 2001 From: Patrick Schönberger Date: Sat, 14 Aug 2021 14:56:12 +0200 Subject: add antlr source code and ReadMe --- src/toc.h | 4 +++- src/visit.h | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/toc.h b/src/toc.h index 254abf2..c31e12b 100644 --- a/src/toc.h +++ b/src/toc.h @@ -305,7 +305,9 @@ void tocFunction (std::ostream & out, const Function & f, bool stub) currentInstantiation[f.genericTypeNames[i]] = instantiation[i]; } - out << f.returnType << " " << generateModifiers(namespacePrefix() + f.name, f.returnType.modifiers) << genericAppendix(instantiation) << " (" << vectorStr(f.parameters, ", ") << ")"; + out << f.returnType << " " << + generateModifiers(namespacePrefix() + f.name + genericAppendix(instantiation), f.returnType.modifiers) << + " (" << vectorStr(f.parameters, ", ") << ")"; if (stub) { diff --git a/src/visit.h b/src/visit.h index 646ac61..279a4fc 100644 --- a/src/visit.h +++ b/src/visit.h @@ -8,17 +8,17 @@ // tree can be walked selectively by providing only // needed callbacks struct Visitor { - std::function ctx)> onType = [](auto, auto){}; - std::function ctx)> onExpr = [](auto, auto){}; - std::function ctx)> onStmt = [](auto, auto){}; - std::function ctx)> onBody = [](auto, auto){}; - std::function ctx)> onFunction = [](auto, auto){}; - std::function ctx)> onVariable = [](auto, auto){}; + std::function ctx)> onType = [](auto, auto){}; + std::function ctx)> onExpr = [](auto, auto){}; + std::function ctx)> onStmt = [](auto, auto){}; + std::function ctx)> onBody = [](auto, auto){}; + std::function ctx)> onFunction = [](auto, auto){}; + std::function ctx)> onVariable = [](auto, auto){}; std::function &, const std::shared_ptr ctx)> onStructMethod = [](auto, auto){}; std::function &, const std::shared_ptr ctx)> onStructMember = [](auto, auto){}; - std::function ctx)> onStruct = [](auto, auto){}; - std::function ctx)> onNamespace = [](auto, auto){}; - std::function ctx)> onProgram = [](auto, auto){}; + std::function ctx)> onStruct = [](auto, auto){}; + std::function ctx)> onNamespace = [](auto, auto){}; + std::function ctx)> onProgram = [](auto, auto){}; }; #define VISIT(XS) for (auto x : XS) visit(x); @@ -162,9 +162,9 @@ public: v.onFunction(x, ctx); if (x.defined) { - visit(x.body); for (auto v : x.parameters) visit(v.type); + visit(x.body); } } void visit(const StructMember & x) -- cgit v1.2.3