Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext multiple parameter to a method possibility(Want to know is it possible to provide a production rule and a terminal rule as a possible parameter to a method together.)
icon7.gif  Xtext multiple parameter to a method possibility [message #1758074] Thu, 23 March 2017 09:53 Go to next message
KHUMAAN RAJAIN is currently offline KHUMAAN RAJAINFriend
Messages: 4
Registered: March 2017
Junior Member
Please find the xtext grammar sample attached. I have a following rule.

SomeFunction:
name=('addDays' | 'addWeeks' | 'addYears') '(' value=NUMBER ')';

terminal NUMBER returns ecore::ELong:
'-'?('0'..'9')+;

All other things are defined and working fine. What I want to change is that to add a production rule as a possible alternative in the parameters of SomeFunction , which is as follows -

SomeFunction:
name=('addDays' | 'addWeeks' | 'addYears') '(' value=(NUMBER | ProductionRule_A) ')';

I'm getting an error which is as follows - Cannot find type for 'NUMBER | ProductionRule_A'.

Please guide me whether it's possible to do so. IF not why. IF yes how can i do this.
Re: Xtext multiple parameter to a method possibility [message #1758099 is a reply to message #1758074] Thu, 23 March 2017 14:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14732
Registered: July 2009
Senior Member
is ProductionRule_A a parser rule. if so this makes no sense: a attribute cannot be ob a simple and a complex type at the same time.
maybe you want to

.... value=(NumberLiteral | ProductionRule_A) 


NumberLiteral: number=NUMBER;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Xtext multiple parameter to a method possibility [message #1758992 is a reply to message #1758099] Wed, 05 April 2017 06:06 Go to previous messageGo to next message
KHUMAAN RAJAIN is currently offline KHUMAAN RAJAINFriend
Messages: 4
Registered: March 2017
Junior Member
Yes ProductionRule_A is a parser rule. Is it possible/allowed to be used like this ?
Using your suggestion, it fails in the content assist, for e.g. when I'm about to complete the ProcutionRule_A , the model comes out to be null in my custom proposal provider class, in the completeXXXXX method. How to deal with that ?
Additionally i wanted to enquire or you can guide me to some resource that clearly states that whether or not we can/cannot use simple and complex type attributes in a method parameters list in Xtext using the grammar.

[Updated on: Wed, 05 April 2017 06:08]

Report message to a moderator

Re: Xtext multiple parameter to a method possibility [message #1758995 is a reply to message #1758992] Wed, 05 April 2017 06:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14732
Registered: July 2009
Senior Member
can you please give a complete hello world sample grammar with failing CA

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Xtext multiple parameter to a method possibility [message #1758999 is a reply to message #1758995] Wed, 05 April 2017 07:31 Go to previous messageGo to next message
KHUMAAN RAJAIN is currently offline KHUMAAN RAJAINFriend
Messages: 4
Registered: March 2017
Junior Member
Yes I'll just share it in my next reply
Re: Xtext multiple parameter to a method possibility [message #1759000 is a reply to message #1758995] Wed, 05 April 2017 07:31 Go to previous message
KHUMAAN RAJAIN is currently offline KHUMAAN RAJAINFriend
Messages: 4
Registered: March 2017
Junior Member
Yes I'll just share it in my next reply
Previous Topic:Cross referencing pre-defined "terminals"
Next Topic:Limiting cross-reference to a single file
Goto Forum:
  


Current Time: Tue Nov 12 23:52:36 GMT 2024

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

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

Back to the top