Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] ANTLR options
[Xtext] ANTLR options [message #57438] Mon, 13 July 2009 09:48 Go to next message
Mounir Stino is currently offline Mounir StinoFriend
Messages: 3
Registered: July 2009
Junior Member
Hi,

I am migrating a project from oAW Xtext to TMF Xtext. My grammar has non
LL(*) decisions, and this problem was solved by the backtrack=true option
that was always set in the generated ANTLR file in oAW Xtext. TMF Xtext
however does not set this option by default. Is there a way to set this
option manually?

Thanks
Re: [Xtext] ANTLR options [message #57465 is a reply to message #57438] Mon, 13 July 2009 10:28 Go to previous messageGo to next message
Eclipse UserFriend
You need the following entry in your mwe file :

<language uri="${grammarURI}" fileExtensions="${file.extensions}">
<fragment class="de.itemis.xtext.antlr.XtextAntlrGeneratorFragment">
<options backtrack="true" memoize="true" k="-1"/>
</fragment>
....
Re: [Xtext] ANTLR options [message #57491 is a reply to message #57465] Mon, 13 July 2009 11:17 Go to previous messageGo to next message
Mounir Stino is currently offline Mounir StinoFriend
Messages: 3
Registered: July 2009
Junior Member
Thanks Aleksey for your reply, but it is unfortunately still not working.
I put the fragment in the mwe file, and the file looks like:

<workflow>
...
<component class="org.eclipse.xtext.generator.Generator">
<pathRtProject value="${runtimeProject}"/>
<pathUiProject value="${runtimeProject}.ui"/>
<projectNameRt value="${projectName}"/>
<projectNameUi value="${projectName}.ui"/>

<language uri="${grammarURI}" fileExtensions="${file.extensions}">
<!-- imposes the backtrack and memoize options in the generated ANTLR
file -->
<fragment class="de.itemis.xtext.antlr.XtextAntlrGeneratorFragment">
<options backtrack="true" memoize="true" k="-1"/>
</fragment>
...
</component>
</workflow>

It does not have any effect on the ANTLR generated files.

Thanks again.
Re: [Xtext] ANTLR options [message #57515 is a reply to message #57491] Mon, 13 July 2009 11:40 Go to previous messageGo to next message
Knut Wannheden is currently offline Knut WannhedenFriend
Messages: 298
Registered: July 2009
Senior Member
Note that Xtext by default also generates an ANTLR grammar into the UI
project (used for content assist). Possibly the warnings you see in your
console pertain to that grammar. If that's the case you can also set the
backtrack option for your UI project. Replace the second
"org.eclipse.xtext.generator.DelegatingGeneratorFragment" fragment with:

<fragment class="de.itemis.xtext.antlr.XtextAntlrUiGeneratorFragment"/ >
<options backtrack="true" memoize="true"/>
</fragment>

Regards,

--knut

Mounir Stino wrote:
> Thanks Aleksey for your reply, but it is unfortunately still not
> working. I put the fragment in the mwe file, and the file looks like:
>
> <workflow>
> ..
> <component class="org.eclipse.xtext.generator.Generator">
> <pathRtProject value="${runtimeProject}"/>
> <pathUiProject value="${runtimeProject}.ui"/>
> <projectNameRt value="${projectName}"/>
> <projectNameUi value="${projectName}.ui"/>
>
> <language uri="${grammarURI}" fileExtensions="${file.extensions}">
> <!-- imposes the backtrack and memoize options in the
> generated ANTLR file -->
> <fragment
> class="de.itemis.xtext.antlr.XtextAntlrGeneratorFragment">
> <options backtrack="true" memoize="true" k="-1"/>
> </fragment>
> ..
> </component>
> </workflow>
>
> It does not have any effect on the ANTLR generated files.
>
> Thanks again.
>
Re: [Xtext] ANTLR options [message #58399 is a reply to message #57515] Tue, 14 July 2009 12:57 Go to previous messageGo to next message
Mounir Stino is currently offline Mounir StinoFriend
Messages: 3
Registered: July 2009
Junior Member
I managed to make the parser files work, but now I need the same options
for the ANTLR lexer files in both the standard and ui projects. Is there a
way to do it?

Thanks again.
Re: [Xtext] ANTLR options [message #58418 is a reply to message #58399] Tue, 14 July 2009 14:16 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Mounir,

I'm afraid this is not possible at the moment. Have a look at this
bugreport from antlr:
http://www.antlr.org/jira/browse/ANTLR-321

If it is necessary to define lexer options you'll have to implement your
own generator fragment and define both a lexer and a parser grammar.
Feel free to file bugzilla :-)

Regards,
Sebastian

Am 14.07.2009 14:57 Uhr, schrieb Mounir Stino:
> I managed to make the parser files work, but now I need the same options
> for the ANTLR lexer files in both the standard and ui projects. Is there
> a way to do it?
>
> Thanks again.
>
Previous Topic:[xText] Pulling up features into common super class
Next Topic:using xtext editors in a Rich Client
Goto Forum:
  


Current Time: Sat Dec 21 16:40:23 GMT 2024

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

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

Back to the top