Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How can I define a rule which is each line must have just one type date?
How can I define a rule which is each line must have just one type date? [message #714302] Wed, 10 August 2011 09:27 Go to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Hi

i hope you can give me some idea.I have some sort of type in my Model such as

LibModel:
  (types+=Type)*;            

Type:
  TypeA|TypeB|TypeAB| TypeC;




Is it possible to allow just one type for each line?

BR
caner
Re: How can I define a rule which is each line must have just one type date? [message #714303 is a reply to message #714302] Wed, 10 August 2011 09:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
Hi,

what about simply

LibModel hidden(Stuff but not NEWLINE):
(types+=Type NEWLINE)*;


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
(no subject) [message #714410 is a reply to message #714302] Wed, 10 August 2011 13:11 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
The best is to handle this in validation - simply check that there is
one or more hidden nodes with a newline (or end of file) between your
types. This will cause you the least problems and keeps the grammar clean.

You also want to add suitable rules to the formatter.

- henrik
On 8/10/11 11:27 AM, Caner wrote:
> Hi
>
> i hope you can give me some idea.I have some sort of type in my Model
> such as
>
> LibModel:
> (types+=Type)*;
> Type:
> TypeA|TypeB|TypeAB| TypeC;
>
>
>
>
> Is it possible to allow just one type for each line?
>
> BR caner
Re: How can I define a rule which is each line must have just one type date? [message #714624 is a reply to message #714303] Thu, 11 August 2011 06:36 Go to previous messageGo to next message
Caner Friend
Messages: 98
Registered: July 2011
Member
Hi Christian

When If I have WS rule and NL, they make conflict
I tried to make a changed on WS like this

LibModel hidden(myWhiteSpace ):
(types+=Type NEWLINE)*;
terminal myWhiteSpace : (' '|'\t')+
terminal NEWLINE: '\r'?'\n';

this didnt work ither, its looking for NewLIne rule is missing, and not allow me leave empty lines

BR
Caner

[Updated on: Thu, 11 August 2011 06:36]

Report message to a moderator

Re: How can I define a rule which is each line must have just one type date? [message #714626 is a reply to message #714624] Thu, 11 August 2011 06:38 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
Hi,

then allow damn empty lines or do a check as hendrik proposed.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Creating Xtext project based on file name not file extension
Next Topic:XText 2.0 --- Hover Documentation
Goto Forum:
  


Current Time: Sat Apr 17 00:25:28 GMT 2021

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

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

Back to the top