Home » Archived » GMT (Generative Modeling Technologies) » [TCS] Is "autoCreate=ifmissing" usable?
[TCS] Is "autoCreate=ifmissing" usable? [message #381747] |
Thu, 13 March 2008 10:41  |
Eclipse User |
|
|
|
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 06:45   |
Eclipse User |
|
|
|
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 #383905 is a reply to message #381750] |
Fri, 27 June 2008 12:05  |
Eclipse User |
|
|
|
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 06:45  |
Eclipse User |
|
|
|
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 16:53  |
Eclipse User |
|
|
|
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 12:05  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Fri Mar 21 04:28:49 EDT 2025
Powered by FUDForum. Page generated in 0.02889 seconds
|