Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/381747/#msg_381747
I am working on a small example language.
In my TCS syntax, I am trying to use the "autoCreate" parameter like this :
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]]>Guillaume Savaton2008-03-13T14:41:16-00:00Re: [TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/613637/#msg_613637
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
>]]>Frédéric Jouault2008-03-14T10:45:04-00:00Re: [TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/381750/#msg_381750
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
>]]>Frédéric Jouault2008-03-14T10:45:04-00:00Re: [TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/381861/#msg_381861
> 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]]>Guillaume Savaton2008-04-05T20:53:26-00:00Re: [TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/614867/#msg_614867
> 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]]>Guillaume Savaton2008-04-05T20:53:26-00:00Re: [TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/618097/#msg_618097
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.
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]]>Guillaume Savaton2008-06-27T16:05:25-00:00Re: [TCS] Is "autoCreate=ifmissing" usable?
https://www.eclipse.org/forums/index.php/mv/msg/124735/383905/#msg_383905
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.
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".