Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Passing Arguments
Passing Arguments [message #756360] Sat, 12 November 2011 11:26 Go to next message
Bahad?r  KIN is currently offline Bahad?r KINFriend
Messages: 3
Registered: November 2011
Junior Member
Hi;

I am working on a DSL on my Senior Project. In my senior proect, i m trying to define a language which can express protocols and it's source code are in a git repo(git://github.com/bhdrkn/Protocol-Definition-Language.git). I want to pass argument to allready defined function. To make it simple let say i want to define a grammer like that which is almost same in my senior project's grammer;

[DEFINITIONS]
Argument name
[/DEFINITIONS]
[FUNCTIONS]
function myFirstFunction(Argument arg0)
[/FUNCTIONS]
[CALLS]
call myFirstFunction(name)
[/CALLS]


In order to do that i define this;


FUNCFile:
defines = Defines
functions = Functions
calls = Calls;

Defines:
'[DEFINITIONS]'
definitions+=Define*
'[/DEFINITIONS]';

Define:
    name=ID param=ID;

Functions:
'[FUNCTIONS]'
functions+=Function*
'[/FUNCTIONS]' ;

Function:
'function' name=ID '(' (args+=Argument)* ')';

Argument:
    keyword=[Define] name=ID;

Calls:
'[CALLS]'
calls+=Call*
'[/CALLS]' ;

Call:
'call' name=[Function];



I'm stuck at calling a function and passing a argument to it. I try many other things but all of them failed. I read other messages about argument passing. But i still have no solution.

I need help
Re: Passing Arguments [message #756363 is a reply to message #756360] Sat, 12 November 2011 11:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13769
Registered: July 2009
Senior Member
Call:
'call' name=[Function] '(' defres+=DefRef* ')';

DefRef:
def=[Define];

Please not: you reference Defines in your case not by "name" but by "param"

=> You have to change IQualifiedNameProvider to return the param of a Define as its qualifiedname
+ you will need a validator to check type and length of the DefRefs

Update:

are you sure you refernce defines by name and by param? if yes you do not have to change the IQualifiedNameProvider but the DefaultResourceDescriptionStrategy
to "export" Defines by "name" and by "param"


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 12 November 2011 12:03]

Report message to a moderator

Re: Passing Arguments [message #756458 is a reply to message #756363] Sun, 13 November 2011 16:23 Go to previous messageGo to next message
Bahad?r  KIN is currently offline Bahad?r KINFriend
Messages: 3
Registered: November 2011
Junior Member
Christian Dietrich wrote on Sat, 12 November 2011 06:39
Call:
'call' name=[Function] '(' defres+=DefRef* ')';

DefRef:
def=[Define];

Please not: you reference Defines in your case not by "name" but by "param"

=> You have to change IQualifiedNameProvider to return the param of a Define as its qualifiedname
+ you will need a validator to check type and length of the DefRefs

Update:

are you sure you refernce defines by name and by param? if yes you do not have to change the IQualifiedNameProvider but the DefaultResourceDescriptionStrategy
to "export" Defines by "name" and by "param"


Thanks for your reply.
I tried something like that but it does not sufficient for me.
How to bind "function"'s Argument and "call"'s defres?
I want to bind "function"'s argument and "call"'s deferes.
I will genereta java classes from it.



Re: Passing Arguments [message #756459 is a reply to message #756458] Sun, 13 November 2011 16:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13769
Registered: July 2009
Senior Member
hi, i dont understand your problem, can you elaborate a bit? what do you mean with "bind"?

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sun, 13 November 2011 16:32]

Report message to a moderator

Re: Passing Arguments [message #756466 is a reply to message #756459] Sun, 13 November 2011 18:16 Go to previous messageGo to next message
Bahad?r  KIN is currently offline Bahad?r KINFriend
Messages: 3
Registered: November 2011
Junior Member
Christian Dietrich wrote on Sun, 13 November 2011 11:25
hi, i dont understand your problem, can you elaborate a bit? what do you mean with "bind"?

~Christian


Sorry. I now get it. I will look for both IQualifiedNameProvider and a Validator.
And thanks for your time.

[Updated on: Sun, 13 November 2011 18:22]

Report message to a moderator

Re: Passing Arguments [message #756468 is a reply to message #756466] Sun, 13 November 2011 18:24 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13769
Registered: July 2009
Senior Member
Hi,

this is usually never !!! done in the grammar but always using a semantic validator. Wink
as i said in my first post: Quote:
you will need a validator to check type and length of the DefRefs


~Christian



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Single quote ambiguity
Next Topic:Newbie: grammar, identifying STRING vs ID
Goto Forum:
  


Current Time: Sat Mar 06 06:48:04 GMT 2021

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

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

Back to the top