Eclipse Creating Xtext Project for CASL

Create Xtext Project

First install Eclipse and intall Xtext into Eclipse if not already installed.

Then start Eclipse and click on menu:

File -> New -> Other

Which gives this dialog:

Select Xtext Project and click on next.

xtext new project

We then get a screen where we can enter the project name and language details. In this case:

Project Name
com.euclideanspace.casl

Language
Name
com.euclideanspace.casl.Editor
Extensions: casl

We then click on Finish:

xtext new project
This gives us a default project like this: xtext new project

Add Our Own Code

We can then replace the default grammar and generator with our own code. The grammar is in the following file:

/com.euclideanspace.casl/src/com/euclideanspace/casl/Editor.xtext

which can be replaced with the code at github here.

and the generator is in the following file:

/com.euclideanspace.casl/src/com/euclideanspace/casl/generator/EditorGenerator.xtend

which can be replaced with the code at github here.

Generate Editor Code

At this stage not all the files and dependancies are availible to create these we need to run GenerateEditor.mwe2 in com.euclideanspace.casl -> src -> com.euclideanspace.casl, to do this follow the procedure below.

If we want a wizard, for our laguage, to create a new project of the appopriate type then uncomment the project wizard fragment in the GenerateEditor.mwe2 file.

I changed the generating project name from "${projectName}" to "casl${projectName}" to

create new wizard

We then right click on GenerateEditor.mwe2 in com.euclideanspace.casl -> src -> com.euclideanspace.casl

and select the option RunAs mwe2Workflow

xtext generator

There may be a request in the console to download ANTLR 3

and select the option RunAs mwe2Workflow

I entered y <cr>

We then wait for the following messages in the Console:

and select the option RunAs mwe2Workflow

Running UI

Right click on /com.euclideanspace.casl/plugin.xml_gen and select Run As -> Eclipse Application. This starts up a second version of eclipse to run our app.

In this new eclipse we:

xtext

A message box asks us if we want to add the Xtext nature, say yes to this.

We can then add an SPAD file (pressing cntl-space gives auto complete)

 


metadata block
see also:

 

Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.