TC-1/2-Parser Goals
Things to learn during this sub-stage that you should remember:
- Basic C++ classes
The
Locationclasses (i.e.,parse::position,parse::location, etc.) and theiroperators 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.,
%leftetc.) 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::indentmisc::indentextendsstd::ostreamwith indentation features. Use it in thePrettyPrinterto pretty-print. Understanding howmisc::indentworks 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
PrettyPrinteris an implementation of the Visitor pattern.- Efficiently debug your AST
The
DumperDotis an initial implementation of a displayer to thedotformat. It may help you a lot to visualize your AST and debug it.