Getting Started

Installation of Xsemantics

To get started, you should first install Xsemantics plugins; you can use the update site: https://dl.bintray.com/lorenzobettini/xsemantics/updates.

Note that this composite update site contains links also to the official Xtext update site, so, if you don't have Xtext already installed, you can install Xtext also from Xsemantics' update site.

The Java code generated by Xsemantics will depend only on the plugin org.eclipse.xsemantics.runtime. Thus, in case you want to deploy your Xtext language implemented making use of Xsemantics, your language will NOT need to depend on the whole Xsemantics SDK: you only need the Runtime feature of Xsemantics.

The Xsemantics SDK contains all the features of Xsemantics, including the examples, so, if you want to use Xsemantics for your DSL, installing this SDK would be the best thing (you may also wanto to install the sources, so that you can inspect Xsemantics classes).

Sources

Sources of Xsemantics (and the examples, section Examples) are available from the git repository, please visit https://github.com/LorenzoBettini/xsemantics.

You might want to consider using Oomph to easily materialize Xsemantics sources into your workspace, together with all the needed bundles in the target platform, as illustrated in section GettingSources.

Using Xsemantics

Before you start using Xsemantics for your Xtext language, you should add in your plugin project the following dependency: org.eclipse.xsemantics.runtime.

To check whether your settings work correctly,

  1. you can create an Xtext project, accepting the defaults;
  2. add the dependency org.eclipse.xsemantics.runtime;
  3. create a file with extension xsemantics in a subdirectory of one of your source folders;
  4. give a name to your system, and save;
  5. you should now have in your project an additional folder xsemantics-gen, where Xsemantics generates the Java file; make sure to set that folder as a source folder (and don't forget to add it also to your build.properties file.

If you see something similar to the following screenshot you should be fine.

An xsemantics file and generated code

Xsemantics will generate Java classes as explained in section CodeGeneration.

Using Xsemantics in Maven builds

Xsemantics provides Maven artifacts that can be used during a Maven build. The artifacts include the runtime library of Xsemantics and the DSL compiler.

IMPORTANT: since version 1.8.1 such Maven artifacts are available from Maven central, and the groupId is org.eclipse.xsemantics.

For example

<dependency>
    <groupId>org.eclipse.xsemantics</groupId>
    <artifactId>org.eclipse.xsemantics.dsl</artifactId>
    <version>${xsemantics.version}</version>
</dependency>

The DSL compiler can be used together with the xtext-maven-plugin.

An example can be found here https://github.com/LorenzoBettini/xsemantics/tree/master/tests/org.eclipse.xsemantics.example.maven.test.