Problem:
Current implementation of the P compiler relies on backend code generators hand-written in C#, making it hard for end-users to write their own code generators. It also makes current code generators harder to write and maintain.
Solution:
String Template 4 (ST4) offers a simple way of building user-defined code generators. Integrating with ST4 is a straightforward task with very clear "handoff" between the host program and the template engine. The host program needs to read the templates, make some version of a preprocessed program tree available to them, and invoke the templates.
Notes:
- Making this pluggable will likely require adding some sort of a config file that links template names to the names of output files.
- There are multiple ports of ST4 to C#, such as this one.
- My fork of the C# port of ST4 adds back the use of embedded resources as templates, which may be helpful in re-defining some of the existing backend generators in ST4.