Home » Archived » GMT (Generative Modeling Technologies) » [TCS] Is "autoCreate=ifmissing" usable?
[TCS] Is "autoCreate=ifmissing" usable? [message #381747] |
Thu, 13 March 2008 14:41 |
Guillaume Savaton 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 |
Frédéric Jouault 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 #383905 is a reply to message #381750] |
Fri, 27 June 2008 16:05 |
Guillaume Savaton 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 |
Frédéric Jouault 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 #618097 is a reply to message #381750] |
Fri, 27 June 2008 16:05 |
Guillaume Savaton 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
|
|
|
Goto Forum:
Current Time: Sat Sep 21 00:33:17 GMT 2024
Powered by FUDForum. Page generated in 0.03487 seconds
|