Xtext eclipse introduction - Java @ Desk

Sunday, June 30, 2013

Xtext eclipse introduction

What is Xtext?

Xtext is a open source framework for development of programming languages and domain specific languages.

It covers all aspects of a complete language infrastructure, from parsers, over linker, compiler or interpreter to fully-blown top-notch Eclipse IDE integration. It comes with good defaults for all these aspects and at the same time every single aspect can be tailored to your needs.

It provides you an infrastructure to develop a parser that will support some domain specific language and allows to create a generator to transform that language into any language of your type.

The most common example is to convert any language into java objects.

Consider a scenario, where a designer wants to design a Java POJO, but do not have a Java language understanding to how to create a java pojo/classes. Now in order to learn java, the designer may require lots of learning and it will cost duration.

Xtext comes into picture here. Xtext allows you to define a parser that will be provided to the designer and he/she will create a pojo in a parser language as shown below:

Class Pojo {
    firstName : Characters
    lastName : Characters
    age : Digits
    salary : Digits

}

Xtext will allow to create the parser to define classes in above format. Plus, the generator implementation that takes this file as input and the output of the generator will be the Java Pojo class.

As shown above, Xtext allows you to create the domain specific language that can be understood by layman, not nexessarily a technical resource is needed to understand the infrastructure.

Where it can be used?

The most easy implementation would be creating of IDE's like Eclipse, NetBeans, etc. What we do we create classes and we simply use CTRL + SPACE to retrieve the fields/methods of that class.






No comments:

Post a Comment