You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Alex Eagle <ea...@post.harvard.edu> on 2009/08/21 07:49:56 UTC

Version of Antlr in buildr/antlr

Hi there,
I've just started using Buildr on a project, and so far I'm glad to dispense
with all that XML in Maven. A couple n00b questions:

It seems that my Antlr grammar is being compiled with the wrong version of
Antlr.
1) How can I tell the classpath being used for the JVM that's running the
antlr.Tool#process method? I'd like to confirm it's the older version (pre
3.1). My evidence so far is that new features like tree grammar and token
declarations with the literal value aren't working.

I tried hacking the classpath, based on an example I found [1], like so:
 ANTLR = ["org.antlr:antlr:jar:3.1.1", "org.antlr:stringtemplate:jar:3.2"]
 Buildr::ANTLR::REQUIRES = ANTLR
 Java.classpath.unshift ANTLR
This doesn't seem to be working either.

[1]
http://www.google.com/codesearch/p?hl=en&sa=N&cd=3&ct=rc#Ev3aWwXNqH4/Rakefile&q=buildr/antlr&l=44

2) When I change the grammar, the code generation doesn't seem to happen. I
have to do a clean build to force the antlr generation to happen again. This
seems like a bug in the way the Rake task is created? I'm running it like
this:
  antlr = antlr(_('src/main/antlr'), :in_package=>'noop.grammar')

  compile.from antlr
  compile.with ANTLR

Thanks in advance
-Alex

Re: Version of Antlr in buildr/antlr

Posted by Matthieu Riou <ma...@gmail.com>.
On Fri, Aug 21, 2009 at 8:15 AM, Alex Boisvert <al...@gmail.com>wrote:

> On Thu, Aug 20, 2009 at 10:49 PM, Alex Eagle <ea...@post.harvard.edu>
> wrote:
>
> > Hi there,
> > I've just started using Buildr on a project, and so far I'm glad to
> > dispense
> > with all that XML in Maven. A couple n00b questions:
> >
> > It seems that my Antlr grammar is being compiled with the wrong version
> of
> > Antlr.
> > 1) How can I tell the classpath being used for the JVM that's running the
> > antlr.Tool#process method? I'd like to confirm it's the older version
> (pre
> > 3.1). My evidence so far is that new features like tree grammar and token
> > declarations with the literal value aren't working.
> >
> > I tried hacking the classpath, based on an example I found [1], like so:
> >  ANTLR = ["org.antlr:antlr:jar:3.1.1",
> "org.antlr:stringtemplate:jar:3.2"]
> >  Buildr::ANTLR::REQUIRES = ANTLR
> >  Java.classpath.unshift ANTLR
> > This doesn't seem to be working either.
>
>
> Because of the way RJB works, you have to initialize these constants pretty
> early in your Buildfile to avoid the classspath being initialized with the
> default values.     Did you add these lines towards the top of your
> Buildfile?
>

There's an example here:

http://github.com/intalio/simpel/blob/master/Rakefile

Matthieu


>
> 2) When I change the grammar, the code generation doesn't seem to happen. I
> > have to do a clean build to force the antlr generation to happen again.
> > This
> > seems like a bug in the way the Rake task is created? I'm running it like
> > this:
> >  antlr = antlr(_('src/main/antlr'), :in_package=>'noop.grammar')
> >
> >  compile.from antlr
> >  compile.with ANTLR
>
>
> I believe you have to point to specific files instead of the directory.
>
> You could try:
>
>  antlr = antlr(Dir[_('src/main/antlr'+'/*.g']),
> :in_package=>'noop.grammar')
>
> alex
>

Re: Version of Antlr in buildr/antlr

Posted by Alex Boisvert <al...@gmail.com>.
On Thu, Aug 20, 2009 at 10:49 PM, Alex Eagle <ea...@post.harvard.edu> wrote:

> Hi there,
> I've just started using Buildr on a project, and so far I'm glad to
> dispense
> with all that XML in Maven. A couple n00b questions:
>
> It seems that my Antlr grammar is being compiled with the wrong version of
> Antlr.
> 1) How can I tell the classpath being used for the JVM that's running the
> antlr.Tool#process method? I'd like to confirm it's the older version (pre
> 3.1). My evidence so far is that new features like tree grammar and token
> declarations with the literal value aren't working.
>
> I tried hacking the classpath, based on an example I found [1], like so:
>  ANTLR = ["org.antlr:antlr:jar:3.1.1", "org.antlr:stringtemplate:jar:3.2"]
>  Buildr::ANTLR::REQUIRES = ANTLR
>  Java.classpath.unshift ANTLR
> This doesn't seem to be working either.


Because of the way RJB works, you have to initialize these constants pretty
early in your Buildfile to avoid the classspath being initialized with the
default values.     Did you add these lines towards the top of your
Buildfile?

2) When I change the grammar, the code generation doesn't seem to happen. I
> have to do a clean build to force the antlr generation to happen again.
> This
> seems like a bug in the way the Rake task is created? I'm running it like
> this:
>  antlr = antlr(_('src/main/antlr'), :in_package=>'noop.grammar')
>
>  compile.from antlr
>  compile.with ANTLR


I believe you have to point to specific files instead of the directory.

You could try:

 antlr = antlr(Dir[_('src/main/antlr'+'/*.g']), :in_package=>'noop.grammar')

alex