Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Disambiguate class reference
[Acceleo] Disambiguate class reference [message #1806427] Wed, 08 May 2019 18:00 Go to next message
Eclipse UserFriend
Hello,

I am currently writing an Acceleo (3.5.2) template where one of my input metamodel has a class named "Collection".

In the following template, the Acceleo compiler tags underlined text with the error ""Collection" unexpected token(s)"

[template public generateElement(aCollection : CollectionEntity) {
target : Collection = aCollection.referencedElement.oclAsType(Collection);
}]

I think this error is weird since my syntax is valid. Replacing "Collection" with any other classes from my input metamodels does remove the error.
So, I think there is somekind of name conflict here, perhaps with OCL own "Collection" ?

Do you know a way to solve of workaround this issue ?
I cannot change the input metamodel.

Kind regards,

Michaël




Re: [Acceleo] Disambiguate class reference [message #1806432 is a reply to message #1806427] Thu, 09 May 2019 00:34 Go to previous messageGo to next message
Eclipse UserFriend
Did you try prefixing"Collection" with the metamodel name?

I don't know Acceleo's syntax but should be something like "metamodel_name.Collection" (where "." may also be "::" or "!*).
Re: [Acceleo] Disambiguate class reference [message #1806437 is a reply to message #1806432] Thu, 09 May 2019 02:52 Go to previous message
Eclipse UserFriend
Hi

While "Collection" is not a reserved word in OCL, it is built-in to the grammar; it is therefore referred to as a restricted name. These can be used with care. Package qualification as suggested earlier should work. If the context is clear the old ("_Collection") or new ("_'Collection'") style of escaping may also work. If you are unlucky you may need both: PackageName::_'Collection'.

Regards

ED Willink

[Updated on: Thu, 09 May 2019 07:09] by Moderator

Previous Topic:a difficult query to solve
Next Topic:M2T Ecore2XML / Ecore2JSON Tutorial/Guide/Help
Goto Forum:
  


Current Time: Sat Jun 14 17:36:33 EDT 2025

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

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

Back to the top