TC-1/2-Parser Goals

Things to learn during this sub-stage that you should remember:

Basic C++ classes

The Location classes (i.e., parse::position, parse::location, etc.) and their operator s provide a good start to study foreign C++ classes.

Writing and debugging a parser

Learn to use Bison with RE/flex, see RE/flex & Bison. Resolve simple conflicts due to precedences and associativities thanks to directives (e.g., %left etc.) and hard conflicts with loop unrolling. For example, you will need to resolve the important lvalue and array instantiation conflict.

Location Tracking

Understand how to track the location and update it, within the parser.

Inheritance

The AST hierarchy is typical example of a proper use of inheritance.

Inclusion Polymorphism

An intense use of inclusion polymorphism for accept.

Use of Virtual Specifier

Dynamic and static bindings.

misc::indent

misc::indent extends std::ostream with indentation features. Use it in the PrettyPrinter to pretty-print. Understanding how misc::indent works will be checked later, see TC-3 Goals.

The Composite design pattern

The AST hierarchy is an implementation of the Composite pattern.

The Visitor design pattern

The PrettyPrinter is an implementation of the Visitor pattern.

Efficiently debug your AST

The DumperDot is an initial implementation of a displayer to the dot format. It may help you a lot to visualize your AST and debug it.