If you really want to extend C ++, you will need a full C ++ parser plus name and type resolution. As you know, this is quite difficult. The best solution is to get an existing one and change it.
Our DMS Software Reengineering Toolkit is an infrastructure for implementing langauge processors. it is intended to support the construction of tools that analyze languages, perform transformations, and splash out the same language (with extended code) or another language / dialect.
DMS has a complete C ++ Front End , which analyzes C ++, builds abstract syntax trees and symbol tables (for example, all this name and type resolution).
The front of DMS / C ++ comes with DMS in its original form, so it can be customized to achieve the desired effect. You would define your DSL as an extension of the front end of C ++, and then write down transformations that convert your custom constructs into C ++ vanilla constructors and then spill out the compiled result.
DMS / C ++ was used for a wide range of conversion tasks, including those that included the C ++ extension, as you described, and included tasks that perform massive reorganizations of large C ++ applications. (See Publications on this website).
Ira Baxter
source share