Overview

DSL Forge is a framework for the development of domain-specific language (DSL) editors for web applications and cloud IDEs. The framework makes it possible to create and edit models, launch automated tool chains on the server, including model-to-model transformations, code generation, live validation, and execution of the generated artefacts.

The framework is composed of two features:

  • Tooling for language development, and
  • Runtime, or Target Components.

The Tooling allows generating editors which are executed on top of the Runtime.

The Tooling

Given a language grammar, the Tooling allows generating automatically a web editor, which can be embedded into any web application, should it be a HTML/JavaScript application, or a dynamic Java EE application. The following figure illustrates the principle.

DSL Forge Tooling Generators

DSL Forge Tooling Generators

Basically, two paths are illustrated each of which covers a specific use case:

Generate ACE Editor: Generates a JavaScript parser, and module scripts which define how ACE is customized for the given DSL (namely the language mode and the language worker). The generated artefacts are packaged into a static web project.

Generate Xtext RAP Editor: Generates a JavaScript parser and ACE modules. In addition, the generated JavaScript artefacts are wrapped by a custom RAP widget, which is then embedded into an Eclipse RAP editor. The generated artefacts are packaged into an Eclipse plugin.

How It Works

The core of the generator is a model to text transformation between Xtext and ANTLR. Indeed, compared to the ANTLR specification language, the Xtext language uses extra sugar (e.g. EMF typed references, Xbase, etc.).

The idea is to extract the base ANTLR grammar from the Xtext grammar, and use a standard ANTLR Parser Generator to get a JavaScript parser, which can be then executed on the client. However, in order to keep the advantages of the Xtext features, one can also make the client interact with an EMF/Xtext back-end, such as to trigger the Xtext parser, synchronize with XMI resources, launch EMF validation and code generators, enhance content assist with typed references, etc.

Both scenarios are covered by the tool, as this first open-source version comes with two generators, each of which fulfills one of the above scenarios.

The Runtime

The Runtime target components are required if you develop against the Eclipse Remote Application Platform (RAP). It is a set of plugins providing services such as typed content assist, workspace management, persistency, etc. The plugins are built on top of the Basic Equinox RAP Target you can already download from the Eclipse RAP update sites.

DSL Forge’s editors can be customized according to the use case. It’s up to the developer to decide what should be done on the client, versus what should be done on the server. The following table illustrates the possible options in typical client/server architectures.

Editor Features

Editor Features

 

Depending on the use case, you may want customize some features from the server, such as parsing (syntax validation), scoping, or semantic validation. You may decide to proceed upon user request (e.g. on button click, on save, etc.) or systematically at each user interaction with the UI (e.g. on text modify). If you are using a Java backend, you probably want a centralized location where you manage the resource sets, persist the files, store workspace metadata, etc.

In other scenarios, features like syntax highlighting, text hovering, or content assist, are required on the client side, so that the amount of HTTP calls between the client and the server is minimized; large scale applications fall in this scenario.

As the generated editor has an embedded JavaScript ANTLR parser which mirrors the Xtext parser, the text content can be parsed either on the server or on the client, or both. Actually, this depends on the use case, and the level of performance you are seeking.

Default Features

 Syntax Highlighting

Default syntax highlighting displays text in different colors and fonts according to the category of terms, e.g. keyword, strings, line comments, and block comments. Together with syntax highlighting, brace matching  makes it simple to see if a brace has been left out, or to locate the match of the brace the cursor is on, by highlighting the pair in a different color.

Syntax Highlighting

Syntax Highlighting

Syntax Validation

Syntax validation is roughly equivalent to checking whether text input is grammatically correct (without worrying about the meaning, as opposed to semantic validation). The purpose of syntax validation is to check that the user is entering a valid sequence of tokens. The language parser takes the tokens produced during the lexical analysis stage, and attempts to build an abstract syntax tree (AST) structure to represent that input. The editor reacts to invalid sequences of tokens by displaying annotations and messages: errors, warning, and information.

Syntax Validation

Syntax Validation

Content Assist

Content Assist, also called autocomplete or auto completion, helps the user predict the rest of a word a user is typing. Press “CRTL+SPACE” to show the content assist popup, and select a suggestion from the popup by double-clicking on the proposal or hitting “ENTER”. Content Assist proposes keywords, local references, global references (i.e. references located in other resources), as well as templates, also known as code snippets.

Content Assist

Content Assist

 

Template Proposals

The content assist popup also proposes templates, or snippets, to help speed up coding. Template proposals are special entries which let the user generate in one click the skeleton of a class, an entity, or whatever the language abstraction is. The templates are located in a separate file and are loaded by ACE the classic way. The user can then navigate through the place holders using the “TAB” key and fill in the values of the template.

Template Proposals

Template Proposals

Semantic Validation

