Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Implementing a DSL with Classes, Instances and Function Calls(Creating my own Scope)
Implementing a DSL with Classes, Instances and Function Calls [message #552322] Wed, 11 August 2010 17:36 Go to next message
Christian Ammann is currently offline Christian AmmannFriend
Messages: 21
Registered: July 2010
Junior Member
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 #552324 is a reply to message #552322] Wed, 11 August 2010 17:44 Go to previous messageGo to next message
Christian Ammann is currently offline Christian AmmannFriend
Messages: 21
Registered: July 2010
Junior Member
oh sorry, somehow i missed the right forum. can somebody move it to the TMF (Xtext) section?

[Updated on: Wed, 11 August 2010 17:45]

Report message to a moderator

Re: Implementing a DSL with Classes, Instances and Function Calls [message #552375 is a reply to message #552322] Wed, 11 August 2010 23:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30553
Registered: July 2009
Senior Member
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 #552388 is a reply to message #552375] Thu, 12 August 2010 03:09 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi Ed,

When i reply using thunderbird, the reply comes with user as anonymous and not my newsgroup account user.
Can this be configured ?

Regards,
Ashwani Kr Sharma
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552391 is a reply to message #552388] Thu, 12 August 2010 03:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30553
Registered: July 2009
Senior Member
Ashwani,

I'm seeing ashw.kumar at gmail.com (with a real @ not just "at") in my
reader, so it looks fine. There's a "From" dropdown that lets you
choose your identity...


Ashwani Kr Sharma wrote:
> Hi Ed,
>
> When i reply using thunderbird, the reply comes with user as anonymous
> and not my newsgroup account user. Can this be configured ?
>
> Regards,
> Ashwani Kr Sharma
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552394 is a reply to message #552391] Thu, 12 August 2010 04:43 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

Actually i am currently using browser to reply. Hence, the name appears correctly.
I will try the option you mentioned in thunderbird.

Thanks and Regards,
Ashwani Kr Sharma
Re: Implementing a DSL with Classes, Instances and Function Calls [message #552422 is a reply to message #552322] Thu, 12 August 2010 08:07 Go to previous messageGo to next message
Christian Ammann is currently offline Christian AmmannFriend
Messages: 21
Registered: July 2010
Junior Member
oh okay. I didnt know this forum is also a newsgroup. I thought its just a regular forum with moderators, moving wrong posts to the right place Smile
Re: Implementing a DSL with Classes, Instances and Function Calls [message #630697 is a reply to message #552375] Mon, 04 October 2010 15:34 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
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:Best practice for EMF Notification propagation
Next Topic:Package not available for reloading of model
Goto Forum:
  


Current Time: Mon Oct 21 20:10:37 GMT 2019

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

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

Back to the top