This guide describes how to add a new C++ output generator to NIMBLE. C++ output generators are used to generate lines of C++ code from NIMBLE syntax trees.

Adding a C++ Generator

  1. Add an entry to the cppOutputCalls list in genCpp_generateCpp.R. The entry should be of the form fxnName = 'cppGeneratorName', where where fxnName is the name of the DSL function to generate C++ code for, and 'cppGeneratorName' is a character string naming the new C++ generator function.

  2. Create a new C++ generator function.
    • NIMBLE C++ generator functions take two arguemnts:
      1. code, a NIMBLE expression class object that has been annotated by size processing
      2. symTab, the symbolTable for the nimbleFunction method that code is being generated for.
    • C++ generator functions should return a character string that is a line of C++ code.

Commonly Used C++ Generators

NIMBLE has many C++ generator functions. We list a few below, but they can all be found in genCpp_generateCpp.R.