Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » [TCS] Is "autoCreate=ifmissing" usable?
[TCS] Is "autoCreate=ifmissing" usable? [message #381747] Thu, 13 March 2008 14:41 Go to next message
Guillaume Savaton is currently offline Guillaume SavatonFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

I am working on a small example language.
In my TCS syntax, I am trying to use the "autoCreate" parameter like this :

template Program main context
: assignments
;

template Assignment
: variable{refersTo=name, lookIn=owningProgram.variables,
autoCreate=ifmissing} "=" expression ";"
;

When meeting an assigned variable name, the parser creates a new
"Variable" element and correctly sets the "variables" reference in the
surrounding "Program" element.
The problem is that "ifmissing" seems to have the same effect as "always":
if I use the same variable name in several assignments, several variables
with the same name are created.

Since I found no example using "ifmissing", I am wondering whether this
feature has already been used successfully, and how I could get it to work.

Many thanks for your help,

Guillaume
Re: [TCS] Is "autoCreate=ifmissing" usable? [message #381750 is a reply to message #381747] Fri, 14 March 2008 10:45 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
Hi,

Can you try to use createIn instead of lookIn?

Indeed, it seems to me that your purpose is to create the Variable at a
specific place, not to look it up in a specific context. (I must admit
that the difference is small.)

createIn adds the created element to the context, whereas lookIn
currently does not. I have to think about it, but you may have
discovered a bug. The combination of lookIn and ifmissing has only been
tested when lookIn = '#all'. Can you please report this issue on the
bugzilla?

Thanks.


Best regards,

Frédéric Jouault

Guillaume Savaton a écrit :
> Hi,
>
> I am working on a small example language.
> In my TCS syntax, I am trying to use the "autoCreate" parameter like this :
>
> template Program main context
> : assignments
> ;
>
> template Assignment
> : variable{refersTo=name, lookIn=owningProgram.variables,
> autoCreate=ifmissing} "=" expression ";"
> ;
>
> When meeting an assigned variable name, the parser creates a new
> "Variable" element and correctly sets the "variables" reference in the
> surrounding "Program" element.
> The problem is that "ifmissing" seems to have the same effect as
> "always": if I use the same variable name in several assignments,
> several variables with the same name are created.
>
> Since I found no example using "ifmissing", I am wondering whether this
> feature has already been used successfully, and how I could get it to work.
>
> Many thanks for your help,
>
> Guillaume
>
Re: [TCS] Is "autoCreate=ifmissing" usable? [message #381861 is a reply to message #381750] Sat, 05 April 2008 20:53 Go to previous messageGo to next message
Guillaume Savaton is currently offline Guillaume SavatonFriend
Messages: 19
Registered: July 2009
Junior Member
Frédéric Jouault wrote:
> Can you try to use createIn instead of lookIn?

Great!
I didn't know about "createIn".

> Indeed, it seems to me that your purpose is to create the Variable at a
> specific place, not to look it up in a specific context. (I must admit
> that the difference is small.)

Actually, it seems reasonable to assume that the context where an element
should be looked up is the same as the context where it should be created
if missing.

I understand that "createIn" can be useful when "lookIn" is set to "#all".
Are there other situations where it is relevant to separate "lookIn" and
"createIn".

> Can you please report this issue on the bugzilla?

I can.

Thanks for your help.

Guillaume
Re: [TCS] Is "autoCreate=ifmissing" usable? [message #383905 is a reply to message #381750] Fri, 27 June 2008 16:05 Go to previous message
Guillaume Savaton is currently offline Guillaume SavatonFriend
Messages: 19
Registered: July 2009
Junior Member
I finally reported this issue on the Bugzilla. Sorry for the delay.

Frédéric Jouault wrote:
> createIn adds the created element to the context, whereas lookIn
> currently does not.

I tried "createIn", but the result is worse than with "lookIn".

With "lookIn", duplicate elements were created, and actually I observe
that all elements were added to the context. In the example below,
template "VariableRefExpression" does not produce "name not found" errors
during injection.

template Assignment :
variable{refersTo=name, lookIn=owningProgram.variables,
autoCreate=ifmissing} "=" expression ";";

template VariableRefExpression :
variable{refersTo=name};

With "createIn", duplicate elements are still created, but none are added
to the context (or maybe not to the desired context). The injector fails
to resolve variable names in "VariableRefExpression".

Best regards,

Guillaume
Re: [TCS] Is "autoCreate=ifmissing" usable? [message #613637 is a reply to message #381747] Fri, 14 March 2008 10:45 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hi,

Can you try to use createIn instead of lookIn?

Indeed, it seems to me that your purpose is to create the Variable at a
specific place, not to look it up in a specific context. (I must admit
that the difference is small.)

createIn adds the created element to the context, whereas lookIn
currently does not. I have to think about it, but you may have
discovered a bug. The combination of lookIn and ifmissing has only been
tested when lookIn = '#all'. Can you please report this issue on the
bugzilla?

Thanks.


Best regards,

Frédéric Jouault

Guillaume Savaton a écrit :
> Hi,
>
> I am working on a small example language.
> In my TCS syntax, I am trying to use the "autoCreate" parameter like this :
>
> template Program main context
> : assignments
> ;
>
> template Assignment
> : variable{refersTo=name, lookIn=owningProgram.variables,
> autoCreate=ifmissing} "=" expression ";"
> ;
>
> When meeting an assigned variable name, the parser creates a new
> "Variable" element and correctly sets the "variables" reference in the
> surrounding "Program" element.
> The problem is that "ifmissing" seems to have the same effect as
> "always": if I use the same variable name in several assignments,
> several variables with the same name are created.
>
> Since I found no example using "ifmissing", I am wondering whether this
> feature has already been used successfully, and how I could get it to work.
>
> Many thanks for your help,
>
> Guillaume
>
Re: [TCS] Is "autoCreate=ifmissing" usable? [message #614867 is a reply to message #381750] Sat, 05 April 2008 20:53 Go to previous message
Guillaume Savaton is currently offline Guillaume SavatonFriend
Messages: 19
Registered: July 2009
Junior Member
Frédéric Jouault wrote:
> Can you try to use createIn instead of lookIn?

Great!
I didn't know about "createIn".

> Indeed, it seems to me that your purpose is to create the Variable at a
> specific place, not to look it up in a specific context. (I must admit
> that the difference is small.)

Actually, it seems reasonable to assume that the context where an element
should be looked up is the same as the context where it should be created
if missing.

I understand that "createIn" can be useful when "lookIn" is set to "#all".
Are there other situations where it is relevant to separate "lookIn" and
"createIn".

> Can you please report this issue on the bugzilla?

I can.

Thanks for your help.

Guillaume
Re: [TCS] Is "autoCreate=ifmissing" usable? [message #618097 is a reply to message #381750] Fri, 27 June 2008 16:05 Go to previous message
Guillaume Savaton is currently offline Guillaume SavatonFriend
Messages: 19
Registered: July 2009
Junior Member
I finally reported this issue on the Bugzilla. Sorry for the delay.

Frédéric Jouault wrote:
> createIn adds the created element to the context, whereas lookIn
> currently does not.

I tried "createIn", but the result is worse than with "lookIn".

With "lookIn", duplicate elements were created, and actually I observe
that all elements were added to the context. In the example below,
template "VariableRefExpression" does not produce "name not found" errors
during injection.

template Assignment :
variable{refersTo=name, lookIn=owningProgram.variables,
autoCreate=ifmissing} "=" expression ";";

template VariableRefExpression :
variable{refersTo=name};

With "createIn", duplicate elements are still created, but none are added
to the context (or maybe not to the desired context). The injector fails
to resolve variable names in "VariableRefExpression".

Best regards,

Guillaume
Previous Topic:OAW xpt and counters
Next Topic:TCS for Eclipse 3.4?
Goto Forum:
  


Current Time: Mon Nov 24 16:32:02 GMT 2014

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

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