Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext dsl file extensions(Splitting grammar across multiple files)
Xtext dsl file extensions [message #708178] Tue, 02 August 2011 14:38 Go to next message
sungam  is currently offline sungam Friend
Messages: 21
Registered: March 2010
Junior Member
I have a DSL as:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
"my invitations:" name=ID ("extends" extensions+=ID (',' extensions+=ID)*)? "{"
invitations=Invitations
"}"
;

Invitations:
greetings+=Greeting+;

Greeting:
'Hello' name=ID '!';

--------------------------------------

My intention is to able to support grammar files like:

invite1.mydsl:
my invitations:invite1{
Hello William!
}


invite2.mydsl:
my invitations:invite2 extends invite1{
Hello Columbus!
}

The above two file should result as:
my invitations:invite2 {
Hello William!
Hello Columbus!
}

Could someone suggest what should be the way to approach this.

Thanks



Re: Xtext dsl file extensions [message #708264 is a reply to message #708178] Tue, 02 August 2011 16:02 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
A couple of observations:
- do not use space in keywords. Replace
"my invitations:"
with
"my" "invitations" ":"

- Use [ ] for cross references. i.e.
(extensions += [Invite] (',' extensions += [Invite])*)?

- Your Invitation is called "Model" suggest changing that to Invite
(that is what I used in the example above).

Note that [Invite] is shorthand for [Invite|ID] and it cross references
to Invite.name by default. How the cross referencing actually finds
stuff is determined by how you decide to handle scopes in general - if
user needs to import what is to be visible, if it is visible by virtue
of being on the OSGi "classpath", by Eclipse project dependency
configuration (or some other scheme of your own).

Hope that helps.
Regards
- henrik

On 8/2/11 4:38 PM, sungam wrote:
> I have a DSL as:
> grammar org.xtext.example.mydsl.MyDsl with
> org.eclipse.xtext.common.Terminals
>
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
>
> Model:
> "my invitations:" name=ID ("extends" extensions+=ID (','
> extensions+=ID)*)? "{"
> invitations=Invitations
> "}"
> ;
>
> Invitations:
> greetings+=Greeting+;
>
> Greeting:
> 'Hello' name=ID '!';
>
> --------------------------------------
>
> My intention is to able to support grammar files like:
>
> invite1.mydsl:
> my invitations:invite1{
> Hello William!
> }
>
>
> invite2.mydsl:
> my invitations:invite2 extends invite1{
> Hello Columbus!
> }
>
> The above two file should result as:
> my invitations:invite2 {
> Hello William!
> Hello Columbus!
> }
>
> Could someone suggest what should be the way to approach this.
>
> Thanks
>
>
>
>
Previous Topic:extend xbase with a binary literal
Next Topic:Finding references from builder
Goto Forum:
  


Current Time: Thu Apr 25 06:47:33 GMT 2024

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

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

Back to the top