Noeud « Next »: , Noeud « Previous »: src/symbol, Noeud « Up »: Project Layout



3.2.6 The src/ast Directory

Namespace ast, delivered for T2. Implementation of the abstract syntax tree. The file ast/README gives an overview of the involved class hierarchy.

— File: location.hh (src/ast/)
— File: position.hh (src/ast/)

These files are now simply forwarding the definitions of yy::Position and yy::Location as provided by Bison.

— File: visitor.hh (src/ast/)

Abstract base class of the compiler's visitor hierarchy. Actually, it defines a class template GenVisitor, which expects an argument which can be either non_const_kind or const_kind. This allows to define to parallel hierarchies: ConstVisitor and Visitor, similar to iterator and const_iterator.

The understanding of the template programming used is not required at this stage as it is quite delicate, and goes far beyond your (average) current understanding of templates.

— File: default-visitor.hh (src/ast/)

Implementation of the DefaultVisitor class, which walks the abstract syntax tree, doing nothing. It is mainly used as a basis for deriving other visitors. Actually, just as above, there is a template, so that we have two different default visitors: DefaultVisitor<const_kind> and DefaultVisitor<non_const_kind>.

— File: print-visitor.hh (src/ast/)

Implementation of the PrintVisitor class, which performs pretty-printing in the tiger compiler.