Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Ordered groups question(Question about error)
Ordered groups question [message #755105] Mon, 07 November 2011 12:15 Go to next message
Pascal  is currently offline Pascal Friend
Messages: 8
Registered: October 2011
Junior Member
hi,

(i'm a beginner and) i wrote this grammer:

Button:
  ('text' text = STRING &
   'icon' icon = STRING &
   'action' action = STRING )
;


Now i write with my DSL:
As supposed, the proposal list offers "text","icon" and "action". If i select one, e.g. 'text' with a String "hello", the next proposal list offers the two others ('icon' and 'action').
But when i set the cursor before 'text' "hello", the proposal list offers me the hole group again.
If i write down 'text' "hello2" again, an errors is marked at 'text' "hello": "rule Button failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getAppAccess().getUnorderedGroup_0_0())}?"

I hope you unterstand what i'm doing and so i asked myself: is this a normal behavior and i could override this error with a better ouput or do i something completly wrong?

thanks for help,
best regards,
pascal
Re: Ordered groups question [message #755113 is a reply to message #755105] Mon, 07 November 2011 12:47 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Pascal,

Am 07.11.2011 13:15, schrieb Pascal:
> (i'm a beginner and) i wrote this grammer:
>
>
> Button:
> ('text' text = STRING &
> 'icon' icon = STRING &
> 'action' action = STRING )
> ;

Is this the complete grammar or just an excerpt?

Volker
Re: Ordered groups question [message #755114 is a reply to message #755113] Mon, 07 November 2011 12:57 Go to previous messageGo to next message
Pascal  is currently offline Pascal Friend
Messages: 8
Registered: October 2011
Junior Member
that's just an excerpt, but i think it shows the problem...do you need the hole grammer?
Re: Ordered groups question [message #755120 is a reply to message #755114] Mon, 07 November 2011 13:20 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Am 07.11.2011 13:57, schrieb Pascal:
> that's just an excerpt, but i think it shows the problem...do you need
> the hole grammer?

Yes.
Re: Ordered groups question [message #755121 is a reply to message #755114] Mon, 07 November 2011 13:22 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

think of the out-of-the-box code completion considering only the text up to the current cursor position (the model may well be syntactically invalid as a whole, so there is no point in considering text present after the cursor - something is missing there, otherwise you would not invoke code completion).

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: Ordered groups question [message #755138 is a reply to message #755105] Mon, 07 November 2011 13:49 Go to previous messageGo to next message
Pascal  is currently offline Pascal Friend
Messages: 8
Registered: October 2011
Junior Member
hmmm...

here is the hole grammer, i thougth i would be easier to describe the problem with a snippet...sorry for this.
App:
	attributes += View
;
	
View: 
	{View}
	'view {'
	attributes += (Button | Label)+
	'}'
;
Button:
	{Button}
	'button {'
	('text' text = STRING &
	'toolTip' toolTip = STRING &
	'action' action = STRING)
	'}'
;

Label:
	{Label}
	'label {'
	('text' text = STRING &
	'icon' icon = STRING )
	'}'
;

so the error is now:
"rule ruleButton failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getButtonAccess().getUnorderedGroup_2())}?" when i try it in a button or:
"rule ruleLabel failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getLabelAccess().getUnorderedGroup_2())}?" in a label.

still i don't understand why the autocompletion suggests an group element which is already written down when putting the cursor before an already written group element and then hittong the autocompletion (ctrl+space).
Re: Ordered groups question [message #755154 is a reply to message #755138] Mon, 07 November 2011 14:47 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Am 07.11.2011 14:49, schrieb Pascal:
> App:
> attributes += View
> ;

Are you sure you didn't mean (attributes += View)* here?

> View: {View}
^^^^^^

I might be wrong, but I think this isn't needed in your case.

> 'view {'

You may want to write this as 'view' '{', otherwise the opening bracket
will be highlighted as part of the keyword.

> still i don't understand why the autocompletion suggests an group
> element which is already written down when putting the cursor before an
> already written group element and then hittong the autocompletion
> (ctrl+space).

Because that would be a valid alternative at that point. It might
invalidate the rest of the file, but that's also true for any garbage
the user enters manually. You're free to customize the autocompletion if
you want to change this: http://pastebin.com/raw.php?i=J2QcZtdd (not
sure whether that's the best way to do it, some of the experts may want
to jump on me...)

btw: "hole" != "whole" :-)

Volker
Re: Ordered groups question [message #755638 is a reply to message #755154] Wed, 09 November 2011 07:59 Go to previous message
Pascal  is currently offline Pascal Friend
Messages: 8
Registered: October 2011
Junior Member
okay, i think i understand now.
thanks for the help and the hints!

btw: sorry for my deficient english Smile
Previous Topic:Formatting guides?
Next Topic:Icons in auto completion Window
Goto Forum:
  


Current Time: Thu Apr 18 03:07:40 GMT 2024

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

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

Back to the top