Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Unordered Groups & Custom Checks
Unordered Groups & Custom Checks [message #1004176] Tue, 22 January 2013 18:34 Go to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Hi,

I've tried out the Custom Checks today and it works mostly, but I've got one problem with the boolean assignment operator (=?).
What I want to do is to define a grammar where some elements can be used only one time.
Because of that I've created the following Unordred Group:

Element:
	name=ConfigurationName &
	description?=Description? &
	tool=Tool &
	model=Model &
	interfaces?=Interfaces? &
	paramaters?=Parameters?
;


Then I implemented some custom checks which works so far with ConfigurationName or Model. But it doesn't work with parameters, where I was a little bit curious about it.
So I removed the boolean assignment operator (=?) from parameters and then it works. What's the problem here? Or is there a better way than to use an unordered group.
Re: Unordered Groups & Custom Checks [message #1004178 is a reply to message #1004176] Tue, 22 January 2013 18:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

?= is for booleans, are you sure you are on the right track?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unordered Groups & Custom Checks [message #1004240 is a reply to message #1004178] Tue, 22 January 2013 21:21 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
No, I'm new to Xtext and not sure at all Very Happy
But except the custom-checks it works for me so far. I was just surprised about the behaviour.

Do you have an alternative idea what to use instead of unordered groups?
I just want to define my grammar, so that some elements must be appear exactly one time in a model and other elements can be appear one time. Not sure how to do this.
Re: Unordered Groups & Custom Checks [message #1004266 is a reply to message #1004240] Tue, 22 January 2013 22:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

i was not tasking about unorderd groups. i am taking about ?=
this assingns a booelean attribute,

so can you please post the grammar for Description, Interfaces, Parameters


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unordered Groups & Custom Checks [message #1004281 is a reply to message #1004266] Tue, 22 January 2013 23:03 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
These are my rules:

Description:
   'description:' description=DescriptionValue
;


Interfaces:
	'interfaces' '{'
		(interfacedesc += InterfaceDesc)+
	'}'	
;

InterfaceDesc:
	interfacetype=InterfaceType name=ID datatypeenum=DataTypeEnum demand=InterfaceDemand
;

DataTypeEnum:
	INT8 = 'int8' | INT16 = 'int16' | INT32 = 'int32' |
	UINT8 = 'uint8' | UINT16 = 'uint16' | UINT32 = 'uint32' |
	DOUBLE = 'double' | SINGLE = 'single' | REAL = 'real' |
	BOOLEAN = 'boolean' | CHAR = 'char'
;

enum InterfaceType:
	INLET = 'inlet' |
	OUTLET = 'outlet'
;

enum InterfaceDemand:
	REQUIRE = 'require' |
	OPTIONAL = 'optional'
;


Parameters:
     ParamFile|
     ParamList

ParamFile:
	'paramfile:' paramfilepath=ParamFilePath
;

ParamFilePath:
	(ABSOLUTE_FILEPATH | RELATIVE_FILEPATH)
;

ParamList:
	'parameters' '{'
		parameterdesc += ParameterDesc+
	 '}'
;

ParameterDesc:
	datatype=[DataType] name=ID value=Value
;

Value:
       ((ID)* | (INT)*)
;


thanks so far
Re: Unordered Groups & Custom Checks [message #1004284 is a reply to message #1004281] Tue, 22 January 2013 23:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
So why not interfaces=Interfaces ? Instead of interfaces?=Interfaces

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unordered Groups & Custom Checks [message #1004291 is a reply to message #1004176] Tue, 22 January 2013 23:26 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
That's it! Thank you!!

I took the example about unordered groups from the documentation and didn't thought about this option.
Re: Unordered Groups & Custom Checks [message #1005331 is a reply to message #1004176] Thu, 24 January 2013 22:12 Go to previous message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Sry, it's me again. Is there a handy way to change this error message to a more specific one? I read about ISyntaxErrorMessageProvider, but I'm not really familiar with this.

rule ruleElement failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getElementAccess().getUnorderedGroup())}?
Previous Topic:createReferenceUpdate failed in rename/refactor
Next Topic:Save one file, all files rebuilt?
Goto Forum:
  


Current Time: Fri Apr 19 12:57:35 GMT 2024

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

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

Back to the top