SourceForge.net Logo

CHORD Plug-in User Manual

 

Introduction

Eclipse Plug-in Installation

Using Eclipse Plug-in

Examples
Compiler Directives

 

 

Introduction

 

            CHORD Eclipse plug-in can be used to add CHR support to an existing Java project. It extends Eclipse Platform with two main extension points:

 

 

Eclipse Plug-in Installation

 

  1. From the Eclipse Help menu, select Software Updates and then Find and install...

  2. You will be presented with the following dialog:



    Select the Search for new features to install radio button.
    Press Next.

  3. You will next be presented with the following dialog:




  4. In the New Update Site dialog that appears, enter a name for the update site and the URL http://chord.sourceforge.net/eclipse/update and press OK.




  5. The update site will now be listed in the Install dialog.



    Ensure that there is a check next to the CHORD update site, then press Finish.

  6. You will next be presented with the following dialog:



    Ensure that there is a check next to CHORD. Other available features can be installed by checking them as well. Press Next.


  7. The installation process will next display the license agreement for CHORD.



    Select I accept the terms of the license agreements and press Next.

  8. The next dialog that appears displays the possible locations into which you can install CHORD:



    Once you have selected a site, press Finish.

  9. The next dialog that appears warns you about the fact that CHORD plug-in has not been digitally signed, just press Install All:




Using Eclipse Plug-in

 

  1. Create a new Java project. From eclipse File menu select New, Project, the following window is displayed:




  2. Press Next. Fill your project’s properties and press Finish.




  3. Now you have to add CHR support to your Java project. Right-click your project icon and select “Add/Remove CHR Support”.



  4. Your new project now has CHR support. Just create a new “.chr” file, Click on your project, File menu, New, File. Create a file with “.chr” extension and press Finish.




  5. Each “.chr” file is called a Handler, each handler is compiled into a Java program extending chord.Handler class. Type any CHR program and save it:




  6. Now you can run your CHR program by right-clicking the generated java file and choosing Run As and Java Application:




  7. Its output will be written to eclipse Console view:




Examples

CHR Examples can be found at examples.zip.


Compiler Directives

 

A Compiler directive is a line that adds meta-information to a Handler. This piece of meta-information can be used by the compiler in order to changer the way it compiles the CHR program, or this information can be used internally by the engine in order to optimize program execution. CHR compiler directives are lines following the pattern below inserted in the first lines of a program:


:- directivename “parameter string”

 

Or, just

 

:- directivename


      Actually there are just two official predefined compiler directives:

 

·        :- standalone

By default every compiled CHR program shows the state of the user-defined constraint memory every time it reaches a final state, with this command this behavior is inhibited, so the program runs as a standalone program.

·        :- package “package.name

By default every CHR compiled program is a class in java default package, you can use this directive in order to generate the class in another package. The referred package must exist to the program be compiled properly.

·        :- explain  

By using this directive when you run the generated java class it will output the reasoning explanation for the execution of the handler. This directive is not compatible with “standalone” directive, if both are present in a given handler,standalone” directive will be ignored.