Duplicated Type Error [message #702283] |
Tue, 26 July 2011 07:22 |
Caner 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 #702364 is a reply to message #702344] |
Tue, 26 July 2011 09:15 |
Caner 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 |
Alexander Nittka 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 |
Caner 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 #702598 is a reply to message #702542] |
Tue, 26 July 2011 15:03 |
Alexander Nittka 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
|
|
|
Powered by
FUDForum. Page generated in 0.04255 seconds