[antlr-interest] Lexer code missing @header info

Bart Kiers bkiers at gmail.com
Fri May 13 06:15:52 PDT 2011


Hi David,

The snippet:

@header {
package parser;
import java.util.HashMap;
}


is short for:

@parser::header {
package parser;
import java.util.HashMap;
}


You'll need to do the following as well:

@lexer::header {
package parser;
import java.util.HashMap;
}



Regards,

Bart.


On Fri, May 13, 2011 at 3:08 PM, David Smith <david.smith at cc.gatech.edu>wrote:

> I'm using ANTLRWorks to generate java code form a grammar with the
> front-end listed below.  The code generation works flawlessly
> producing XXXLexer.java and XXXParser.java as expected with one minor
> annoyance.  The "package parser;" line makes it into XXXParser.java,
> but not into XXXLexer.java.  I therefore have to manually edit
> XXXLexer.java.  Not really a big issue, but is there an easy cure?
>
> ______________________
> grammar XXX;
> options {
>     output=AST;
>     ASTLabelType=CommonTree;
> }
> tokens{ STATLIST; }
>
> @header {
> package parser;
> import java.util.HashMap;
> }
>
>
>
> David M. Smith http://www.cc.gatech.edu/fac/David.Smith
> Georgia Institute of Technology, College of Computing
> Sent from my ASR-33 Teletype
>
>
> 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