Books on Xtext [message #903514] |
Fri, 24 August 2012 04:59 |
|
Its been hard to find a single source of information. I tried amazon, no luck anyone know of any concrete books that give a good overview of how to use xtext to create DSL's? - Duncan
[Updated on: Fri, 24 August 2012 05:00] Report message to a moderator
|
|
|
|
Re: Books on Xtext [message #903636 is a reply to message #903633] |
Fri, 24 August 2012 15:40 |
Peter Radisch Messages: 1 Registered: August 2012 |
Junior Member |
|
|
Hi Duncan,
sorry there are no books covering xtext. Only the documentation posted by Frank...
Unfortunately this documentation will not help you to learn xtext, at least it didn't help me because ist is rather incomplete and the explanations are not suitable for a beginner.
I can only give you the hint to search the web for blogposts wher someone explains the xtext concepts on a more user-centered level...
These two blogs helped me alot:
dslmeinte.wordpress.com
christiandietrich.wordpress.com
If such posts are not enough you only have the possibility to ask on the forum or hope for a miraculous increase of the xtext docs ^^
Regards
Peter
[Updated on: Fri, 24 August 2012 15:42] Report message to a moderator
|
|
|
|
Re: Books on Xtext [message #903669 is a reply to message #903640] |
Fri, 24 August 2012 20:03 |
|
Hey guys, thanks for the replies. EMF is a technology I know well, its just figuring out how to put together a grammer with simple if/then logic and then building a runtime component to execute it. Am I correct that if something like if (x = y) then add 1 to y would be modeled as emf objects like having an "And" model object as well as a "Then" model object in my generated ecore or is it a lot easier than that? Also things like creating functions and pretty much building my own scripting language is what I'm wanting to learn more about. Do you think the books mentioned cover this kind of material? - Duncan
|
|
|
|
Re: Books on Xtext [message #903692 is a reply to message #903669] |
Fri, 24 August 2012 23:16 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
On 2012-24-08 22:03, Duncan Krebs wrote:
> Hey guys, thanks for the replies. EMF is a technology I know well, its
> just figuring out how to put together a grammer with simple if/then
> logic and then building a runtime component to execute it. Am I correct
> that if something like if (x = y) then add 1 to y would be modeled as
> emf objects like having an "And" model object as well as a "Then" model
> object in my generated ecore or is it a lot easier than that? Also
> things like creating functions and pretty much building my own scripting
> language is what I'm wanting to learn more about. Do you think the books
> mentioned cover this kind of material? - Duncan
The easiest way to get started is to start with a small example. Since
you want to build a scripting language, you probably need expressions.
So start with an expression example - a calculator or something.
Then look at implementations of some more complex languages. Xbase,
Xtend etc. If you want to do something like C, C++, Ruby, or JavaScript
you have a rougher ride ahead as there are some difficult problems to
overcome inherit in parsing those languages. I take that back, some of
them is not so much a ride as a free fall, or in the case of Java
Script, a riot at the asylum ;-)
Then ask for pointers and guidance along the way. The books, although
they are good as introduction very quickly gets complicated, and are
perhaps more useful when you want to learn about something specific.
If you have not done any language design, parsers, etc. read some
introductory chapters to get a feel for the issues.
OTOH, if you need a competent scripting language, there is always Xtend :)
And, you are naturally correct that expressions are modeled using EMF.
An expression such as '1 + 2' (typically) becomes an Add instance with a
left containment reference to an instance of LiteralInt with an int
feature value = 1, and a right containment reference to an instance of
LiteralInt with value = 2.
You can also do this as a BinaryOp instance and have a String op = '+'
feature. It is common to divide them by precedence, So you may have an
abstract BinaryOp, with AdditiveOp, MultiplicativeOp being derived from
BinaryOp. Or indeed be explicit and have a class per binary and unary
operator.
Your choices have effect on flexibility of the model, what is reflected
in the grammar/model itself, and what you need to handle in validation
of the model.
Good advice is to make the grammar as lenient as possible to avoid harsh
"syntax error" and unrecognized parts in what is parsed. The more that
the parser can understand and construct a model for, the more help can
be provided in the editor. So don't go overboard with specifying every
itty bitty detail in the grammar itself. In fact, build it to withstand
typical anticipated user errors. Again a balancing act, as the more
flexible you allow the grammar to be, the less help do you get with the
generated tooling/out-of-the-box features.
oh - welcome to the club - working with Xtext (and languages) is fun
stuff :)
Regards
- henrik
|
|
|
Re: Books on Xtext [message #903905 is a reply to message #903514] |
Mon, 27 August 2012 08:20 |
Tobias Mayer Messages: 8 Registered: August 2012 |
Junior Member |
|
|
Hi Duncan,
I think that the following blog post of Simon Gerlach is very helpfull, too:
xtexterience.wordpress.com/2011/05/17/xtext-based-lua-editor
(Sorry for the incomplete link. The forum doesn't allow to set a link outsite of eclipse.org as long as I have less than 25 messages. Just add a http:// in front of the link.)
He implements the LUA language in the grammar language of xtext.
Best Regards,
Tobias
[Updated on: Mon, 27 August 2012 08:21] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03741 seconds