Clone wiki

PPME-Lang / PPML Back-end


PPML Back-end

This page describes the back-end of PPML-IDE, including the architecture of the language stack and the code generation process. In summary, the language stack is implemented in a modular fashion in order to allow for simple reuse and extension of the domain-specific language. The following figure shows the overall structure of the current language implementation.


The two packages ppml.expressions and ppml.statements contain general programming structures such as arithmetic expressions or variable declarations. The ppml.core package holds the domain-specific programming elements available in PPML, e.g., the simulation loop or differential operators. On the top-level, ppml.modules contains the specification for PPML programs.

The following graphic further illustrates the package structure. The packages form a hierarchy where higher-level packages use and extend packages from lower levels. For instance, ppml.core adds a new Timeloop statement for the main simulation loop, and it uses the variable reference concept defined in ppml.statements in the specification of differential operators. Similarly, ppml.modules composes a PPML program (so called module) out of phases which contain a statement list.


It should be stressed that the current language stack can easily be extended, either by adding new concepts to the existing structure (evolving the language) or by providing language extensions on top of the current stack. This allows for a great flexibility for language enhancements.

Program Analysis

Programs written in PPML-IDE are analyzed using a mix of two approaches. First, a pre-processing pass is executed on all program elements recursively. Second, behavior methods on language elements allow inspect the program and compute attributes on the language nodes. The result of these analysis methods is utilized during the code generation process.

The pre-processing step is used to build up symbol tables, e.g., for the used differential operators or referenced right-hand side specifications. For each root module, i.e., PPML program in the current project, such a symbol table is created. Behavior methods allow to define attributes on language nodes, similar to attribute grammars. For instance, a list of accessed variables can be synthesized for a statement list from its children.

Code Generation

Code generation is handled by TextGen components of MPS which are responsible for assembling the target code. Each language element can have its own textgen component and thus full flexibility is guaranteed.


The code generation for a program written in the PPML-IDE works as follows.

  1. The pre-processing pass is triggered for the module root. This will create and fill several symbol tables for domain-specific elements, e.g., references to right-hand side equations.
  2. The main code generation process starts. First, PPML code for importing external variables is generated. Second, global variables used throughout the simulation are declared.
  3. PPM is initialized and domain-specific variables (relying on PPM) are defined. For instance, used differential operators can only be created after PPM was initialized.
  4. The code generation routines for the program's phases are called in sequential order of phases. As described in PPML Front-end phases do not have a semantic meaning yet.
  5. PPM is finalized and the PPML client code is closed.
  6. The right-hand side (RHS) specifications used in the simulation are translated and appended to the generated code. Each RHS gets a unique name by which it is referenced in the simulation code.

For more detailed information on the code generation process look into the TextGen components in MPS. For a good overview, start with Module_TextGen of the ppml.modules package.

PPME@bitbucket | PPME-Lang@bitbucket