C++ template disambiguation with Transformers Attribute Grammars

From LRDE

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Abstract

C++ is a context-sensitive language that can be parsed using a context-free but ambiguous grammar. Disambiguation is then required to select the unique semantically-valid parse tree. Transformers, a framework for C++ program transformation, uses attribute grammars to achieve that stage. One of the hardest ambiguity in the language is related to metaprogramming. In so far as code is generated when templates are instanciated, types are not fully known at the declaration site. Therefore, type-checking is needed to perfectly handle templates, and it poses a real challenge. This report focuses on template disambiguationdetailing the problems and how to resolve it, in order to provide a better platform for source manipulation.