Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Invoking antlr - path to grammar files
Invoking antlr - path to grammar files [message #58904] Wed, 15 July 2009 09:11 Go to next message
Christoph Kulla is currently offline Christoph KullaFriend
Messages: 48
Registered: July 2009
Member
Hi,

I'm trying to build my xtext projects with maven (with fornax). This works
fine with a flat directory layout. But when trying to setup the projects
in a hierarchy things get worse.

I guess the reason is that the current working directory stays by the
parent directory during the build and gets not changed when maven walks
down to the child projects. As far as I see xtext expects the current
directory to be the xtext project directory when running the workflow.

I've adjusted the platform uri in the workflow and played around with the
pathRtProject setting and projecNameRt. Now the code generation works
fine. But invoking antlr fails as the path to the grammar files is wrong:

3922 [main] INFO ipse.xtext.generator.LanguageConfig - generating
infrastructure for org.eclipse.vis.blockdiagram.metamodel.BlockDiagram
with fragments : ImplicitRuntimeFragment, ImplicitUiFragment,
GrammarAccessFragment, EcoreGeneratorFragment,
ParseTreeConstructorFragment, Resour
error(7): cannot find or open file:
../blockdiagram.metamodel/src/generated/java/org/eclipse/vis /blockdiagram/metamodel/parser/antlr/internal/InternalBlockD iagram.g
7985 [main] INFO or.validation.JavaValidatorFragment - executing
generate for org.eclipse.xtext.generator.validation.JavaValidatorFragment
error(7): cannot find or open file:
../blockdiagram.metamodel.ui/src/generated/java/org/eclipse/ vis/blockdiagram/metamodel/contentassist/antlr/internal/Inte rnalBlockDiagram.g
8657 [main] DEBUG enerator.CompositeGeneratorFragment - replacing binding
: org.eclipse.jface.text.rules.ITokenScanner ->
org.eclipse.xtext.ui.common.editor.syntaxcoloring.DefaultTok enScanner
(contributed by org.eclipse.xtext.ui.generator.ImplicitUiFragment)
8657 [main] DEBUG enerator.CompositeGeneratorFragment - with new binding
: org.eclipse.jface.text.rules.ITokenScanner ->
org.eclipse.xtext.ui.common.editor.syntaxcoloring.antlr.Antl rTokenScanner
(contributed by de.itemis.xtext.antlr.XtextAntlrGeneratorFragment)

Instead of "../blockdiagram.metamodel/" it needs to be platformUri +
"../blockdiagram.metamodel/"

How do I achieve this? Unfortunately I could not find the source of
de.itemis.xtext.antlr plugin to look at the code.

Regards

Christoph

The workflow setup is:

<workflow>
<property
file=" org/eclipse/vis/blockdiagram/metamodel/GenerateBlockDiagram. properties "/>

<!-- ${basedir} comes from maven -->
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup"
platformUri="${basedir}/.."/>

<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner"
directory="${basedir}/src/generated"/>
<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner"
directory="${basedir}.ui/src/generated"/>

<component class="org.eclipse.xtext.generator.Generator">
<pathRtProject value="../${projectName}"/>
<pathUiProject value="../${projectName}.ui"/>
<projectNameRt value="${projectName}"/>
<projectNameUi value="${projectName}.ui"/>
<mergeManifest value="false"/>
<srcPath value="/src/main/java"/>
<srcGenPath value="/src/generated/java"/>
Re: Invoking antlr - path to grammar files [message #58979 is a reply to message #58904] Wed, 15 July 2009 09:50 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Christoph,

you can find the sourcecode for the antlr stuff at sourceforge:
http://architecturware.cvs.sourceforge.net/viewvc/architectu rware/xtext_external/

At a first glance, the code looks fine. On the other hand, your mwe file
looks fine, too. If you experience a bug in the generator, please don't
hesitate to file a ticket.

Btw: Please file a bugzilla for the missing sources of the antlr-stuff.

Regards,
Sebastian


Am 15.07.2009 11:11 Uhr, schrieb Christoph Kulla:
> Hi,
>
> I'm trying to build my xtext projects with maven (with fornax). This
> works fine with a flat directory layout. But when trying to setup the
> projects in a hierarchy things get worse.
> I guess the reason is that the current working directory stays by the
> parent directory during the build and gets not changed when maven walks
> down to the child projects. As far as I see xtext expects the current
> directory to be the xtext project directory when running the workflow.
>
> I've adjusted the platform uri in the workflow and played around with
> the pathRtProject setting and projecNameRt. Now the code generation
> works fine. But invoking antlr fails as the path to the grammar files is
> wrong:
>
> 3922 [main] INFO ipse.xtext.generator.LanguageConfig - generating
> infrastructure for org.eclipse.vis.blockdiagram.metamodel.BlockDiagram
> with fragments : ImplicitRuntimeFragment, ImplicitUiFragment,
> GrammarAccessFragment, EcoreGeneratorFragment,
> ParseTreeConstructorFragment, Resour
> error(7): cannot find or open file:
> ../blockdiagram.metamodel/src/generated/java/org/eclipse/vis /blockdiagram/metamodel/parser/antlr/internal/InternalBlockD iagram.g
>
> 7985 [main] INFO or.validation.JavaValidatorFragment - executing
> generate for org.eclipse.xtext.generator.validation.JavaValidatorFragment
> error(7): cannot find or open file:
> ../blockdiagram.metamodel.ui/src/generated/java/org/eclipse/ vis/blockdiagram/metamodel/contentassist/antlr/internal/Inte rnalBlockDiagram.g
>
> 8657 [main] DEBUG enerator.CompositeGeneratorFragment - replacing
> binding : org.eclipse.jface.text.rules.ITokenScanner ->
> org.eclipse.xtext.ui.common.editor.syntaxcoloring.DefaultTok enScanner
> (contributed by org.eclipse.xtext.ui.generator.ImplicitUiFragment)
> 8657 [main] DEBUG enerator.CompositeGeneratorFragment - with new binding
> : org.eclipse.jface.text.rules.ITokenScanner ->
> org.eclipse.xtext.ui.common.editor.syntaxcoloring.antlr.Antl rTokenScanner (contributed
> by de.itemis.xtext.antlr.XtextAntlrGeneratorFragment)
>
> Instead of "../blockdiagram.metamodel/" it needs to be platformUri +
> "../blockdiagram.metamodel/"
> How do I achieve this? Unfortunately I could not find the source of
> de.itemis.xtext.antlr plugin to look at the code.
>
> Regards
>
> Christoph
>
> The workflow setup is:
>
> <workflow>
> <property
> file=" org/eclipse/vis/blockdiagram/metamodel/GenerateBlockDiagram. properties "/>
>
>
> <!-- ${basedir} comes from maven -->
> <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup"
> platformUri="${basedir}/.."/>
>
> <component class="org.eclipse.emf.mwe.utils.DirectoryCleaner"
> directory="${basedir}/src/generated"/>
> <component class="org.eclipse.emf.mwe.utils.DirectoryCleaner"
> directory="${basedir}.ui/src/generated"/>
> <component class="org.eclipse.xtext.generator.Generator">
> <pathRtProject value="../${projectName}"/>
> <pathUiProject value="../${projectName}.ui"/>
> <projectNameRt value="${projectName}"/>
> <projectNameUi value="${projectName}.ui"/> <mergeManifest value="false"/>
> <srcPath value="/src/main/java"/>
> <srcGenPath value="/src/generated/java"/>
>
Re: Invoking antlr - path to grammar files [message #59223 is a reply to message #58979] Wed, 15 July 2009 13:58 Go to previous messageGo to next message
Christoph Kulla is currently offline Christoph KullaFriend
Messages: 48
Registered: July 2009
Member
Hi,

I've patched the AntlrToolRunner class to get the canonical path for the
grammar file and pass it to antlr. Now everything works as expected. Looks
like antlr has a problem with relative file names (at least on my machine
here). I will file a bug and provide a patch for this issue.

Regards

Christoph
Re: Invoking antlr - path to grammar files [message #59247 is a reply to message #59223] Wed, 15 July 2009 14:16 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Thanks for your effort. I'm looking forward to the patch.

Regards,
Sebastian

Am 15.07.2009 15:58 Uhr, schrieb Christoph Kulla:
> Hi,
>
> I've patched the AntlrToolRunner class to get the canonical path for the
> grammar file and pass it to antlr. Now everything works as expected.
> Looks like antlr has a problem with relative file names (at least on my
> machine here). I will file a bug and provide a patch for this issue.
>
> Regards
>
> Christoph
>
Previous Topic:Grammars without 'with' generate errors
Next Topic:Serialize a single element to a String
Goto Forum:
  


Current Time: Sun Jul 07 07:44:44 GMT 2024

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

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

Back to the top