Lab 3(a): Setting up the Type Checking Project

Project Set-up
September 22, 2020

For the course project and for some of the homework assignments we will use the Spoofax Language Workbench.

Follow the instructions from Lab 1(a) for using Spoofax.

Creating the Project

Create a new language project using File ‣ New ‣ Project ‣ Spoofax Language Project for the type checking assignment with the following parameters:

  • Project name: chocopy.types
  • Use default location: []
  • Location: your gitlab repository
  • Identifier: chocopy.types
  • Name: chocopy
  • Version: 0.1.0-SNAPSHOT
  • Group identifier: org.example
  • Extensions: cpy
  • Syntax type: SDF3
  • Analysis type: Statix
  • Generate examples project: [x]
  • Generate unit testing project: [x]

This will give you three directories in your gitlab repository:

  • chocopy.types
  • chocopy.types.example
  • chocopy.types.test

Configuring the Project

By default, the start symbol for a project is set to Start. We want to change that to Program, the start symbol of the ChocoPy grammar. This requires changes in a couple of files:

  • Set language.sdf.jsglr-version: layout-sensitive in metaborg.yaml
  • chocopy.types/syntax/chocopy.sdf3: rename Start => Program
  • chocopy.types/editor/Syntax.esv: Start => Program
  • chocopy.types/trans/statics.stx:
    • rename Start => Program
      • add imports signatures/chocopy-sig
      • remove signature for Start and Empty
  • chocopy.types/trans/analysis.str: rename Start => Program
  • Remove the line with - org.metaborg:dynsem:${metaborgVersion} from metaborg.yaml
  • In the file trans/analysis.str file, change pre-analyze = explicate-injections-chocopy-Start to pre-analyze = explicate-injections-chocopy-Program and change post-analyze = implicate-injections-chocopy-Start to post-analyze = implicate-injections-chocopy-Program.
  • Include the types projects in the Maven build for CI and add <relativePath /> in the <parent></parent> section of the types projects pom files

Copy Syntax Definition

Copy the syntax definition from your chocopy.syntax project to the syntax/ directory of the new language project. Improve the syntax definition where necessary. Back-port the changes to the syntax project. We will grade your syntax again in the final milestone of the project.

Creating the Static Semantics

In the files /trans/statics.stx define the Statix rules that define the static semantics of ChocoPy. Statix is a modular language. It is probably a good idea to distribute your Statix definition over multiple modules.

References