Re: Implementing a DSL with Classes, Instances and Function Calls [message #552380] |
Wed, 11 August 2010 23:44 |
Ed Merks Messages: 33140 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
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Re: Implementing a DSL with Classes, Instances and Function Calls [message #630701 is a reply to message #552380] |
Mon, 04 October 2010 15:34 |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Powered by
FUDForum. Page generated in 0.03057 seconds