Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » keywords and terminals(content assist is not working with terminal but it works with keywords)
keywords and terminals [message #1552336] Thu, 08 January 2015 04:22 Go to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi guys,

I am new using Xtext so I am sure that the following question could be answered using some basic concepts.

I have one simple Grammar where the first character is "(" so the content assist suggest me to introduce that but when I changed "(" to be a terminal in my grammar the content assist does not suggest me anything.

Grammar 1:

grammar org.testing.xpp.XPP with org.eclipse.xtext.common.Terminals

generate xPP "htt://www.testing.org/xpp/XPP"

Model:
inicial="("
greetings+=Greeting*
fin=")";

Greeting:
'Hello' name=ID '!';

Grammar 2:
grammar org.testing.xpp.XPP with org.eclipse.xtext.common.Terminals

generate xPP "htt://www.testing.org/xpp/XPP"

Model:
inicial=A
greetings+=Greeting*
fin=B;

Greeting:
'Hello' name=ID '!';

terminal A:"(";
terminal B:")";

As far as I understand in the first grammar the "(" is handled as a keyword which are processed before local terminals maybe this is affecting the content assist but I am not able to figure out the reason of this.

Also I have noticed that in the first grammar the "Xtext Syntax Graph" view show me the "(" using a white background but in the second case this is shown in a different color, do you have any idea about what that means?

I hope someone can bring me some lights on this
Thanks in advance

Luis
Re: keywords and terminals [message #1553061 is a reply to message #1552336] Thu, 08 January 2015 13:27 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
It is not a good idea to use terminals for keywords / punctuation (one
reason you already have discovered - it does not provide automatic code
completion. The reason for this is that a terminal is something like a
number or a string, and the system cannot provide automatic suggestions
for such values. You can write a provider though. For punctuation that
is just too much work.

The lexing that takes place checks if a terminal is the same as that of
a keyword, if so, the keyword token is emitted, else the terminal.

You should strive to have as few terminals as possible since you
otherwise risk creating overlapping definitions and those cause a lot of
headache and unreliable result. I.e. you should have very good reasons
for deviating from the handful of terminals provided by the default grammar.

Hope that helps
- henrik

On 2015-08-01 14:05, Luis De Bello wrote:
> Hi guys,
>
> I am new using Xtext so I am sure that the following question could be
> answered using some basic concepts.
>
> I have one simple Grammar where the first character is "(" so the
> content assist suggest me to introduce that but when I changed "(" to be
> a terminal in my grammar the content assist does not suggest me anything.
>
> Grammar 1:
>
> grammar org.testing.xpp.XPP with org.eclipse.xtext.common.Terminals
>
> generate xPP "htt://www.testing.org/xpp/XPP"
>
> Model:
> inicial="("
> greetings+=Greeting*
> fin=")";
>
> Greeting:
> 'Hello' name=ID '!';
>
> Grammar 2:
> grammar org.testing.xpp.XPP with org.eclipse.xtext.common.Terminals
>
> generate xPP "htt://www.testing.org/xpp/XPP"
>
> Model:
> inicial=A
> greetings+=Greeting*
> fin=B;
>
> Greeting:
> 'Hello' name=ID '!';
>
> terminal A:"(";
> terminal B:")";
>
> As far as I understand in the first grammar the "(" is handled as a
> keyword which are processed before local terminals maybe this is
> affecting the content assist but I am not able to figure out the reason
> of this.
>
> Also I have noticed that in the first grammar the "Xtext Syntax Graph"
> view show me the "(" using a white background but in the second case
> this is shown in a different color, do you have any idea about what that
> means?
>
> I hope someone can bring me some lights on this
> Thanks in advance
>
> Luis
Re: keywords and terminals [message #1553086 is a reply to message #1553061] Thu, 08 January 2015 13:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
regarding the content assist: for all but the default terminal and for datatype rule you have to provide content assist through overriding the proposalproviders corresponding method.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: keywords and terminals [message #1553122 is a reply to message #1553086] Thu, 08 January 2015 14:06 Go to previous message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi guys,

Thanks for the explanation and for the tips.

Regards,
- Luis
Previous Topic:JUnit-Tests for cuscom LinkingService
Next Topic:Xbase: type computation of switch's case expressions
Goto Forum:
  


Current Time: Fri Apr 26 00:24:57 GMT 2024

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

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

Back to the top