Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » IMP » IMP Examples
IMP Examples [message #568349] Tue, 23 October 2007 02:18
Stan Sutton is currently offline Stan SuttonFriend
Messages: 121
Registered: July 2009
Senior Member
IMP comes with several built-in examples:

* There are IMP-based IDEs that you can run; some of these are part of
the IMP meta-tooling

* With little or no programming you can create a running IMP IDE for an
example language

* You can look at the code that implements each of these IDEs

IMP-based IDEs

One IMP-based IDE in the IMP release is the LPG IDE. When you run one
of the LPG Grammar wizards, some LPG grammar files are generated. These
are ".g" and ".gi" files. If you double-click on one of these files,
they should open automatically in the LPG editor in the LPG IDE. No
special invocation of the editor or IDE is needed. When you're
examining the file file in the editor, or looking at the outliner view,
you're using the LPG IDE.

Another IMP-based IDE in the IMP release is the "PrefSpecs" IDE.
PrefSpecs is the IMP DSL for specifying IDE preferences and preference
pages. When you run the New Preferences Specification wizard a
preferences specification file is generated (a ".pfsp" file). When you
double-click on one of these files, it opens in the PrefSpecs editor in
the PrefSpecs IDE.

Yet another IMP-based IDE that is bundled with the IMP release is the
X10DT. X10 is not part of the IMP meta-tooling; it is a general-purpose
programming language. It is defined and implemented as an extension of
Java with special support for parallel programming. Documentation and
examples of X10 code can be found in the X10 project on SourceForge

There are other IMP-based IDEs that are under development as part of the
IMP meta-tooling.

IDE Development:

Just running the various IMP wizards will let you construct a
functioning IDE without any significant additional programming, just
based on the example grammar and service implementations contained in
the generated skeleton implementations.

First create a plug-in project and run the New Language wizard. We name
the langauge "LEG" (for "Little Expression Grammar") and give "leg" as
the filename extension.

Next run the LPG Grammar and Parser Wrapper wizard. This generates a
skeleton grammar specification that contains a complete grammar for the
LEG language, a simple but nontrivial example language. The LPG builder
will generate a functioning LEG scanner and parser based on this example

If you do just this much you will have a functioning LEG IDE, albeit
with very limited functionality. To exercise the LEG IDE, you need to
run a runtime workbench from your IDE-development workbench. In the
runtime workbench, create a Java project. In the source folder, create
a file with the filename extension ".leg." (An example is provided
below--but you can write your own based on the grammar.) If you
double-click on the .leg file it will open up in the LEG editor. This
will look like a very plain text editor. However, if you create a LEG
file that has syntax errors you should see these annotated in the
editor. Parsing is the one service that the LEG IDE has at this point.

In the IDE development project you can run additional wizards to create
example implementations for additional services. For instance you can
run the wizards for the token colorer, outliner, and source-text
folding. If you then restart the runtime workbench and reopen the .leg
file, you should see these additional features in the LEG IDE. If you
run additional wizards you can create additional services, most of which
will work as-is in the LEG IDE.


If you check out the IMP projects from the CVS repository, you can see
the source code for various IDEs that are in use or under development in

* Project org.eclipse.imp.lpg.runtime contains the implementation of the

* Project org.eclipse.imp.prefspecs contains the implementation of the
PrefSpecs IDE

* Project org.eclipse.imp.x10dt.ui contains elements of the X10DE

Various other projects contain in-progress implementations for several
other IDEs (look for the ".g" files that define the grammars of their

An example LEG program:

This program should parse correctly.

int exp2(int x) {
int res;
res = 1;
while(x > 0) {
res = res * 2;
x = x - 1;
return res;

void main() {
int xavier = 5;
int yahoo;

int yams;
int yellow;
yahoo = exp2(12) * xavier + 22;

yams = 23 + exp2(7);
int zanzibar;
zanzibar = xavier + yahoo + 90;

Previous Topic:IMP Help contents
Next Topic:Regarding the IMP project!
Goto Forum:

Current Time: Thu Jun 21 16:44:36 GMT 2018

Powered by FUDForum. Page generated in 0.01903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top