Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » [TCS] More than one syntax construction per class AND optional keywords
[TCS] More than one syntax construction per class AND optional keywords [message #380835] Tue, 08 January 2008 10:09 Go to next message
Gustavo Cabral is currently offline Gustavo Cabral
Messages: 20
Registered: July 2009
Junior Member
Hi everyone,

Is it possible to define more than one syntax definition per class
of the DSL metamodel. For example, something like this:

-- KM3
class NounNamePlural {
attribute name : String;
attribute plural : String;
}

-- TCS (Solution 2)
template NounNamePlural addToContext
: name "is a noun and its plural form is" plural "."
;

template NounNamePlural addToContext
: name "is a noun; its plural form is" plural "."
;

-- TCS (Solution 2)
template NounNamePlural addToContext
: name "is a noun and its plural form is" plural "."
| name "is a noun; its plural form is" plural "."
;

I know the code\syntax above doesn't work! Is there any alternative syntax
I can use? In ANTLR, I would use the | constructor. What would it be in
TCS?

The second question is: is it possible to have optional constructor? In
ANTLT it would be ( "optional terminal or nonterminal" )?. In TCS? I would
like to have:

template NounNamePlural addToContext
: name "is a noun and its plural" ("form")? is" plural "."
;

for instance.

Best regards and thank you,
Gustavo Cabral
Re: [TCS] More than one syntax construction per class AND optional keywords [message #380836 is a reply to message #380835] Tue, 08 January 2008 10:38 Go to previous messageGo to next message
Gustavo Cabral is currently offline Gustavo Cabral
Messages: 20
Registered: July 2009
Junior Member
Hi,

Sorry for my premature questioning. I downloaded the TCS dsl project
(CVS) and found out how to define syntax alternatives using the
[[ alt1 | alt2 .... | altN ]] constructor, like in:

template NounNamePlural addToContext
: [[ name "is a noun and its plural form is " plural "."
| name "is a noun; its plural form is" plural "."
]]
;

I still don't know how to define optional elements in my
syntax definition. :( Anyone?

regards,
Gustavo
Re: [TCS] More than one syntax construction per class AND optional keywords [message #380838 is a reply to message #380836] Tue, 08 January 2008 11:33 Go to previous message
Eclipse User
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------030105070206010408000408
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Gustavo,

As far as I know, the square brakets are only for model to text
production. The alternatives should work without them.

For optional elements, the question mark is used.
For example:

--KM3
class NounNamePlural {
attribute name : String;
attribute plural[O..1] : String;
}

--TCS
template NounNamePlural addToContext :
(
isDefined(plural)?
name "is a noun and its plural form is " plural "." :
name "is a noun and its plural form is " name "s."
)
;

Quentin GLINEUR

Gustavo Cabral a
Re: [TCS] More than one syntax construction per class AND optional keywords [message #611153 is a reply to message #380835] Tue, 08 January 2008 10:38 Go to previous message
Gustavo Cabral is currently offline Gustavo Cabral
Messages: 20
Registered: July 2009
Junior Member
Hi,

Sorry for my premature questioning. I downloaded the TCS dsl project
(CVS) and found out how to define syntax alternatives using the
[[ alt1 | alt2 .... | altN ]] constructor, like in:

template NounNamePlural addToContext
: [[ name "is a noun and its plural form is " plural "."
| name "is a noun; its plural form is" plural "."
]]
;

I still don't know how to define optional elements in my
syntax definition. :( Anyone?

regards,
Gustavo
Re: [TCS] More than one syntax construction per class AND optional keywords [message #611155 is a reply to message #380836] Tue, 08 January 2008 11:33 Go to previous message
Eclipse User
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------030105070206010408000408
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Gustavo,

As far as I know, the square brakets are only for model to text
production. The alternatives should work without them.

For optional elements, the question mark is used.
For example:

--KM3
class NounNamePlural {
attribute name : String;
attribute plural[O..1] : String;
}

--TCS
template NounNamePlural addToContext :
(
isDefined(plural)?
name "is a noun and its plural form is " plural "." :
name "is a noun and its plural form is " name "s."
)
;

Quentin GLINEUR

Gustavo Cabral a
Previous Topic:[TCS] More than one syntax construction per class AND optional keywords
Next Topic:[TCS] UML 2.1.1 TCS
Goto Forum:
  


Current Time: Sun Oct 26 03:43:03 GMT 2014

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

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