Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Converting someone else's grammar style
Converting someone else's grammar style [message #650760] Wed, 26 January 2011 12:38 Go to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

I am attempting to make a XText grammar out of the grammar published
here http://nrl.sourceforge.net/spec/spec-nrl-20100407.html#concr ete-syntax

I converted it to XText grammar but their grammar uses these 'hints'
that look like they define a hint to the parser about the basic type of
node being processed. Here is an example

ValidationFragmentApplication : fragmentId:FragmentName
OperatorParameterList;
CollectionIndex : OrdinalNumber ("of")? collection:ModelReference;
ModelReference : (PackageReference)?
elementOrAttribute::ModelElementName ((("." | "of" )
attribute:ModelElementName)*)*;

Note the "fragmentId:", the "collection:", the "elementOrAttribute:" and
the "attribute:"

Not quite sure how to represent these in XText xtext file. Any pointers?

Thx.

David
Re: Converting someone else's grammar style [message #650783 is a reply to message #650760] Wed, 26 January 2011 14:16 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi David,

please have a look at the documentation section on cross references.
Something like
attribute=[ModelElementName] or attribute+=[ModelElementName]* should do
the trick.

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

Am 26.01.11 13:38, schrieb David Wynter:
> Hi,
>
> I am attempting to make a XText grammar out of the grammar published
> here http://nrl.sourceforge.net/spec/spec-nrl-20100407.html#concr ete-syntax
>
> I converted it to XText grammar but their grammar uses these 'hints'
> that look like they define a hint to the parser about the basic type of
> node being processed. Here is an example
>
> ValidationFragmentApplication : fragmentId:FragmentName
> OperatorParameterList;
> CollectionIndex : OrdinalNumber ("of")? collection:ModelReference;
> ModelReference : (PackageReference)?
> elementOrAttribute::ModelElementName ((("." | "of" )
> attribute:ModelElementName)*)*;
>
> Note the "fragmentId:", the "collection:", the "elementOrAttribute:" and
> the "attribute:"
>
> Not quite sure how to represent these in XText xtext file. Any pointers?
>
> Thx.
>
> David
Re: Converting someone else's grammar style [message #650812 is a reply to message #650783] Wed, 26 January 2011 16:44 Go to previous message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
On 26/01/11 14:16, Sebastian Zarnekow wrote:
> Hi David,
>
> please have a look at the documentation section on cross references.
> Something like
> attribute=[ModelElementName] or attribute+=[ModelElementName]* should do
> the trick.
>
> Regards,
> Sebastian
That is not what I read it as. I read it that the prefix was qualifying
the term to indicate that it is of a particular type, a collection or an
attribute or an element. So figured I needed to create specific terms
that include type information. Like so.

ValidationFragmentApplication : FragmentNameId OperatorParameterList;
CollectionIndex : OrdinalNumber ("of")? ModelCollectionReference;
ModelReference : (PackageReference)?
ModelElementOrAttributeName ((("." | "of" )
ModelAttributeName)*)*;

In other words introduce specific terms for the different types of data
construct (Element, Attribute, Identifier collection and Collection).

Sound reasonable?

Thx.

David
Previous Topic:ResourceSet containing single Resource or all Resources
Next Topic:Import Antlr Lexer grammar in Xtext
Goto Forum:
  


Current Time: Tue Apr 23 06:09:25 GMT 2024

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

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

Back to the top