4 #include <core/assert.hh>
5 #include "generator.hh"
7 namespace ag
= ast::generator
;
10 generateVisitorHeader(const char * working_directory
)
12 assert(working_directory
);
15 std::string
path(working_directory
);
17 path
.append("/visitor.hh");
18 out
.open(path
.c_str(), std::fstream::out
| std::fstream::trunc
);
19 assert(out
.is_open() && out
.good());
21 ag::appendGeneratedWarning(out
);
22 out
<< "#ifndef AST_VISITOR_HH" NL
23 << "# define AST_VISITOR_HH" NL
25 << "#include <ast/ast.hh>" NL
30 out
<< " /** @defgroup Visitors */" NL
32 << " * @brief The Visitor" NL
33 << " * @ingroup Visitors" NL
35 << " class Visitor" NL
38 << " virtual ~Visitor() {};" NL
42 for (node
= ag::nodes
; !node
->name
.empty() > 0; node
++)
43 out
<< " /** The visit method, see the Visitor design pattern. */" NL
44 << " virtual void visit(" << node
->name
<< " & node) = 0;"
49 << " * @brief The const Visitor" NL
50 << " * @ingroup Visitors" NL
52 << " class ConstVisitor" NL
55 << " virtual ~ConstVisitor() {};" NL
58 for (node
= ag::nodes
; !node
->name
.empty() > 0; node
++)
59 out
<< " /** The visit method, see the Visitor design pattern. */" NL
60 << " virtual void visit(const " << node
->name
<< " & node) = 0;"
64 out
<< "} // namespace ast" NL
65 << "#endif // !AST_VISITOR_HH" NL
;
69 int main(int argc
, char **argv
)
72 generateVisitorHeader(argv
[1]);