[Xtext] ANTLR options [message #57438] |
Mon, 13 July 2009 05:48  |
Eclipse User |
|
|
|
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 06:28   |
Eclipse User |
|
|
|
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 07:17   |
Eclipse User |
|
|
|
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 07:40   |
Eclipse User |
|
|
|
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 08:57   |
Eclipse User |
|
|
|
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 10:16  |
Eclipse User |
|
|
|
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.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03334 seconds