Action Language for EMF
ALE provides an Hello world!
project template:
File > New > Example...
EcoreTools ALE Examples > Hello world!
helloworld
Finish
After a few seconds a new project called helloworld should be created in your workspace. This project defines a simple HelloWorld
EClass able to print “Hello world!”. The content of the project is presented below.
The interesting files of the helloworld
project are inside the folder model
:
File | Defines |
---|---|
HelloWorld.aird | Graphical representation of HelloWorld.ecore |
HelloWorld.ale | Semantics of HelloWorld.ecore |
HelloWorld.dsl | Binding between the metamodel (HelloWolrd.ecore) and its semantics (HelloWorld.ale) |
HelloWorld.ecore | Metamodel describing the EClass HelloWorld |
HelloWorld.xmi | Instance of the EClass HelloWorld |
By opening HelloWorld.aird you will see the HelloWorld
EClass and its properties:
As you can see, all the members of HelloWorld
are displayed in a bold font. That indicates that they are defined inside HelloWorld.ale.
Note: if the members are not shown make sure that the Behavior layer is activated.
HelloWorld.ale contains the following code:
behavior HelloWorld;
open class HelloWorld { // 1
String msg := 'Hello world!'; // 2
override EString greeting() { // 3
result := self.msg; // 4
}
@main // 5
def void entryPoint() {
self.greeting().log(); // 6
}
}
HelloWorld
EClass.String
. Defining msg
within HelloWorls.ale makes it a runtime data. In other words, it does not exist in the metamodel and will be created by the ALE interpreter during the execution.greeting
operation.msg
attribute (there is no return
statement in ALE).entryPoint
operation is the entry point of the execution and should be called by the ALE interpreter.Tip: see the Reference page for a detailed overview of ALE’s syntax.
The execution can be launched through the contextual menu:
Run As > ALE launch
, a dialog should open asking you to select the model to interpretOK
.Run helloworld.dsl
------------
Hello world!
Now that we covered the basics of ALE you’re ready to go further with the MiniFsm tutorial.