Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Beginner : Xtext help
Beginner : Xtext help [message #699742] Fri, 22 July 2011 04:31 Go to next message
Eclipse UserFriend
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 04:48 Go to previous messageGo to next message
Eclipse UserFriend
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.

Re: Beginner : Xtext help [message #699749 is a reply to message #699742] Fri, 22 July 2011 04:50 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Beginner : Xtext help [message #699792 is a reply to message #699749] Fri, 22 July 2011 06:13 Go to previous message
Eclipse UserFriend
Thanks Christian!. Issue solved.
Previous Topic:Combining data structure with a markup format
Next Topic:getting started with xdoc
Goto Forum:
  


Current Time: Sun Jul 20 04:19:31 EDT 2025

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

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

Back to the top