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. |
We then get a screen where we can enter the project name and language details. In this case: Project Name Language We then click on Finish: |
This gives us a default project like this: |
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 |
|
We then right click on GenerateEditor.mwe2 in com.euclideanspace.casl -> src -> com.euclideanspace.casl and select the option RunAs mwe2Workflow |
There may be a request in the console to download ANTLR 3
I entered y <cr>
We then wait for the following messages in the Console:
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:
- Close the Welcome Screen.
- Create a new project, as a java project, and call it somthing like 'test'.
- In that project we create a new file (File -> New -> File ) called test.casl.
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)