Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Named open and closing tags in xtext grammar?
Named open and closing tags in xtext grammar? [message #765790] Wed, 14 December 2011 12:30 Go to next message
Eclipse UserFriend
Hi!

I'm trying to implement an xtext grammar for my dsl atm and am pretty thrilled about the good results so far!

There is one point though thats troubling me:

considering I have a DSL with something like this:

Person Jimbo                          <- opening tag with name of person
   fullName = JamesJeronimoSmith
   Address = Somewhere
end Jimbo                             <- closing tag with name of person


then i would instinctively use a grammar like
(not tested)
Person:
   'Person' name=ID
    ('fullName = ' fullName=ID )?
    ('Address = ' address=ID )?
   'end' ID      // <- PROBLEM HERE?
;


the thing is, does this imply that the name at the start and end tag are the same? in my opinion it does not, it just states that there will be another ID that is not saved? So how can i make xtext check if the ID behind 'end' is the same as the ID behind 'Person' ?

I have of course tried to google, but could not find anything, which might be because i don't really know a name for this problem. an xtext grammar for XML would also have to address this problem and might be helpful, but I couldn't find one either.

Can anyone help me?

Regards
Re: Named open and closing tags in xtext grammar? [message #765800 is a reply to message #765790] Wed, 14 December 2011 12:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

try

Person:
..
'end' end=[Person]
;

and customize scoping to make sure that only 'this' Person is available.

Btw: Why do you want to enforce this redundancy?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 14.12.11 18:30, schrieb eclipse:
> Hi!
>
> I'm trying to implement an xtext grammar for my dsl atm and am pretty
> thrilled about the good results so far!
> There is one point though thats troubling me:
>
> considering I have a DSL with something like this:
>
>
> Person Jimbo <- opening tag with name of person
> fullName = JamesJeronimoSmith
> Address = Somewhere
> end Jimbo <- closing tag with name of person
>
>
> then i would instinctively use a grammar like
> (not tested)
>
> Person:
> 'Person' name=ID
> ('fullName = ' fullName=ID )?
> ('Address = ' address=ID )?
> 'end' ID // <- PROBLEM HERE?
> ;
>
>
> the thing is, does this imply that the name at the start and end tag are
> the same? in my opinion it does not, it just states that there will be
> another ID that is not saved? So how can i make xtext check if the ID
> behind 'end' is the same as the ID behind 'Person' ?
>
> I have of course tried to google, but could not find anything, which
> might be because i don't really know a name for this problem. an xtext
> grammar for XML would also have to address this problem and might be
> helpful, but I couldn't find one either.
> Can anyone help me?
>
> Regards
>
Re: Named open and closing tags in xtext grammar? [message #765860 is a reply to message #765800] Wed, 14 December 2011 14:45 Go to previous message
Eclipse UserFriend
Thanks for your reply Sebastian.

Well, the obvious answer is that I need this redundancy because the reference of my DSL says so and thus it must be implemented Wink

Another problem was that when I modified the ecore model instance of the .mydsl file and tried saving it, the serializer didn't know what to do with this undefined ID. Your solution fixed that and now it serializes.

This stuff is really awesome so far.

PS: Just for anyone else running into this issue in the future, the error message was :

Could not determine the value for the unassigned rulecall of rule ID from within rule ... 
You might want to implement org.eclipse.xtext.parsetree.reconstr.ITokenSerializer$IValueSerializer.serializeUnassignedValue() or modify your implementation to handle this rulecall.


Previous Topic:Embed XText Editor on BPMN Model Editor label connections
Next Topic:Cross reference // Functions // ContentAssist
Goto Forum:
  


Current Time: Sun Jul 06 08:07:41 EDT 2025

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

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

Back to the top