Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » simplified grammar for autocompletion
simplified grammar for autocompletion [message #878704] Tue, 29 May 2012 19:17 Go to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 431
Registered: July 2009
Location: Gothenburg
Senior Member
Hi!

I am fighting with my language and it's harder than I think it should be. I just realized that because the source will be fed to a full compiler anyway, the Xtext grammar doesn't have to get everything right, maybe. While writing this message, I have second thoughts Smile

I thought I could ignore operator precedence and similar things that make the grammar more complex while not giving any useful information for the IDE services. There is already a simplified grammar generated for the completion service.

But then the serialization/formatting came to mind, and then even the quickfixes: I think these would need a full grammar anyway, in order to get all the details right...

Does anyone have any comments on this idea?

best regards,
Vlad
Re: simplified grammar for autocompletion [message #878720 is a reply to message #878704] Tue, 29 May 2012 19:47 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Vlad,

the content assist grammar is not simplified at all. It's a lot more
complicated than the production grammar that Xtext uses just in order to
'convince' antlr to produce the right output / events that are intercepted.

I can only recommend to use a grammar that mirrors the precedencies of
your language. Otherwise you'll end up with a big mess when it comes to
the outline view, code folding, error recovery in the parser, content
assist, scoping ... well you get the idea.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 29.05.12 21:17, schrieb Vlad Dumitrescu:
> Hi!
>
> I am fighting with my language and it's harder than I think it should
> be. I just realized that because the source will be fed to a full
> compiler anyway, the Xtext grammar doesn't have to get everything right,
> maybe. While writing this message, I have second thoughts :)
>
> I thought I could ignore operator precedence and similar things that
> make the grammar more complex while not giving any useful information
> for the IDE services. There is already a simplified grammar generated
> for the completion service.
> But then the serialization/formatting came to mind, and then even the
> quickfixes: I think these would need a full grammar anyway, in order to
> get all the details right...
>
> Does anyone have any comments on this idea?
> best regards,
> Vlad
>
Re: simplified grammar for autocompletion [message #878749 is a reply to message #878720] Tue, 29 May 2012 21:28 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 431
Registered: July 2009
Location: Gothenburg
Senior Member
Thanks for the clarification, Sebastian, I had it all wrong!

I'll fight my way with the LinkingService, then... Please expect exasperated questions in the near future Very Happy

BTW there's an inconsistency in the documentation: ILinkingService#getLinkedObjects says
"Returns all {@link EObject}s referenced by the given link text in the given context."
while DefaultLinkingService#getLinkedObjects says
"@return the first element returned from the injected {@link IScopeProvider} which matches the text of the passed {@link INode node}"

Which one is right? What is the meaning of returning multiple objects?

Thanks,
Vlad
Re: simplified grammar for autocompletion [message #878767 is a reply to message #878749] Tue, 29 May 2012 22:24 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-29-05 23:28, Vlad Dumitrescu wrote:
> Thanks for the clarification, Sebastian, I had it all wrong!
>
> I'll fight my way with the LinkingService, then... Please expect
> exasperated questions in the near future :d
>
> BTW there's an inconsistency in the documentation:
> ILinkingService#getLinkedObjects says "Returns all {@link EObject}s
> referenced by the given link text in the given context." while
> DefaultLinkingService#getLinkedObjects says
> "@return the first element returned from the injected {@link
> IScopeProvider} which matches the text of the passed {@link INode node}"
>
> Which one is right? What is the meaning of returning multiple objects?
> Thanks,
> Vlad
>
I can imagine that you would want to be able to pick "the best" in case
there are several matching objects. By name alone the result could be
ambiguous, and the default implementation simply picks the first, but
some other implementation may do something more advanced.

(I am not an expert though).

- henrik
Re: simplified grammar for autocompletion [message #878914 is a reply to message #878767] Wed, 30 May 2012 07:34 Go to previous message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 431
Registered: July 2009
Location: Gothenburg
Senior Member
Hi Henrik,

Where would I do that picking? Since I have my own LinkingService, I can select the right object there and return it. I didn't look further, to which services use this result and what they do with it.

It could also be a form of poor-man's Option monad, so that results from multiple linking services may be put together without caring for null (which would otherwise be returned when no match is found).

regards,
Vlad
Previous Topic:Out of memory during full build
Next Topic:Xtext & EAnnotation
Goto Forum:
  


Current Time: Fri Mar 29 05:53:03 GMT 2024

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

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

Back to the top