Refer the value of one feature inside the rule [message #986207] |
Mon, 19 November 2012 08:20  |
Eclipse User |
|
|
|
Goodmorning everyone!
Is it possible to refer the value of one feature inside the same rule?
I want to realize something like this:
FUNCTION example
example:=1+1;
END_FUNCTION
So I use a code like this:
Function:
'FUNCTION' name=ID
??? ':=' Expression
'END_FUNCTION';
What can I put instead of ??? to force the name of function? (Or I have to realize it with the validator?)
Very thank you.
[Updated on: Mon, 19 November 2012 11:04] by Moderator
|
|
|
|
|
|
|
|
|
Re: Refer the value of one feature inside the rule [message #987165 is a reply to message #987126] |
Fri, 23 November 2012 17:34   |
Eclipse User |
|
|
|
Can output refer to anything else than the same function? If not why do
you need to have an actual reference to itself in the first place?
I.e. you could just use an ID and validate that same ID is being used.
You want to also add this ID when doing code completion.
If you keep it as a reference, you need to look at scoping to understand
how to limit what is visible; here, if the only thing that is selectable
is the function itself, then that is what you need to add in your scope.
Does that help?
- henrik
On 2012-23-11 17:23, Tommaso De Sica wrote:
> Well, my problem is this:
> I want to write a Rule for Functions. A Function, in my DSL, appears
> like these:
>
> FUNCTION functionName
> {some instruction}
> functionName:=expressionForOutput
> END_FUNCTION
>
> FUNCTION secondFunctionName
> {some instruction}
> secondFunctionName:=expressionForOutput
> END_FUNCTION
>
>
> As you can see, the last instruction must be an assignment where the
> left member is the name of the function.
>
> If I use something like this:
>
> Function:
> 'FUNCTION' name=ID
> instructions+=Instruction*
> output=[Function]':='expression=Expression';' 'END_FUNCTION';
>
> the cross reference [Function] accepts all Function's names, but I want
> only the function name of Function where output is in.
>
> Very thanks.
|
|
|
Re: Refer the value of one feature inside the rule [message #987213 is a reply to message #987126] |
Sat, 24 November 2012 09:29  |
Eclipse User |
|
|
|
On 11/23/2012 05:23 PM, Tommaso De Sica wrote:
> Well, my problem is this:
> I want to write a Rule for Functions. A Function, in my DSL, appears
> like these:
>
> FUNCTION functionName
> {some instruction}
> functionName:=expressionForOutput
> END_FUNCTION
>
> FUNCTION secondFunctionName
> {some instruction}
> secondFunctionName:=expressionForOutput
> END_FUNCTION
>
>
> As you can see, the last instruction must be an assignment where the
> left member is the name of the function.
>
> If I use something like this:
>
> Function:
> 'FUNCTION' name=ID
> instructions+=Instruction*
> output=[Function]':='expression=Expression';' 'END_FUNCTION';
>
> the cross reference [Function] accepts all Function's names, but I want
> only the function name of Function where output is in.
>
> Very thanks.
You have to implement a custom Scoping for that!
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
|
|
|
Powered by
FUDForum. Page generated in 0.06121 seconds