Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem when defining terminal rule(Overloading rule)
Problem when defining terminal rule [message #892173] Wed, 27 June 2012 09:54 Go to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Hello,

I'm going through a persistent problem when I define a terminal rule in my grammar.

/* Grammar standard stuff, only non-terminal rules */

terminal Regle returns ecore::EString:
	('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_')*
;

/*
 * To enable inline comments begginning with #
 */
terminal SL_COMMENT returns ecore::EString:
	'#' !('\n'|'\r')* ('\r'? '\n')?
;


I don't have any error while defining it but when I launch Runtime Eclipse, several errors appear in my own dsl editor, as :


  • mismatched input 'DEFAULT' expecting RULE_ID
  • missing RULE_ID at 'EXIT_SEQUENCE'
  • extraneous input 'InternalSet' expecting 'END_SEQUENCE'


When I comment the first terminal rule (Regle one) in my grammar and then re-compile, it's just work fine.

I really don't understand, I check on documentation many times and then on google without success.

I hope any of you has suggestions, thanks !
Re: Problem when defining terminal rule [message #892183 is a reply to message #892173] Wed, 27 June 2012 10:33 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 430
Registered: July 2009
Location: Gothenburg
Senior Member
Hi!

Do you import the default terminal definitions? If yes, Regle is colliding with ID and the engine gets confused.

best regards,
Vlad
Re: Problem when defining terminal rule [message #892186 is a reply to message #892173] Wed, 27 June 2012 10:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13358
Registered: July 2009
Senior Member
Hi you terminal collides with the id terminal so fix this or remove
the usages of the ID terminal. P.s. xxx=[whatever] is such a usage
too


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem when defining terminal rule [message #892198 is a reply to message #892183] Wed, 27 June 2012 11:39 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Thank you for your responses.

Vlad Dumitrescu wrote on Wed, 27 June 2012 06:33
Hi!

Do you import the default terminal definitions? If yes, Regle is colliding with ID and the engine gets confused.

best regards,
Vlad


Yes I think so. I have the following line in my grammar :
import "the_link_here" as ecore


Ok I see, my rule is colliding with the ID terminal.

But in other rules I need the ID, so I can't remove it.

I don't really understand what you mean to fix it Christian.
For example, in another rule, I call this terminal rule simply by : xxx=Regle

I read that means implicitly xxx=Regle|ID, so do I need to write xxx=Regle|Regle instead ?


Re: Problem when defining terminal rule [message #892200 is a reply to message #892173] Wed, 27 June 2012 11:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13358
Registered: July 2009
Senior Member
Use the Id rule and ensure naming conventions by checks

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem when defining terminal rule [message #892235 is a reply to message #892200] Wed, 27 June 2012 13:17 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
I checked naming conventions, I modified my rule Regle by changing her name to REGLE.
Then I used xxx=REGLE|ID to call it when necessary and I did the same for all my calls of another rules : by writing xxx=Y|ID or xxx=Z|REGLE.

Now, thank you it resolves most of my errors but I still have one error in my dsl's editor view.

I have this rules for example :
Seq hidden(WS, ML_COMMENT, SL_COMMENT):
	'START' name='=' SeqName|REGLE
	package=Package|ID
	firstAction=FirstAction|ID
	lastAction=LastAction|ID
	regle=REGLE|ID
	'END';

Package:
	'PACKAGE' name='=' ID ('.' ID | '.' | '.*')*;


And I have an error on the keyword 'PACKAGE', it says : missing EOF at 'PACKAGE'

I don't see where the error is hiding...
Re: Problem when defining terminal rule [message #892240 is a reply to message #892235] Wed, 27 June 2012 13:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13358
Registered: July 2009
Senior Member
Sorry the grammar makes no sense to me

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem when defining terminal rule [message #892242 is a reply to message #892240] Wed, 27 June 2012 13:30 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 430
Registered: July 2009
Location: Gothenburg
Senior Member
When you write for example
package=Package|ID
, do you really mean
package=[Package|ID]
, i.e. a link to a Package object?
/Vlad
Re: Problem when defining terminal rule [message #892267 is a reply to message #892173] Wed, 27 June 2012 14:33 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
In my mind, when I write package=Package|ID in the Seq rule, it will create a field named "package" in the Seq class , I don't know if it answers to your question...

But I don't understand the difference between the two notations, I'll check on documentation.
Re: Problem when defining terminal rule [message #892352 is a reply to message #892267] Wed, 27 June 2012 20:43 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 430
Registered: July 2009
Location: Gothenburg
Senior Member
If you write
package=Package|ID
, then it means
 (package=Package)|ID
which is either an inlined Package rule or an ID that will not be saved in a feature.

 package=[Package|ID]
means a reference to a Package that has the textual form of an ID.

regards,
Vlad
Re: Problem when defining terminal rule [message #892427 is a reply to message #892352] Thu, 28 June 2012 08:13 Go to previous message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
I see the difference.
In fact I need the second notation package=[Package|ID].
I wrote all my rules calls like this but now I have several erros on it.
For example it says : "A rule's name has to be unique." for all my rules calls...

It seems that XText understand this notation like a second definition or I missed something...

By the way, thank you for the explanation Smile
Previous Topic:Change sorting behavior of Quick Outline
Next Topic:Xtext-Error: rule ruleReference has non-LL(*) decision due to recursive rule invocations...
Goto Forum:
  


Current Time: Thu Feb 20 11:34:31 GMT 2020

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

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

Back to the top