Features Help Download

Lomse Hacking Guide

2.5. The LDP compiler

The responsibility for transforming LDP source code into the internal model is on the Ldp compiler. It is modelled by class Compiler, and follows a typical compiler structure:

  1. A tokenizer class (LdpTokenizer) is responsible for the lexical analysis, grouping the input into language tokens.
  2. Then, class LdpParser does the syntactical analysis, and produces a parse tree formed by LdpElement objects.
  3. Next, the Analyser class is responsible for syntax validation and semantic analysis; it creates IMO objects and adds them to the parse tree.
  4. Finally, the ModelBuilder class performs the code generation phase. It basically throws away the parse tree and retains the IMO objects tree, and builds specific structures needed in certain cases. For instance, the ColStaffObjs object for scores.

(To be continued ...)