[antlr-interest] Composite grammar support in antlr4.0ea

Dave Thomas opensource at peoplemerge.com
Sun Jan 1 20:21:36 PST 2012


With all this exciting Honey Badger activity (which is just crazy and
doesn't give a shit), I thought I'd bump this "Redefinition of header
action" thread and attach a minimal tarball with code for your convenience!

I get the same result with antlr-4.0ea (as I did with 3.4 nicely mavenized)
by running:
cd src/main/antlr3; java  -cp
/path/to/antlr-4.0ea-complete.jar:/path/to/ST-4.0.4.jar org.antlr.Tool
test/*.g -o ../../../target
error(144): JavaDecl.g:3:2: redefinition of header action


On Tue, Nov 22, 2011 at 9:07 PM, Dave Thomas <opensource at peoplemerge.com>wrote:

> Hi all,
>
> I'm using ANTLR for my masters thesis, which includes letting user extend
> the lex and parser grammars I supply with their own jargon in the form of a
> combined grammar.  I wouldn't have dreamed it possible before ANTLR, and
> I'm a big fan!
>
> The problem I'm having is:
> error(144): JavaDecl.g:3:2: redefinition of header action
>
> The reason this is making me scratch my head is that I see this issue has
> been reported, and AFAICT addressed:
> http://www.antlr.org/jira/browse/ANTLR-301
> http://www.antlr.org/jira/browse/ANTLR-370
>  http://www.antlr.org/jira/browse/ANTLR-375
> http://www.antlr.org/pipermail/antlr-interest/2011-January/040487.html
> http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars (basis for
> the examples; sorry for the cross-post)
>
> Am I specifying the antlr release wrong in the maven plugin?
>
> Should I be concerned that my dependency hierarchy includes antlr 2.7.7?
>  Per http://www.antlr.org/wiki/display/ANTLR3/ANTLR+3.4+Release+Notes the
> dependency on v2 should be removed, but I still see it when I do `mvn clean
> antlr3:antlr compile -X`:
>
> [DEBUG]    org.antlr:antlr:jar:3.4:compile
> [DEBUG]       org.antlr:antlr-runtime:jar:3.4:compile
> [DEBUG]          org.antlr:stringtemplate:jar:3.2.1:compile
> [DEBUG]          antlr:antlr:jar:2.7.7:compile
>
>
> src/main/antlr3/test/JLex.g
>
> lexer grammar JLex;
> @lexer::header { package test; }
>
> INT : 'int';
> SEMICOLON : ';';
> EQUALS : '=';
> ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
>
>
> src/main/antlr3/test/JavaDecl.g
>
> parser grammar JavaDecl;
> @header { package test; }
> type : INT ;
> decl : type ID SEMICOLON
>      | type ID init SEMICOLON
>      ;
> init : EQUALS INT ;
>
>
> src/main/antlr3/test/Java.g:
>
> grammar Java;
> import JavaDecl, JLex;
> @header { package test; }
> prog : decl ;
> type : 'int' | 'float' ;
>
> pom.xml:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>  <modelVersion>4.0.0</modelVersion>
> <groupId>test</groupId>
>  <artifactId>test</artifactId>
> <packaging>jar</packaging>
>  <version>1.0-SNAPSHOT</version>
> <name>test</name>
>  <build>
> <plugins>
> <plugin>
>  <groupId>org.antlr</groupId>
> <artifactId>antlr3-maven-plugin</artifactId>
>  <version>3.4</version>
> <executions>
> <execution>
>  <configuration>
> <goals>
> <goal>antlr</goal>
>  </goals>
> </configuration>
> </execution>
>  </executions>
> </plugin>
> </plugins>
>  </build>
> </project>
>
>
>
>
>
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: antlr-header.tar
Type: application/x-tar
Size: 20480 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120101/45fa5b04/attachment.tar 


More information about the antlr-interest mailing list