Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Beginner : Xtext help
Beginner : Xtext help [message #699742] Fri, 22 July 2011 08:31 Go to next message
Arun  is currently offline Arun Friend
Messages: 26
Registered: July 2011
Junior Member
Hi,

One of the rule in my model as follows,

MessageConfig:

"MessageConfig" name=ID "{"
(messageSourceConfig+=MessageSourceConfig)*
"}"
;

MessageSourceConfig:
"MessageSourceConfig" name=ID "sends (a) message(s) {"
(("via port" portname+=ID)? "to the destination(s)" destination+=ID (',' destination+=ID)* "of type" (dmsType+=DMSTYPE)* (',' dmsType+=DMSTYPE)* "managed by" (providerType+=ProviderType)* (',' providerType+=ProviderType)* )*
"}"
;

DMSTYPE:
TOPIC | QUEUE;

TOPIC:
name="topic";

QUEUE:
name="queue";

ProviderType:
LOCAL | SQLDMS;

LOCAL:
name="local";

SQLDMS:
name="sqldms";

When i write a rule in editor , im getting duplicate rule id,

MessageConfig TestConfig {

MessageSourceConfig TestSource sends (a) message(s) {

via port normal to the destination(s) normalmsgtpoic,emergencymdgtopic of type queue,topic managed by sqldms,local

via port emergency to the destination(s) normalmsgtpoic,emergencytopi of type topic managed by sqldms
}

Error:
Duplicate DMSType topic and Duplicate ProviderType sqldms.

kindly help on this.

Thanks,
Arun

}
Re: Beginner : Xtext help [message #699748 is a reply to message #699742] Fri, 22 July 2011 08:48 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,
these rules do not really make sense. E.g. every time you use TOPIC a topic object with name "topic" is created, no wonder there are duplicate elements.

DMSTYPE:
TOPIC | QUEUE;

TOPIC:
name="topic";

QUEUE:
name="queue";

ProviderType:
LOCAL | SQLDMS;

LOCAL:
name="local";

SQLDMS:
name="sqldms";

If you want to hard code the types, it would be better to use enum rules for DmsType and ProviderType. If these types should be flexible, you would use references to them in the MessageSourceConfig.

Further notes:
-its a bad idea to have white spaces in a keyword
"sends (a) message(s) {"
shold be
"sends" "(a)" "message(s)" "{"
-the convention is that only terminal rules are completely capitalised, that way, reading the grammar becomes easier.



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: Beginner : Xtext help [message #699749 is a reply to message #699742] Fri, 22 July 2011 08:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you have static names so they are of course not unique if you use them twice.

but if you want to use them as enums why dont you declare them as enums

enum DMSTYPE:
TOPIC="topic" | QUEUE="queue";


enum ProviderType:
LOCAL="local" | SQLDMS="sqldms";



~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Beginner : Xtext help [message #699792 is a reply to message #699749] Fri, 22 July 2011 10:13 Go to previous message
Arun  is currently offline Arun Friend
Messages: 26
Registered: July 2011
Junior Member
Thanks Christian!. Issue solved.
Previous Topic:Combining data structure with a markup format
Next Topic:getting started with xdoc
Goto Forum:
  


Current Time: Fri Apr 19 18:49:09 GMT 2024

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

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

Back to the top