Posts Tagged ‘ Code Generator ’

Designing Scalable Code Generators for very large Java Projects

Model-driven development is increasingly applied in large industrial projects. When java is used as the target language, some language details have to be considered that do not make any difference in conventional implementation. It is also necessary to take them into account when deciding between code generation and runtime interpretation. In order to make the generators scalable it is important to keep their execution times low. Furthermore, they need to be designed in such a way that changes to the source models result in localized and traceable effects in the generated code. This can be achieved by respecting some basic design rules during development of the code generators.

Continue reading

Generate Proxies for the WPF frontend

In the previous post we learned how a WPF user interface can be driven from a java application. The solution that was presented allows showing views, modifying controls’ properties, and starting or stopping animations. It is based on a set of generic functions that provide for the required functionality. Each one of these takes additional parameters to adress a specific view, control, animation, and property.

Assuming there is a control named mute in the view main. To set its boolean property checked to true, we need to call wpfFrontend.setWidgetPropertyBool("main", "mute", "checked", true). This call will fail, when the view, the control, or the property is not found for the given names, which can likely happen because of mispelling or after refactoring the user interface. Such errors cannot be detected by the Java compiler and will lead to runtime errors that are hard to detect. One can use proxies that encapsulate all the adressing in order to avoid these problems and offer a more convenient way to access the elements of the WPF frontend. Using proxies the modification of the control’s property can be done by a call to a setter, e.g. wpfFrontend.main.mute.setChecked(true).

This post shows how such Java proxies can be generated from a high-level description of the frontend elements.
Continue reading

Xtext based Lua-Editor

Lua is an imperative programming language. It was designed to be embedded as programming language within other programs. Lua uses automatic memory management with garbage collection. It is dynamically typed and provides coroutines. The Lua interpreter has a low memory footprint and is even suitable for embedded systems.

Lua uses a very simple grammar with specialized list operations. The complete symtax can be found here.

In this post we use Xtext to develop an IDE for this real-world programming language.
Continue reading

Generate EBNF-Descriptions for Xtext-based DSL

Creating DSLs in Xtext is easy and works out of the box. However, when it comes to documentation,  things get tricky. Your DSL should be used by other programmers to model a system that maybe didn’t take part in defining the language. So how can you describe the usage of your language to these guys?

Of course there is the possibility to provide code-snippets as examples and the tool support Xtext generated for your languages eases its use. However, sometimes a more complete documentation is useful. Using the original .xtext file for that purpose is not the best way, because its crowded with internal information for the parser that the user of the DSLs doesn’t care about. Furthermore, only few people are used to the Xtext-Language. The good old way is to provide a BNF or EBNF description of the language.

In this posts I will describe how to automatically generate EBNF descriptions for your DSL.
Continue reading