If your application has a Java back-end, server-side validation can be used to validate additional constraints on the language instances. In this case, it is possible to integrate model validators that can be triggered in live mode, or on user request. EMF-based validators, including the Xtext validation framework, work out-of-the box as the validators are bound in the runtime plugin, which is packaged as-is in the web application.

Semantic Validation

Semantic Validation

Text Hover

Hovering is typically used to display documentation, for example hovering over a reference displays the documentation attached to its declaring type. In the example below, hovering over an entity displays its name, type, and a link to package documentation.

Text Hover

Text Hover

Code Folding

Folding allows selectively hiding and displaying sections of the model being edited. This allows the user to manage a large amount of code, while viewing only those subsections which are specifically relevant at a given time. Identification of folds is automatic for curly brackets, and can be adapted based on the syntax of the language.

Code Folding

Code Folding

Key Bindings

Keyboard shortcuts are used to expedite common operations by reducing input sequences to a few keystrokes. The generated editors provide the most commonly used key bindings, here is the default key bindings:

  • CRTL+SPACE: Content assist,
  • CRTL+S: Save,
  • CRTL+C: Copy,
  • CRTL+V: Paste,
  • CRTL+Z: Undo,
  • CRTL+Y: Redo,
  • CRTL+F: Find text.

Supported Web Development Platforms

Two web development platforms are now supported:

  • Eclipse Remote Application Platform (RAP)
  • Eclipse Web Tools Platform (WTP)

Remote Application Platform

The Remote Application Platform (RAP) is a framework for modular business applications that can be accessed from different types of clients including web browsers, rich clients, and mobile devices. It provides a powerful, multi-platform widget toolkit with SWT API that enables developers to write applications entirely in Java and re-use the same code on different platforms. More information about Eclipse RAP can be found at https://www.eclipse.org/rap/

Web Tools Platform

The Web Tools Project (WTP) aims to provide common infrastructure available to any Eclipse-based development environment targeting web applications. WTP provides tools to develop web applications following the Sun Microsystems Java™ Servlet 2.3 Specification and the Sun Microsystems JSP 1.2 Specification. Web applications can be simple (consisting of static web pages) or they can be more advanced and include Java Server Pages (JSP) files and Java servlets. More info about WTP can be found on https://www.eclipse.org/webtools/

Dependencies with other tools

DSL Forge is open source and uses components from other open source projects under EPL and BSD liscences. Below a brief description of the involved technologies:

ACE

Ace (Ajax.org Cloud9 Editor) is a standalone code editor written in JavaScript. Its goal is to create a web-based code editor that matches and extends the features, usability, and performance of existing native editors such as TextMate, Vim, or Eclipse. It can be easily embedded in any web page and JavaScript application. Ace is developed as the primary editor for Cloud9 IDE and as the successor of the Mozilla Skywriter project. More info about ACE on https://ace.c9.io

ANTLR

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It’s widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build abstract syntax trees. More info about ANTLR at https://www.antlr.org/

Xtext

Xtext is an open-source framework for developing programming languages and domain-specific languages (DSLs) based on ANTLR grammars. It uses a subset of ANTLR and is specifically tailored to EMF-based models. It also provides customizable advanced features well-integrated with Eclipse IDEs. More info about Xtext at https://eclipse.org/Xtext/

Licence

DSL Forge program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which is available at https://www.eclipse.org/legal/epl-v10.html

4 Steps to get your DSL online!

Get the web plugin to package with RAP, a Maven/Tycho project to actually build and package the editor as a web application archive (war), and the target platform on top of which to compile and build the web application. Build the web archive and deploy on Tomcat.

Installation

The current DSL Forge version is based on Eclipse Mars packages. The packages are available under https://www.eclipse.org/downloads/packages/ To know which package is the most appropriate for you, select one of the following alternatives.

Overview

DSL Forge is a framework for the development of domain-specific language (DSL) editors for web applications and cloud IDEs. The framework makes it possible to create and edit models, launch automated tool chains on the server, including model-to-model transformations, code generation, live validation, and execution of the generated artefacts.

Generate Web Editor from Xtext

Generate a RAP editor with both client-side ANTLR Parser, and Xtext runtime features in the back-end. The Xtext/RAP Generator option produces an Eclipse plugin with the suffix “.web”. To compile the plugin, don’t forget to switch the target platform to RAP.

Generate Web Editor from ANTLR

The Generator takes as input an Xtext grammar, generates JavaScript parser and lexer, and does the wiring with an ACE Editor. As Xtext takes a subset of ANTLR while adding the integration layer for EMF, the generator ignores the extra info, and extracts the ANTLR grammar to generate the “.g” file.

Customize the Web editor

The generated code contains Java classes and JavaScript sripts; both artefacts can be customized according the developer's needs. Below some hints on how to customize the generated editors, for more advanced customizations, feel free contact the support.