Compiler Construction bio photo

Compiler Construction

Twitter Github

Edit on GitHub

Milestone 1 FAQ

Overview

Installation

How can I disable the cygwin warnings about paths when building on Windows?
  1. Add a system environment variable called CYGWIN with the value nodosfilewarning.
  2. Restart eclipse.

Setup

After importing the projects into Eclipse I receive several errors that have to do with importing and including files.

If you get errors after importing the projects into Eclipse you should build the project by choosing Project > Build All from the menu.

Testing Syntax Definition

How do I get started?
  1. Create a Spoofax editor project (instructions) and a test project (instructions) in Eclipse.
  2. Create a new test suite in the test project.
    1. Select File > New > File from the menu.
    2. Use .spt as a file extension.
  3. Write your first test module in that file.

Each test module gets its own file. You can add directories to your project to group the test files. If you build the editor project, your test modules will be parsed.

Syntax Definition

Should I use templates?

Yes. This will save you several hours of work in the next assignment.

Is it possible to split my syntax definition up in several files possibly in subfolders?

Yes that is possible. You can have the following directory tree for example:

syntax/
  subdir/
    c.sdf3
  b.sdf3
  MyLanguage.sdf3

MyLanguage.sdf3 should have the following imports if it depends on b and c:

module MyLanguage

imports
  b
  subdir/c

and c should be declared as

module subdir/c

If you get errors while you think you shouldn’t, open all .sdf3 files and run Generate SDF (concrete, for selection) from the Transform button. If this does not result in a corresponding .sdf file, something is wrong in your .sdf3 file.

Why do my disambiguation tests fail?

Disambiguation tests (i.e. tests of the form test name [[...]] parse to [[..]]) compare the ASTs for both test fragments. If these ASTs differ, the test fails. Use the Show AST option in the editor’s Transform menu to view the AST; this may give you clue as to what is going wrong. A common mistake is to introduce a constructor when parsing a parenthesized expression. This can be solved by using the bracket attribute.

Why does the bracket attribute has no effect?

You probably used a constructor name together with the bracket attribute. As the SDF3 editor indicates, this is a mistake.

Why are my context-free priorities not translated into SDF2?

There is an error in these priorities, which causes the generator to fail. You probably made a typo in a constructor name.

Why does Eclipse become unresponsive when I open or run test files?

There is very likely an error in your rules for LAYOUT. Study the rules found on the slides or in the generated Common.sdf3 in a new language project. Fixing these issues should make running your tests way faster.

Why do I get a StackOverflowException and how should I handle this?

This is also very likely caused by erroneous rules for LAYOUT.

  1. Close Eclipse.
  2. Delete all files in the include folder in your MiniJava project.
  3. Fix the erroneous rules.
  4. Build your project.

Syntactic Editor Services

Simple Term Rewriting

Why am I getting a Builder failed error when I click Show desugared syntax?

You probably do not have a snippet of code selected that can be transformed by the desugar rule, thereby causing the editor-desugar rule to fail. If you select an expression and run Show desugared syntax, you will see the output of desugar applied to that expression. Alternatively, you could edit the editor-desugar rule to apply the desugar-all strategy to transform the complete AST of your MiniJava file.