Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Re: Implementing a DSL with Classes, Instances and Function Calls
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552380] Wed, 11 August 2010 19:44 Go to next message
Eclipse UserFriend
Christian,

With a newsgroup reader (Thunderbird) you can redirect a post just by
adding the other newsgroup to the reply as I've done here.


Christian Ammann wrote:
> Hi there,
>
> i have a scoping related problem. I Want to implement a DSL which
> contains classes. A class can contain functions. When i instanciate a
> class, i want to call the class functions. Here is a simplified
> example of my DSL:
>
>
> class Stack{ operation push();
> }
>
> Stack s1;
>
> call s1.push();
>
>
> The problem is within the last line: The default scoping only allows
> me something like:
>
> call Stack.push();
>
> My grammar looks like:
>
>
> Model:
> (class+=Class)*
> (vars+=Variable)*
> (calls+=Calls)*
> ;
>
> Variable:
> type=[Class] name=ID ";"
> ;
>
> Class:
> "class" name=ID "{"
> (op+=Operation)*
> "}"
> ;
> Operation:
> "operation" name=ID "(" ")" ";"
> ;
>
> Calls:
> "call" call=[Operation|FQN] "(" ")" ";"
> ;
>
> FQN:
> ID "." ID
> ;
>
>
> I think i have to create somehow my own scope, which uses the instance
> references instead of the class declaration name.
> Thanks for your help in advance,
>
> Christian
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552434 is a reply to message #552380] Thu, 12 August 2010 05:03 Go to previous messageGo to next message
Eclipse UserFriend
The original Thread was for thhis forum (Xtext) but i posted it at the wrong place. The Thread can be found here:

http://www.eclipse.org/forums/index.php?t=msg&th=173546& amp;start=0&S=7c4d1a3902e0c5c52ba2a05f549b3017
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552468 is a reply to message #552434] Thu, 12 August 2010 05:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

it may make sense to break up the call and adapt scoping

Calls: 'call' variable=[Variable]'.'operation=[Operation]'('')'';';

and adapt scoping so that only operations from the given variable are
visible. You may have to adapt code completion because the default
implementation will try to propose fully qualified names and there is
only one operation in the model (push in Stack whose qualified name is
Stack.push).
I don't know whether further chaining is possible in your case

call s1.pop().chreateHashcode().multiplyByTwo()

In this case it would make sense to think about Expressions and assigned
actions.

Alex
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552476 is a reply to message #552468] Thu, 12 August 2010 06:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex,

thanks for your reply. I had problems understanding the concept of scoping, but your replay together with this this:

http://www.eclipse.org/forums/index.php?t=msg&th=172683& amp;start=0&S=7c4d1a3902e0c5c52ba2a05f549b3017

helped alot. Smile
Re: Implementing a DSL with Classes, Instances and Function Calls [message #630701 is a reply to message #552380] Mon, 04 October 2010 11:34 Go to previous message
Eclipse UserFriend
probably this might help: http://fj-eclipse.sourceforge.net/

On 08/12/2010 01:44 AM, Ed Merks wrote:
> Christian Ammann wrote:
>> Hi there,
>>
>> i have a scoping related problem. I Want to implement a DSL which
>> contains classes. A class can contain functions. When i instanciate a
>> class, i want to call the class functions. Here is a simplified
>> example of my DSL:
>>
>>
>> class Stack{ operation push();
>> }
>>
>> Stack s1;
>>
>> call s1.push();
>>
>>
>> The problem is within the last line: The default scoping only allows
>> me something like:
>>
>> call Stack.push();
>>
>> My grammar looks like:
>>
>>
>> Model:
>> (class+=Class)*
>> (vars+=Variable)*
>> (calls+=Calls)*
>> ;
>>
>> Variable:
>> type=[Class] name=ID ";"
>> ;
>>
>> Class:
>> "class" name=ID "{"
>> (op+=Operation)*
>> "}"
>> ;
>> Operation:
>> "operation" name=ID "(" ")" ";"
>> ;
>>
>> Calls:
>> "call" call=[Operation|FQN] "(" ")" ";"
>> ;
>>
>> FQN:
>> ID "." ID
>> ;
>>
>>
>> I think i have to create somehow my own scope, which uses the instance
>> references instead of the class declaration name.
>> Thanks for your help in advance,
>>
>> Christian


--
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
Previous Topic:Keyword-reference collision: backtrackLexer doesn't help
Next Topic:IContentOutlineNodeForTextSelection - what is it supposed to do?
Goto Forum:
  


Current Time: Wed Jul 16 18:41:11 EDT 2025

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

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

Back to the top