[antlr-interest] Antlr3 in Eclipse and Maven?

Jim Idle jimi at temporal-wave.com
Wed Jun 20 18:39:13 PDT 2012


The wiki instructions are fine and the output you see on the web page is
from maven. However you should really be using 3.4 anyway of course - the
only thing I would change on the wiki page is the version number. BTW -
you don't need to override the default options with the default values -
that is probably something to do with why that version of the plugin did
not work for you. When trying to work out why something is going  wrong,
start with the simplest configuration - don't dive in with the most
complex and then accuse the documentation of being incorrect.

Antlr has nothing to do with the Eclipse editors - the Eclipse editor is
no doubt trying to deal with ANTLR 2.

If you have an undeclared _type variable in your generated lexer in 3.4,
then though it is possible there is a bug in the lexer, I think that it is
more likely that you are trying to do something in the lexer that is
forbidden but is not caught at analysis time - perhaps you are trying to
change token types in a fragment rule or something like that.

We won't be able to tell unless you show the rule that generates the
undeclared _type variable. Declaring a _type variable manually is very
unlikely to be the correct fix. I think that your lexer is just broken.

Jim



-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Brad Cox
Sent: Wednesday, June 20, 2012 8:15 PM
To: Verny Quartara
Cc: ANTLR interest
Subject: Re: [antlr-interest] Antlr3 in Eclipse and Maven?

Thanks! The new version number did the trick. The wiki instructions are
just broken.

And I still don't have a solution to why the grammar statement still isn't
recognized.

That revealed a problem I've seen all along in the generated lexer code...
the _type variable is never declared. Accepting the eclipse quick fix
(declare local variable) clears the problem. But the code generator should
have done this without having to repair it by hand.

Failed to execute goal
> org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
> (default-compile) on project Xacml-Antlr: Compilation failure:
> Compilation
> failure:
> [ERROR]
> /Users/Brad/Dropbox/Xacml-Antlr/target/generated-sources/antlr3/my/Xac
> mlLexer.java:[3239,29]
> cannot find symbol
> [ERROR] symbol  : variable _type
> [ERROR] location: class my.XacmlLexer
> [ERROR]
> /Users/Brad/Dropbox/Xacml-Antlr/target/generated-sources/antlr3/my/Xac
> mlLexer.java:[3246,29]
> cannot find symbol
> [ERROR] symbol  : variable _type
> [ERROR] location: class my.XacmlLexer
> [ERROR]
> /Users/Brad/Dropbox/Xacml-Antlr/target/generated-sources/antlr3/my/Xac
> mlLexer.java:[3314,21]
> cannot find symbol
> [ERROR] symbol  : variable _type
> [ERROR] location: class my.XacmlLexer
> [ERROR]
> /Users/Brad/Dropbox/Xacml-Antlr/target/generated-sources/antlr3/my/Xac
> mlLexer.java:[3403,29]
> cannot find symbol
> [ERROR] symbol  : variable _type
> [ERROR] location: class my.XacmlLexer
> [ERROR]
> /Users/Brad/Dropbox/Xacml-Antlr/target/generated-sources/antlr3/my/Xac
> mlLexer.java:[3412,28]
> cannot find symbol
> [ERROR] symbol  : variable _type
> [ERROR] location: class my.XacmlLexer
> [ERROR]
> /Users/Brad/Dropbox/Xacml-Antlr/target/generated-sources/antlr3/my/Xac
> mlLexer.java:[3419,28]
> cannot find symbol
> [ERROR] symbol  : variable _type
> [ERROR] location: class my.XacmlLexer


On Wed, Jun 20, 2012 at 8:06 AM, Verny Quartara <webny23 at gmail.com> wrote:

> I post my working configuration, hoping that helps.
> My grammar compiles fine in both AntlrWorks and Maven.
> I putted my .g files in src/main/antlr3 and the gunit tests in
> src/test/gunit.
>
> Bye
>
> <plugin>
>                 <groupId>org.antlr</groupId>
>                 <artifactId>antlr3-maven-plugin</artifactId>
>                 <version>3.4</version>
>                 <executions>
>                     <execution>
>                         <goals>
>                             <goal>antlr</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>             </plugin>
>             <plugin>
>                 <groupId>org.antlr</groupId>
>                 <artifactId>maven-gunit-plugin</artifactId>
>                 <version>3.4</version>
>                 <executions>
>                     <execution>
>                         <id>maven-gunit-plugin</id>
>                         <phase>generate-test-sources</phase>
>                         <goals>
>                             <goal>gunit</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>             </plugin>
>
>
> 2012/6/20 Brad Cox <bradjcox at gmail.com>
>
>>  I've an antlr3 grammar that compiles fine in AntlrWorks. I'm trying
>> to load it into Eclipse with Maven to start work on the non-grammar
>> bits.
>>
>> Problem is it won't compile in either. Error flags are on the first
>> line, grammar ...;, and nothing I've tried will remove them. Somehow
>> antlr2 is getting involved in the compile step.
>>
>> The dependency list shows antlr-runtime-3.2.jar and
>> stringtemplate-3.2.jar now. Previously there was an antlr2 jar that
I've explicitly excluded.
>> Didn't make a difference.
>>
>> My best guess is that the antlr3 maven plugin is launching antlr2,
>> not antlr3, but I have no visibility into what that plugin is doing.
>>
>> <groupId>org.antlr</groupId>
>> <artifactId>antlr3-maven-plugin</artifactId>
>> <version>3.1.3-1</version
>>
>> There's also likely confusion over which eclipse plugin I should be
using.
>> After some searching I removed everything but the one from certiv,
>> but no joy.
>>
>> Could someone point me to a known-to-work reference? Thanks!
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-addres
>> s
>>
>
>
>
> --
> Verny Quartara
>
>


--
Cell: 703-594-1883
Blog: http://bradjcox.blogspot.com
Web: http://virtualschool.edu
Manassas VA 20111

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list