summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/libast.cc
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/ast/libast.cc
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/ast/libast.cc')
-rw-r--r--tiger-compiler/src/ast/libast.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/libast.cc b/tiger-compiler/src/ast/libast.cc
new file mode 100644
index 0000000..0bebaa0
--- /dev/null
+++ b/tiger-compiler/src/ast/libast.cc
@@ -0,0 +1,44 @@
+/**
+ ** \file ast/libast.cc
+ ** \brief Public ast interface implementation.
+ */
+
+#include <fstream>
+
+#include <ast/dumper-dot.hh>
+#include <ast/libast.hh>
+#include <ast/pretty-printer.hh>
+
+// Define exported ast functions.
+namespace ast
+{
+ // Making the following variables const is more than merely
+ // stylistic. If they were not, Swig will create set/get for them,
+ // and there is no set (operator=), since it has a const member.
+
+ /// xalloc slot to enable escapes display in Ast display.
+ const misc::xalloc<bool> escapes_display;
+ /// xalloc slot to enable bindings display in Ast display.
+ const misc::xalloc<bool> bindings_display;
+
+ // Print the TREE on OSTR.
+ std::ostream& operator<<(std::ostream& ostr, const Ast& tree)
+ {
+ PrettyPrinter print(ostr);
+ print(tree);
+ return ostr;
+ }
+
+ /// Dump \a a on \a ostr.
+ std::ostream& dump_dot(const Ast& tree, std::ostream& ostr)
+ {
+ DumperDot dump_dot(ostr);
+ ostr << misc::resetindent << "digraph structs {" << misc::incendl;
+ ostr << "splines=line;" << misc::iendl;
+ ostr << "node [shape=plaintext]" << misc::iendl;
+ dump_dot(tree);
+ ostr << misc::decendl << "}" << misc::iendl;
+ return ostr;
+ }
+
+} // namespace ast