Installation

Some setup is required before the Polyglot framework can be used. This page provides instructions and links to the necessary tools.

Prerequisites

First, install the following tools, following the instructions found at the links:
Tutorial participants: Download the Eclipse workspace prepared for the tutorial and skip the rest of this section. The prepared workspace includes version 2.6.1 of Polyglot and the skeleton of a sample extension.
Next, open Eclipse and choose a workspace directory of your choice. Go to the workbench. Go to menu Project → Build Automatically to uncheck the option to avoid headache in the next step.
Do not build automatically
Deselect Build Automatically before downloading Polyglot.
Download the Polyglot distribution from GitHub using Eclipse's Import wizard. Go to menu File → Import... and select Git → Projects from Git.
Import Polyglot from GitHub
We will import the Polyglot project from GitHub.
Select Clone URI on the next screen, and enter (paste) this URI:
https://github.com/polyglot-compiler/polyglot.git
on the screen that follows. The remaining fields will be populated automatically.
Paste Git URI here
Paste the above URI in the URI field.
On the next screen, Deselect All branches, and then choose only the master branch.
Clone master branch
Clone only the master branch.
Select an empty Local Destination Directory of your choice on the next screen. Eclipse will then clone the project on the next screen. When done, select Import existing projects, and click Finish.
Probably because of an Eclipse bug, a lot of undesired directories will be included on the build path. To fix this, right click on the project name and go to Build Path → Configure Build Path....
Correct build path first
We don't need all these directories!
On Source tab, change the Default output folder to polyglot-git/bin_ (note the underscore) and click OK. Select No when asked whether generated resources should be removed.
Change output folder
Change the output folder to bin_.
Now we are ready to build Polyglot.

Building Polyglot

Polyglot is compiled with the Ant build tool, which is already included in the Eclipse distribution. Therefore, we will build Polyglot in Eclipse directly.
First, locate build.xml under the Polyglot root directory. Right-click on the file and select Run As → Ant Build... from the menu that pops up to open the build configuration dialog.
Select Ant Build... to open the build dialog
Select Ant Build... to open the build dialog
Locate the tab Targets on the configuration dialog. The compile target should be checked by default. Also select the jar target and make sure that the Target execution order towards the bottom of the dialog shows "compile, jar" in that order.
Select compile and jar as the targets
Select compile and jar as the targets.
Finally, press Run. The Polyglot project will start building, which usually takes about a minute for a fresh build. Java files for lexers and parsers will be generated at this time. Once the build is successful, refresh the project by right-clicking the project name and select Refresh on the menu that pops up. Lastly, check the Build Automatically that we deselected before downloading Polyglot. Eclipse will then build the project, which is useful for running Java applications within Eclipse itself. The CUP JAR file located at lib/java_cup.jar will also be necessary for a successful build in Eclipse; add it to build path by right-clicking the file name and select Build Path → Add to Build Path from the menu that pops up.

Valid HTML 4.01 Transitional Valid CSS!