3. Configuration

We will show you how to prepare your project for use with NaBL2, and write your first small specification.

3.1. Prepare your project

You can start using NaBL2 by creating a new project, or by modifying an existing project. See below for the steps for your case.

3.1.1. Start a new project

If you have not done this already, install Spoofax Eclipse, by following the installation instructions.

Create a new project by selecting New > Project... from the menu. Selecting Spoofax > Spoofax language project from the list, and click Next. After filling in a project name, an identifier, name etc will be automatically suggested. To use NaBL2 in the project, select NaBL2 as the analysis type. Click Finish to create the project.

3.1.2. Convert an existing project

If you have an existing project, and you want to start using NaBL2, there are a few changes you need to make.

First of all, make sure the metaborg.yaml file contains at least the following dependencies.

# ...
  - org.metaborg:org.metaborg.meta.nabl2.lang:${metaborgVersion}
  - org.metaborg:org.metaborg.meta.nabl2.shared:${metaborgVersion}
  - org.metaborg:org.metaborg.meta.nabl2.runtime:${metaborgVersion}

We will set things up, such that analysis rules will be grouped together in the directory trans/analysis. Create a file trans/analysis/main.str that contains the following.

module analysis/main



Add the following lines to your main trans/LANGUAGE.str.





  editor-analyze = analyze(desugar-pre,desugar-post)

If your language does not have a desugaring step, use analyze(id,id) instead.

Finally, we will add reference resolution and menus to access the result of analysis, by adding the following lines to editor/Main.esv.

module Main



You can now continue to the example specification here, or directly to the language reference.

3.2. Settings

    debug: all

List all possible flags here, and describe the resulting output.

3.3. Custom analysis

Implements hooks to add your own analysis step

3.4. Custom pretty-printing

Printing of terms

Make sure everything can be printed

3.5. Debugging

You can debug your specification by inspecting the result of analysis, and by logging a trace of the rules that get applied during constraint generation.

The result of analysis can be inspected, by selecting Spoofax > Analysis > Show Analysis from the menu.

If you want de see which rules are being applied during constraint generation, add the following to trans/analysis/main.str.


  debug-generate-constraint = debug

Now, when the analysis is executed, a trace of the constraint generation rules is written to the console.