Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Using xtext for comprehensive languages
Using xtext for comprehensive languages [message #44764] Fri, 22 May 2009 10:34 Go to next message
Eclipse UserFriend
Hi,

Is xtext project aimed at small DSL's or is it also suitable for
comprehensive languages? (EMFText seems to have big languages such as java
in its language zoo.)

Particularly, I'm interested to know about the use of xtext in JVM-based
languages such as groovy, scala, jython, jruby, etc. Does the fact that
these languages can directly call the java API make anything any easier?
Would xtext be able to provide joint java compilation for these languages?
Re: Using xtext for comprehensive languages [message #44790 is a reply to message #44764] Fri, 22 May 2009 11:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi Auerliano!

Xtext's primary target is to build external textual DSLs. It is not
intended to create full-fledged general purpose programming languages. I
think you would face many limitations when trying to build "big"
languages. It is simply not the right tooling for that. You would need
parser generators with more possibilities, like Antlr. Xtext uses them
itself and abstract certain things, gaining simplicity and abstraction,
but loosing some features.
Xtext is a perfect choice for creating good external DSLs with high
efficiency. This is normally the way I use it in real projects and which
works well.

~Karsten

On 22.05.09 16:34, Auerliano wrote:
> Hi,
>
> Is xtext project aimed at small DSL's or is it also suitable for
> comprehensive languages? (EMFText seems to have big languages such as
> java in its language zoo.)
>
> Particularly, I'm interested to know about the use of xtext in JVM-based
> languages such as groovy, scala, jython, jruby, etc. Does the fact that
> these languages can directly call the java API make anything any easier?
> Would xtext be able to provide joint java compilation for these languages?
>
Re: Using xtext for comprehensive languages [message #44822 is a reply to message #44790] Fri, 22 May 2009 12:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi Karsten,

Thanks for the information. One question remains here: how come EMFText
does support general languages? I had the impression that EMFText and
xtext are very similar.

Karsten Thoms wrote:

> Hi Auerliano!

> Xtext's primary target is to build external textual DSLs. It is not
> intended to create full-fledged general purpose programming languages. I
> think you would face many limitations when trying to build "big"
> languages. It is simply not the right tooling for that. You would need
> parser generators with more possibilities, like Antlr. Xtext uses them
> itself and abstract certain things, gaining simplicity and abstraction,
> but loosing some features.
> Xtext is a perfect choice for creating good external DSLs with high
> efficiency. This is normally the way I use it in real projects and which
> works well.

> ~Karsten

> On 22.05.09 16:34, Auerliano wrote:
>> Hi,
>>
>> Is xtext project aimed at small DSL's or is it also suitable for
>> comprehensive languages? (EMFText seems to have big languages such as
>> java in its language zoo.)
>>
>> Particularly, I'm interested to know about the use of xtext in JVM-based
>> languages such as groovy, scala, jython, jruby, etc. Does the fact that
>> these languages can directly call the java API make anything any easier?
>> Would xtext be able to provide joint java compilation for these languages?
>>
Re: Using xtext for comprehensive languages [message #44917 is a reply to message #44764] Fri, 22 May 2009 14:13 Go to previous messageGo to next message
Eclipse UserFriend
Hi Auerlino,

with TMF Xtext it is possible and reasonable to build more complex
languages. Karsten was referring to oAW Xtext which had some limitations
regarding expression based grammars (left factored grammars created
verbose trees). This is solved in TMF Xtext. Also scalability problems
we had in oAW Xtext are solved.

TMF Xtext is absolutely capable of hosting big general-purpose
languages. One thing we don't have yet (but we will add as soon as
someone needs them after Galileo) is predicates. In Anltr you can define
semantic and syntactic predicates. There are some languages, where you
might need these features. Anyway, we didn't need them so far, so we
haven't yet added them. If you need them come up with a bugzilla and
we'll take care if it.

To proove that Xtext supports more complicated languages, we'll
implement one in the next release and ship it as a library. So people
can extend / modify the language and add their own domain-specific
concepts but can reuse the expressions and the typesystem and of course
can call to Java, because we want to ship that language with a mapping
to Java.

So the reason why other frameworks have a language zoo and have
general-purpose languages therin and Xtext has not, is just because we
so far put all our resources into the framework's code.

Cheers,
Sven

Auerliano schrieb:
> Hi,
>
> Is xtext project aimed at small DSL's or is it also suitable for
> comprehensive languages? (EMFText seems to have big languages such as
> java in its language zoo.)
>
> Particularly, I'm interested to know about the use of xtext in JVM-based
> languages such as groovy, scala, jython, jruby, etc. Does the fact that
> these languages can directly call the java API make anything any easier?
> Would xtext be able to provide joint java compilation for these languages?
>
Re: Using xtext for comprehensive languages [message #44941 is a reply to message #44917] Fri, 22 May 2009 14:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sven,

That's really good news! One question is, having a compiler like jython or
scala, (or even java), how is it possible to avoid a parser like antlr and
use the compiler directly in xtext?



Sven Efftinge wrote:

> Hi Auerlino,

> with TMF Xtext it is possible and reasonable to build more complex
> languages. Karsten was referring to oAW Xtext which had some limitations
> regarding expression based grammars (left factored grammars created
> verbose trees). This is solved in TMF Xtext. Also scalability problems
> we had in oAW Xtext are solved.

> TMF Xtext is absolutely capable of hosting big general-purpose
> languages. One thing we don't have yet (but we will add as soon as
> someone needs them after Galileo) is predicates. In Anltr you can define
> semantic and syntactic predicates. There are some languages, where you
> might need these features. Anyway, we didn't need them so far, so we
> haven't yet added them. If you need them come up with a bugzilla and
> we'll take care if it.

> To proove that Xtext supports more complicated languages, we'll
> implement one in the next release and ship it as a library. So people
> can extend / modify the language and add their own domain-specific
> concepts but can reuse the expressions and the typesystem and of course
> can call to Java, because we want to ship that language with a mapping
> to Java.

> So the reason why other frameworks have a language zoo and have
> general-purpose languages therin and Xtext has not, is just because we
> so far put all our resources into the framework's code.

> Cheers,
> Sven

> Auerliano schrieb:
>> Hi,
>>
>> Is xtext project aimed at small DSL's or is it also suitable for
>> comprehensive languages? (EMFText seems to have big languages such as
>> java in its language zoo.)
>>
>> Particularly, I'm interested to know about the use of xtext in JVM-based
>> languages such as groovy, scala, jython, jruby, etc. Does the fact that
>> these languages can directly call the java API make anything any easier?
>> Would xtext be able to provide joint java compilation for these languages?
>>
Re: Using xtext for comprehensive languages [message #45101 is a reply to message #44917] Fri, 22 May 2009 14:27 Go to previous messageGo to next message
Eclipse UserFriend
Sven Efftinge wrote:

> Hi Auerlino,

> with TMF Xtext it is possible and reasonable to build more complex
> languages. Karsten was referring to oAW Xtext which had some limitations
> regarding expression based grammars (left factored grammars created
> verbose trees). This is solved in TMF Xtext. Also scalability problems
> we had in oAW Xtext are solved.

> TMF Xtext is absolutely capable of hosting big general-purpose
> languages. One thing we don't have yet (but we will add as soon as
> someone needs them after Galileo) is predicates. In Anltr you can define
> semantic and syntactic predicates. There are some languages, where you
> might need these features. Anyway, we didn't need them so far, so we
> haven't yet added them. If you need them come up with a bugzilla and
> we'll take care if it.

> To proove that Xtext supports more complicated languages, we'll
> implement one in the next release and ship it as a library.

By 'next release' you mean in June 2010?

> So people
> can extend / modify the language and add their own domain-specific
> concepts but can reuse the expressions and the typesystem and of course
> can call to Java, because we want to ship that language with a mapping
> to Java.

> So the reason why other frameworks have a language zoo and have
> general-purpose languages therin and Xtext has not, is just because we
> so far put all our resources into the framework's code.

> Cheers,
> Sven

> Auerliano schrieb:
>> Hi,
>>
>> Is xtext project aimed at small DSL's or is it also suitable for
>> comprehensive languages? (EMFText seems to have big languages such as
>> java in its language zoo.)
>>
>> Particularly, I'm interested to know about the use of xtext in JVM-based
>> languages such as groovy, scala, jython, jruby, etc. Does the fact that
>> these languages can directly call the java API make anything any easier?
>> Would xtext be able to provide joint java compilation for these languages?
>>
Re: Using xtext for comprehensive languages [message #45126 is a reply to message #44941] Fri, 22 May 2009 15:50 Go to previous messageGo to next message
Eclipse UserFriend
I'm not sure what you mean.
This things you've listed are all languages which have their own parser
and compiler. You could reimplement those languages with Xtext or you
could transform information written in your Xtext-based language into
something the respective compiler "understands", i.e. source code or
maybe an abstract syntax tree.
So this would be basically a code generator which generates Jython,
Scala or even Java.

Did that answer your question?

Cheers,
Sven

Auerliano schrieb:
> Hi Sven,
>
> That's really good news! One question is, having a compiler like jython
> or scala, (or even java), how is it possible to avoid a parser like
> antlr and use the compiler directly in xtext?
>
>
>
> Sven Efftinge wrote:
>
>> Hi Auerlino,
>
>> with TMF Xtext it is possible and reasonable to build more complex
>> languages. Karsten was referring to oAW Xtext which had some
>> limitations regarding expression based grammars (left factored
>> grammars created verbose trees). This is solved in TMF Xtext. Also
>> scalability problems we had in oAW Xtext are solved.
>
>> TMF Xtext is absolutely capable of hosting big general-purpose
>> languages. One thing we don't have yet (but we will add as soon as
>> someone needs them after Galileo) is predicates. In Anltr you can
>> define semantic and syntactic predicates. There are some languages,
>> where you might need these features. Anyway, we didn't need them so
>> far, so we haven't yet added them. If you need them come up with a
>> bugzilla and we'll take care if it.
>
>> To proove that Xtext supports more complicated languages, we'll
>> implement one in the next release and ship it as a library. So people
>> can extend / modify the language and add their own domain-specific
>> concepts but can reuse the expressions and the typesystem and of
>> course can call to Java, because we want to ship that language with a
>> mapping to Java.
>
>> So the reason why other frameworks have a language zoo and have
>> general-purpose languages therin and Xtext has not, is just because we
>> so far put all our resources into the framework's code.
>
>> Cheers,
>> Sven
>
>> Auerliano schrieb:
>>> Hi,
>>>
>>> Is xtext project aimed at small DSL's or is it also suitable for
>>> comprehensive languages? (EMFText seems to have big languages such as
>>> java in its language zoo.)
>>>
>>> Particularly, I'm interested to know about the use of xtext in
>>> JVM-based languages such as groovy, scala, jython, jruby, etc. Does
>>> the fact that these languages can directly call the java API make
>>> anything any easier? Would xtext be able to provide joint java
>>> compilation for these languages?
>>>
>
>
Re: Using xtext for comprehensive languages [message #45157 is a reply to message #45101] Fri, 22 May 2009 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Auerliano schrieb:
> Sven Efftinge wrote:
>
>> Hi Auerlino,
>
>> with TMF Xtext it is possible and reasonable to build more complex
>> languages. Karsten was referring to oAW Xtext which had some
>> limitations regarding expression based grammars (left factored
>> grammars created verbose trees). This is solved in TMF Xtext. Also
>> scalability problems we had in oAW Xtext are solved.
>
>> TMF Xtext is absolutely capable of hosting big general-purpose
>> languages. One thing we don't have yet (but we will add as soon as
>> someone needs them after Galileo) is predicates. In Anltr you can
>> define semantic and syntactic predicates. There are some languages,
>> where you might need these features. Anyway, we didn't need them so
>> far, so we haven't yet added them. If you need them come up with a
>> bugzilla and we'll take care if it.
>
>> To proove that Xtext supports more complicated languages, we'll
>> implement one in the next release and ship it as a library.
>
> By 'next release' you mean in June 2010?
>

Yes, that's the next release.
But useable things will of course be available earlier through milestones.

Sven
Re: Using xtext for comprehensive languages [message #58583 is a reply to message #44917] Tue, 14 July 2009 13:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Sven Efftinge wrote:
> Hi Auerlino,
>
> with TMF Xtext it is possible and reasonable to build more complex
> languages. Karsten was referring to oAW Xtext which had some limitations
> regarding expression based grammars (left factored grammars created
> verbose trees). This is solved in TMF Xtext. Also scalability problems
> we had in oAW Xtext are solved.

Left factored grammars are still an issue, when trying to implement the
following grammar:

http://www.oasis-open.org/committees/relax-ng/compact-200211 21.html#syntax

In particular the Pattern rule gives errors when you try to implement it
with left factoring as specified by this EBNF grammar:

pattern ::= "element" nameClass "{" pattern "}"
| "attribute" nameClass "{" pattern "}"
| pattern ("," pattern)+
| pattern ("&" pattern)+
| pattern ("|" pattern)+
| pattern "?"
| pattern "*"
| pattern "+"
| "list" "{" pattern "}"
| "mixed" "{" pattern "}"
| identifier
| "parent" identifier
| "empty"
| "text"
| [datatypeName] datatypeValue
| datatypeName ["{" param* "}"] [exceptPattern]
| "notAllowed"
| "external" anyURILiteral [inherit]
| "grammar" "{" grammarContent* "}"
| "(" pattern ")"

XText will complain about the let factoring in this Rule when converted
into XText grammar. Only way I was able to get this to work was to
rewrite the rule in xtext:

Pattern:
(val=(Element | Attribute))+ |
'list' '{' pattern+=Pattern* '}' |
'mixed' '{' pattern+=Pattern* '}' |
ID ('=')?|
'parent' ID |
'empty' |
'text' |
'|' |
(value=DataTypeValue)+ |
DataTypeName ('{' param+=Param* '}')* (exceptPattern=ExceptPattern)* |
'notAllowed' |
'external'uri=AnyURILiteral (inherit=Inherit)* |
'grammar' '{' grammarContent+=GrammarContent* '}' |
'(' group+=Pattern* ')' (continue=',')?
;

Element:
'element' elemName=NameClass '{' pattern+=Pattern* '}'
(cardinality=('?' | '+' | '*'))? (continue=(',' | '&' | '|'))?;

Attribute:
'attribute' attrName=NameClass '{' pattern+=Pattern* '}'
(cardinality='?')? (continue=(',' | '|'))?;

Which is a messy alternative to the EBNF grammar. I'd be interested in
knowning how to correctly write this in XText with left factoring.
Re: Using xtext for comprehensive languages [message #59447 is a reply to message #58583] Thu, 16 July 2009 04:31 Go to previous message
Eclipse UserFriend
Hi Dave,

Xtext is based on LL parser generators (such as Antlr) which by
definition do not allow left recursion.
This is not a bug.

Your grammar has a lot of left recursion in it which needs to be left
factored.

That is in principle done like in the following (I don't know the
conceptual names of the different patterns so I'll just add a number):

Pattern1 returns Pattern :
Pattern2 ({Pattern.left=current} ',' right=Pattern2)*;

Pattern2 returns Pattern :
Pattern3 ({Pattern.left=current} '&' right=Pattern3)*;

Pattern3 returns Pattern :
Pattern4 ({Pattern.left=current} '|' right=Pattern4)*;

....

Pattern :
// ... all the not left recursive stuff goes here separated by '|'
'(' Pattern1 ')';


This at the same time defines operator precedence (In this example '|'
has higher precedence than '&', which is probably not right :-))
See also "tree rewrite actions" in the documentation.

Hope that helps,
Sven

David Carver schrieb:
> Sven Efftinge wrote:
>> Hi Auerlino,
>>
>> with TMF Xtext it is possible and reasonable to build more complex
>> languages. Karsten was referring to oAW Xtext which had some
>> limitations regarding expression based grammars (left factored
>> grammars created verbose trees). This is solved in TMF Xtext. Also
>> scalability problems we had in oAW Xtext are solved.
>
> Left factored grammars are still an issue, when trying to implement the
> following grammar:
>
> http://www.oasis-open.org/committees/relax-ng/compact-200211 21.html#syntax
>
> In particular the Pattern rule gives errors when you try to implement it
> with left factoring as specified by this EBNF grammar:
>
> pattern ::= "element" nameClass "{" pattern "}"
> | "attribute" nameClass "{" pattern "}"
> | pattern ("," pattern)+
> | pattern ("&" pattern)+
> | pattern ("|" pattern)+
> | pattern "?"
> | pattern "*"
> | pattern "+"
> | "list" "{" pattern "}"
> | "mixed" "{" pattern "}"
> | identifier
> | "parent" identifier
> | "empty"
> | "text"
> | [datatypeName] datatypeValue
> | datatypeName ["{" param* "}"] [exceptPattern]
> | "notAllowed"
> | "external" anyURILiteral [inherit]
> | "grammar" "{" grammarContent* "}"
> | "(" pattern ")"
>
> XText will complain about the let factoring in this Rule when converted
> into XText grammar. Only way I was able to get this to work was to
> rewrite the rule in xtext:
>
> Pattern:
> (val=(Element | Attribute))+ |
> 'list' '{' pattern+=Pattern* '}' |
> 'mixed' '{' pattern+=Pattern* '}' |
> ID ('=')?|
> 'parent' ID |
> 'empty' |
> 'text' |
> '|' |
> (value=DataTypeValue)+ |
> DataTypeName ('{' param+=Param* '}')* (exceptPattern=ExceptPattern)* |
> 'notAllowed' |
> 'external'uri=AnyURILiteral (inherit=Inherit)* |
> 'grammar' '{' grammarContent+=GrammarContent* '}' |
> '(' group+=Pattern* ')' (continue=',')?
> ;
>
> Element:
> 'element' elemName=NameClass '{' pattern+=Pattern* '}'
> (cardinality=('?' | '+' | '*'))? (continue=(',' | '&' | '|'))?;
>
> Attribute:
> 'attribute' attrName=NameClass '{' pattern+=Pattern* '}'
> (cardinality='?')? (continue=(',' | '|'))?;
>
> Which is a messy alternative to the EBNF grammar. I'd be interested in
> knowning how to correctly write this in XText with left factoring.
Previous Topic:Conversion from oaw to tmf xtext - Access values of Datatype refs
Next Topic:Crossreference & lazy loading pb ?
Goto Forum:
  


Current Time: Wed Jul 16 17:40:12 EDT 2025

Powered by FUDForum. Page generated in 0.10849 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top