Added a nice and easy to use API for my C+ compiler so you can use it as a library. Some random things you can do with it:

  • Setting compiler options dynamically
  • Custom checks: enforce a maximum level of indirection, enforce naming conventions
  • Automatically generating serialization functions for structures
  • Scripting
  • Custom language features: basic RAII, member functions

The video shows an example application that uses this library. I first enter a source file and cmdline options and compile the source file. Then, I can search this compiled file using a filter script (e.g. 'IsFunction(node) MATCH;'). Some boilerplate code gets inserted above and below to make it a valid C function and then it gets compiled, codegen'd, linked against the compiler library and finally launched, all at runtime, nothing gets written to disk. The application then calls into the native code that was generated and uses it to filter the AST, by checking whether 'IsFunction' returns true for a given node, displaying a list of all the matches, which you can then browse around in. The application uses the source information that every AST node has to locate the node in source files. When you click on a 'Token' button, the text editor goes to the corresponding location, and when you ctrl-click on an identifier, the text editor goes to the location of the corresponding definition.