Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Duplicated Type Error
Duplicated Type Error [message #702283] Tue, 26 July 2011 07:22 Go to next message
Caner Friend
Messages: 98
Registered: July 2011
Member

Hello Everyone
Can you give me a hand please?

in myDsl, I have some Types as below;

LibraryModel:
  (types+=Type)*;            

Type:
Comment1|NonEmpityLine|Version

Version:
   "@" name=Words ('=' DOUBLE)?
 ; 
	
...

Words hidden (): 
  	
    	ID (WS ID)*
     ;

....


In the something.dsl file, I get Duplicate Type Error for version while I am typing version might be called more than one time e.g.

%comentss

@version=0.0
/////some code
@version=X
////some code
@version=2.2
////some code 



PS: name "version" declared via content assist
Re: Duplicated Type Error [message #702291 is a reply to message #702283] Tue, 26 July 2011 07:33 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

Version has a name feature the value of which will be used cross referencing. In the example all Versions are called "version" so there are duplicate names.
Do you want to have references to Version? If not, why call the feature name. If yes, you have to provide unique names (if you want referencing to work).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicated Type Error [message #702334 is a reply to message #702291] Tue, 26 July 2011 08:27 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Hi
How is it supposed to be than?
Version is just sort of information for user, it hasnt anything to do with code,
By the way, Thanks for your answer
Re: Duplicated Type Error [message #702344 is a reply to message #702334] Tue, 26 July 2011 08:47 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

I don't know your language and what you want to do with it. If a version is only some info for the user then why not have
Version:'@' infoName=Words (versionNumber=DOUBLE)?;
It looks like you have a terminal rule for DOUBLE, it is better practice not to mess with terminals (if not necessary) and introduce datatype rules instead.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicated Type Error [message #702364 is a reply to message #702344] Tue, 26 July 2011 09:15 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Thank you so much , according your advice, I have declared the version
  Version:
  '@version=' (versionNumber=DOUBLE|'X' )?;	



But i got a warning which is " The rule 'version' may be consumed without object instantiation.
Add an action to ensure object creation, e.g. '{version}'.
"
Does it matter do you think?

[Updated on: Tue, 26 July 2011 09:17]

Report message to a moderator

Re: Duplicated Type Error [message #702377 is a reply to message #702364] Tue, 26 July 2011 09:35 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the rule looks strange, either the version number is mandatory or you should move the "=" into the optional part. As to your question, it depends on what you want to do with your model. If you don't specify a versionNumber, no Version-Object will be created. That is, if your model looks like this
...
@version
@version
@version
...
and you "count" the versions in your model, the result will be 0. Anyway, I'd add the action, so that the model represents the input as far as possible
Version: {Version} '@version' ('=' versionNumber=(DOUBLE|'X'))?/*note the additional parentheses around Double and 'X', otherwise 'X' will not be stored as versionNumber, but maybe you wanted that*/

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicated Type Error [message #702446 is a reply to message #702377] Tue, 26 July 2011 11:45 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Thanks a lot Alex
Now i have an other problem;
I have a type as below


tagTranslation:
	  {tagTranslation}
		'@translators' ('=' pattern1=myWords ) (','name1=myWords)? 	;


    
myWords hidden (): 
    	
    	myID (WS ID)*
    	
    ;

terminal myID :
	
  	'^'?('a'..'z'|'A'..'Z'|'_'|'.'|'[]'|'()') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'%')*  
    ;
  	  



When I am coding in .mydsl file

@tagtranslators= spattern,wname

mismatched input ',' expecting ':'
- mismatched input '<EOF>' expecting ':'
- missing RULE_MYID at 'spattern'

[Updated on: Tue, 26 July 2011 11:49]

Report message to a moderator

Re: Duplicated Type Error [message #702458 is a reply to message #702446] Tue, 26 July 2011 11:52 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

you did not give enough of the grammar. The error message indicates that there should be a colon somewhere, but none of the rules given contains one.
If possible, don't define a terminal myId but rather a datatype rule along with a value-converter that checks the correct syntax. It is well possible that input that you expect to be tokenised as ID will be myId instead.
It is never a good idea to have overlapping terminal definitions.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicated Type Error [message #702468 is a reply to message #702458] Tue, 26 July 2011 12:13 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Please excuse me for unclear question

Actually what i want to do is ;

i have special parameters names which contains some special characters such as "[,],%,|.."

@tagtranslators= [spa%ttern],(%nameID)

I tough if i define new terminal ID and modify it with these needed characters, I thought it will work,
Re: Duplicated Type Error [message #702478 is a reply to message #702468] Tue, 26 July 2011 12:26 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

still, it is the question whether you want to solve that on the terminal level (for now, I don't recommend that) or on the parser level. How about something linke this

SpecialPatternSymbol: '[' | ']'|...;
Pattern: SpecialPatternSymbol? (ID SpecialPatternSymbol)* ID SpecialPatternSymbol?;

Of course this needs to be addapted to what your pattern really could look like.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicated Type Error [message #702525 is a reply to message #702478] Tue, 26 July 2011 13:47 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Hi again
I had so many errors until declaration which is below


Translation:
	 
	 {Translation}
	'@translators'('=' pattern1=Characters )? (´,´ user=Characters)? 
;

Characters hidden () :
 	ID(WS myID)*
 ;

terminal myID:
	'^'?('a'..'z'|'A'..'Z'|'_'|'.') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'%'|'['|']'|'('|')'|'.')*
;



Now, if I type

@translators= pattern[%d],patternID

I get this error


missing RULE_ID at 'pattern[%d]'


Why do you think? Is there any missing?
Re: Duplicated Type Error [message #702537 is a reply to message #702525] Tue, 26 July 2011 13:54 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

pattern[%d] is not covered by ID, and Characters requires there to be an ID and then possibly a white space followed by myID.
Did you intend
Characters hidden () :
myID(WS myID)*
;

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicated Type Error [message #702542 is a reply to message #702537] Tue, 26 July 2011 14:01 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
well,I have tired this before and its an error

Characters hidden () :
myID(WS myID)*
;

and with this way

i get this error;

missing RULE_MYID at '@ttranslators'

[Updated on: Tue, 26 July 2011 14:02]

Report message to a moderator

Re: Duplicated Type Error [message #702598 is a reply to message #702542] Tue, 26 July 2011 15:03 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

grammar org.xtext.example.mydsl1.MyDsl1 with org.eclipse.xtext.common.Terminals

generate myDsl1 "http://www.xtext.org/example/mydsl1/MyDsl1"

Translation:
	 
	 {Translation}
	'@translators'('=' pattern1=Characters )? (',' user=Characters)? 
;

Characters hidden () :
 	myID(WS myID)*
 ;

terminal myID:
	'^'?('a'..'z'|'A'..'Z'|'_'|'.') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'%'|'['|']'|'('|')'|'.')*
;


works for

@translators= pattern[%d],patternID


There is no way to help you, if you don't provide your full grammar along with a large set of input models you expect to be working. You should write unit tests that cover input. AbstractXtextTests in the xtext.junit plugin is helpful
You may want to have a look at this project. I think it also contains methods for testing terminal and parser rules, otherwise look at this somewhat outdated blog post.

As I said, messing with terminal rules may be painful.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:Xtext generated parser reports errors - why?
Next Topic:generator providing simple XML output
Goto Forum:
  


Current Time: Wed Apr 21 06:09:40 GMT 2021

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

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

Back to the top