Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [TCS]User issues
[TCS]User issues [message #376313] Fri, 06 April 2007 17:01 Go to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

Hi,

I encounter one problem that I can't solve : Using TCS, I am trying to get
an injector able to parse a file which may contain optional tokens with a
default value. More over, these token have their values in only three
predefined ones.

So, I thought to use km3 enums in my metamodel :
How to handle enums used in KM3 in TCS ?

When the token do not appear in the text, how can I recognize it anyway as
defining the default value in the model ?

Thanks for your help,

Quentin
Re: [TCS]User issues [message #376314 is a reply to message #376313] Fri, 06 April 2007 20:19 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

You can use enumeration templates to represent enumerations.
For instance:

- in KM3:
enumeration A {
literal b;
literal c;
}

- in TCS:
enumerationTemplate A
: #b = "b",
#c = "c"
;

You can also use conditional elements.
For instance:

- in KM3 (in addition to enumeration A):
class Test {
attribute value : A;
}

- in TCS (instead of enumerationTemplate A, which is now unnecessary):
template Test
: (value = #b ? "b" : "c")
;

In this case, this will behave similarly to enumerationTemplate A.
However, you may have more complex constructs (e.g., using isDefined if
the attribute is optional, having a complex sequence depending on the
value of the enumeration attribute).


Regards,

Frédéric Jouault


Quentin Glineur wrote:
> Hi,
>
> I encounter one problem that I can't solve : Using TCS, I am trying to
> get an injector able to parse a file which may contain optional tokens
> with a default value. More over, these token have their values in only
> three predefined ones.
>
> So, I thought to use km3 enums in my metamodel :
> How to handle enums used in KM3 in TCS ?
>
> When the token do not appear in the text, how can I recognize it anyway
> as defining the default value in the model ?
>
> Thanks for your help,
>
> Quentin
>
Re: [TCS]User issues [message #376865 is a reply to message #376314] Wed, 18 April 2007 16:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

Hi, and thanks for those ones...

Now, going further in my work with TCS, I wonder what is the difference
between the "context" and "addToContext" clauses for a template. I have
read about them having a role in the references (refersTo) but I have a
problems with such references :

[am3.loadModel] Error: <unknown location>: MyToken with value = Or was
not found for following of MM!MyLitteral.

Here are the implicated source excerpt :

KM3:
abstract class MyToken {
attribute value : String;
}

class MyIdentifier extends MyToken {
reference following : MyToken;
}

class MyLitteral extends MyToken {
reference following : MyToken;
}

class MyLineEnd extends MyToken {
}

TCS:
template MyToken abstract <context/addToContext?>
;

template MyIdentifier <context/addToContext?>
: value
following{refersTo = value}
;

template MyLitteral <context/addToContext?>
: value{as=stringSymbol}
following{refersTo = value}
;

template MyLineEnd <context/addToContext?>
: value{as=endLineSymbol}
;

(The "<context/addToContext?>" patterns are where my misunderstanding
is... )

Regards,

Quentin


Frédéric Jouault a écrit :
> Hello,
>
> You can use enumeration templates to represent enumerations.
> For instance:
>
> - in KM3:
> enumeration A {
> literal b;
> literal c;
> }
>
> - in TCS:
> enumerationTemplate A
> : #b = "b",
> #c = "c"
> ;
>
> You can also use conditional elements.
> For instance:
>
> - in KM3 (in addition to enumeration A):
> class Test {
> attribute value : A;
> }
>
> - in TCS (instead of enumerationTemplate A, which is now unnecessary):
> template Test
> : (value = #b ? "b" : "c")
> ;
>
> In this case, this will behave similarly to enumerationTemplate A.
> However, you may have more complex constructs (e.g., using isDefined if
> the attribute is optional, having a complex sequence depending on the
> value of the enumeration attribute).
>
>
> Regards,
>
> Frédéric Jouault
>
>
> Quentin Glineur wrote:
>> Hi,
>>
>> I encounter one problem that I can't solve : Using TCS, I am trying to
>> get an injector able to parse a file which may contain optional tokens
>> with a default value. More over, these token have their values in only
>> three predefined ones.
>>
>> So, I thought to use km3 enums in my metamodel :
>> How to handle enums used in KM3 in TCS ?
>>
>> When the token do not appear in the text, how can I recognize it
>> anyway as defining the default value in the model ?
>>
>> Thanks for your help,
>>
>> Quentin
>>
Re: [TCS]User issues [message #376868 is a reply to message #376865] Thu, 19 April 2007 09:34 Go to previous message
Eclipse UserFriend
Originally posted by: mikael.barbero.gmail.com

Hi Quentin,

"context" is a model element that defines a context whereas addToContext
add a model element to the current context. You define a context if you
want to access an attribute (refersTo) of another element of the same
type of this context whereas you define an addToContext when you want to
look into (lookIn) a parent context of the element.

In your case, i don't think you need to addToContext your elements. Only
declare your MyToken template as a context.

Best regards,
Mikael


Quentin Glineur wrote:
> Hi, and thanks for those ones...
>
> Now, going further in my work with TCS, I wonder what is the difference
> between the "context" and "addToContext" clauses for a template. I have
> read about them having a role in the references (refersTo) but I have a
> problems with such references :
>
> [am3.loadModel] Error: <unknown location>: MyToken with value = Or was
> not found for following of MM!MyLitteral.
>
> Here are the implicated source excerpt :
>
> KM3:
> abstract class MyToken {
> attribute value : String;
> }
>
> class MyIdentifier extends MyToken {
> reference following : MyToken;
> }
>
> class MyLitteral extends MyToken {
> reference following : MyToken;
> }
>
> class MyLineEnd extends MyToken {
> }
>
> TCS:
> template MyToken abstract <context/addToContext?>
> ;
>
> template MyIdentifier <context/addToContext?>
> : value
> following{refersTo = value}
> ;
>
> template MyLitteral <context/addToContext?>
> : value{as=stringSymbol}
> following{refersTo = value}
> ;
>
> template MyLineEnd <context/addToContext?>
> : value{as=endLineSymbol}
> ;
>
> (The "<context/addToContext?>" patterns are where my misunderstanding
> is... )
>
> Regards,
>
> Quentin
>
>
> Frédéric Jouault a écrit :
>> Hello,
>>
>> You can use enumeration templates to represent enumerations.
>> For instance:
>>
>> - in KM3:
>> enumeration A {
>> literal b;
>> literal c;
>> }
>>
>> - in TCS:
>> enumerationTemplate A
>> : #b = "b",
>> #c = "c"
>> ;
>>
>> You can also use conditional elements.
>> For instance:
>>
>> - in KM3 (in addition to enumeration A):
>> class Test {
>> attribute value : A;
>> }
>>
>> - in TCS (instead of enumerationTemplate A, which is now unnecessary):
>> template Test
>> : (value = #b ? "b" : "c")
>> ;
>>
>> In this case, this will behave similarly to enumerationTemplate A.
>> However, you may have more complex constructs (e.g., using isDefined
>> if the attribute is optional, having a complex sequence depending on
>> the value of the enumeration attribute).
>>
>>
>> Regards,
>>
>> Frédéric Jouault
>>
>>
>> Quentin Glineur wrote:
>>> Hi,
>>>
>>> I encounter one problem that I can't solve : Using TCS, I am trying
>>> to get an injector able to parse a file which may contain optional
>>> tokens with a default value. More over, these token have their values
>>> in only three predefined ones.
>>>
>>> So, I thought to use km3 enums in my metamodel :
>>> How to handle enums used in KM3 in TCS ?
>>>
>>> When the token do not appear in the text, how can I recognize it
>>> anyway as defining the default value in the model ?
>>>
>>> Thanks for your help,
>>>
>>> Quentin
>>>



--
Mikaël Barbero - PhD Candidate
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssinière
44322 Nantes Cedex 3 - France
tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00
email: Mikael.Barbero@{gmail.com, univ-nantes.fr}
http://www.sciences.univ-nantes.fr/lina/atl/
Re: [TCS]User issues [message #578331 is a reply to message #376313] Fri, 06 April 2007 20:19 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

You can use enumeration templates to represent enumerations.
For instance:

- in KM3:
enumeration A {
literal b;
literal c;
}

- in TCS:
enumerationTemplate A
: #b = "b",
#c = "c"
;

You can also use conditional elements.
For instance:

- in KM3 (in addition to enumeration A):
class Test {
attribute value : A;
}

- in TCS (instead of enumerationTemplate A, which is now unnecessary):
template Test
: (value = #b ? "b" : "c")
;

In this case, this will behave similarly to enumerationTemplate A.
However, you may have more complex constructs (e.g., using isDefined if
the attribute is optional, having a complex sequence depending on the
value of the enumeration attribute).


Regards,

Frédéric Jouault


Quentin Glineur wrote:
> Hi,
>
> I encounter one problem that I can't solve : Using TCS, I am trying to
> get an injector able to parse a file which may contain optional tokens
> with a default value. More over, these token have their values in only
> three predefined ones.
>
> So, I thought to use km3 enums in my metamodel :
> How to handle enums used in KM3 in TCS ?
>
> When the token do not appear in the text, how can I recognize it anyway
> as defining the default value in the model ?
>
> Thanks for your help,
>
> Quentin
>
Re: [TCS]User issues [message #580249 is a reply to message #376314] Wed, 18 April 2007 16:48 Go to previous message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

Hi, and thanks for those ones...

Now, going further in my work with TCS, I wonder what is the difference
between the "context" and "addToContext" clauses for a template. I have
read about them having a role in the references (refersTo) but I have a
problems with such references :

[am3.loadModel] Error: <unknown location>: MyToken with value = Or was
not found for following of MM!MyLitteral.

Here are the implicated source excerpt :

KM3:
abstract class MyToken {
attribute value : String;
}

class MyIdentifier extends MyToken {
reference following : MyToken;
}

class MyLitteral extends MyToken {
reference following : MyToken;
}

class MyLineEnd extends MyToken {
}

TCS:
template MyToken abstract <context/addToContext?>
;

template MyIdentifier <context/addToContext?>
: value
following{refersTo = value}
;

template MyLitteral <context/addToContext?>
: value{as=stringSymbol}
following{refersTo = value}
;

template MyLineEnd <context/addToContext?>
: value{as=endLineSymbol}
;

(The "<context/addToContext?>" patterns are where my misunderstanding
is... )

Regards,

Quentin


Frédéric Jouault a écrit :
> Hello,
>
> You can use enumeration templates to represent enumerations.
> For instance:
>
> - in KM3:
> enumeration A {
> literal b;
> literal c;
> }
>
> - in TCS:
> enumerationTemplate A
> : #b = "b",
> #c = "c"
> ;
>
> You can also use conditional elements.
> For instance:
>
> - in KM3 (in addition to enumeration A):
> class Test {
> attribute value : A;
> }
>
> - in TCS (instead of enumerationTemplate A, which is now unnecessary):
> template Test
> : (value = #b ? "b" : "c")
> ;
>
> In this case, this will behave similarly to enumerationTemplate A.
> However, you may have more complex constructs (e.g., using isDefined if
> the attribute is optional, having a complex sequence depending on the
> value of the enumeration attribute).
>
>
> Regards,
>
> Frédéric Jouault
>
>
> Quentin Glineur wrote:
>> Hi,
>>
>> I encounter one problem that I can't solve : Using TCS, I am trying to
>> get an injector able to parse a file which may contain optional tokens
>> with a default value. More over, these token have their values in only
>> three predefined ones.
>>
>> So, I thought to use km3 enums in my metamodel :
>> How to handle enums used in KM3 in TCS ?
>>
>> When the token do not appear in the text, how can I recognize it
>> anyway as defining the default value in the model ?
>>
>> Thanks for your help,
>>
>> Quentin
>>
Re: [TCS]User issues [message #580320 is a reply to message #376865] Thu, 19 April 2007 09:34 Go to previous message
Eclipse UserFriend
Originally posted by: mikael.barbero.gmail.com

Hi Quentin,

"context" is a model element that defines a context whereas addToContext
add a model element to the current context. You define a context if you
want to access an attribute (refersTo) of another element of the same
type of this context whereas you define an addToContext when you want to
look into (lookIn) a parent context of the element.

In your case, i don't think you need to addToContext your elements. Only
declare your MyToken template as a context.

Best regards,
Mikael


Quentin Glineur wrote:
> Hi, and thanks for those ones...
>
> Now, going further in my work with TCS, I wonder what is the difference
> between the "context" and "addToContext" clauses for a template. I have
> read about them having a role in the references (refersTo) but I have a
> problems with such references :
>
> [am3.loadModel] Error: <unknown location>: MyToken with value = Or was
> not found for following of MM!MyLitteral.
>
> Here are the implicated source excerpt :
>
> KM3:
> abstract class MyToken {
> attribute value : String;
> }
>
> class MyIdentifier extends MyToken {
> reference following : MyToken;
> }
>
> class MyLitteral extends MyToken {
> reference following : MyToken;
> }
>
> class MyLineEnd extends MyToken {
> }
>
> TCS:
> template MyToken abstract <context/addToContext?>
> ;
>
> template MyIdentifier <context/addToContext?>
> : value
> following{refersTo = value}
> ;
>
> template MyLitteral <context/addToContext?>
> : value{as=stringSymbol}
> following{refersTo = value}
> ;
>
> template MyLineEnd <context/addToContext?>
> : value{as=endLineSymbol}
> ;
>
> (The "<context/addToContext?>" patterns are where my misunderstanding
> is... )
>
> Regards,
>
> Quentin
>
>
> Frédéric Jouault a écrit :
>> Hello,
>>
>> You can use enumeration templates to represent enumerations.
>> For instance:
>>
>> - in KM3:
>> enumeration A {
>> literal b;
>> literal c;
>> }
>>
>> - in TCS:
>> enumerationTemplate A
>> : #b = "b",
>> #c = "c"
>> ;
>>
>> You can also use conditional elements.
>> For instance:
>>
>> - in KM3 (in addition to enumeration A):
>> class Test {
>> attribute value : A;
>> }
>>
>> - in TCS (instead of enumerationTemplate A, which is now unnecessary):
>> template Test
>> : (value = #b ? "b" : "c")
>> ;
>>
>> In this case, this will behave similarly to enumerationTemplate A.
>> However, you may have more complex constructs (e.g., using isDefined
>> if the attribute is optional, having a complex sequence depending on
>> the value of the enumeration attribute).
>>
>>
>> Regards,
>>
>> Frédéric Jouault
>>
>>
>> Quentin Glineur wrote:
>>> Hi,
>>>
>>> I encounter one problem that I can't solve : Using TCS, I am trying
>>> to get an injector able to parse a file which may contain optional
>>> tokens with a default value. More over, these token have their values
>>> in only three predefined ones.
>>>
>>> So, I thought to use km3 enums in my metamodel :
>>> How to handle enums used in KM3 in TCS ?
>>>
>>> When the token do not appear in the text, how can I recognize it
>>> anyway as defining the default value in the model ?
>>>
>>> Thanks for your help,
>>>
>>> Quentin
>>>



--
Mikaël Barbero - PhD Candidate
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssinière
44322 Nantes Cedex 3 - France
tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00
email: Mikael.Barbero@{gmail.com, univ-nantes.fr}
http://www.sciences.univ-nantes.fr/lina/atl/
Previous Topic:[xPand]template doesn't recognise metamodel data
Next Topic:[OAW] dynamic evaluation of templates
Goto Forum:
  


Current Time: Fri Mar 29 11:23:27 GMT 2024

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

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

Back to the top