Implementing a DSL with Classes, Instances and Function Calls [message #552322] |
Wed, 11 August 2010 13:36  |
Eclipse User |
|
|
|
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:
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 #630697 is a reply to message #552375] |
Mon, 04 October 2010 11:34  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.05539 seconds