[antlr-interest] Antlr v3.0ea8 : @header not taken into account in automatically generated lexer java code...

Jim Idle jimi at temporal-wave.com
Tue May 2 06:05:33 PDT 2006


In ANTLR3 the header section is taken to mean you want this in the parser generated code and not the lexer generated code. They are separate directives. You want:
 
@lexer::header {
}
 
To place things in  the lexer explicitly.

Jim

________________________________

From: antlr-interest-bounces at antlr.org on behalf of David CROSSON
Sent: Tue 5/2/2006 2:24 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Antlr v3.0ea8 : @header not taken into account in automatically generated lexer java code...



Hello,

The @header content information, such as package declaration, is included
in the generated grammar java source code but not in the automatically
generated lexer java source code.

// ----------------------------
grammar BeaStackDumpParser;
options {
    filter=true;
    output=AST;
}

@header {
  package stackdumpparser.parsers;
  import stackdumpparser.model.*;
}
... my rules, no lexer declaration ...
// ----------------------------

The following files are generated :
- BeaStackDumpParser.java
- BeaStackDumpParser.lexer.g
- BeaStackDumpParser.tokens
- BeaStackDumpParserLexer.java
- BeaStackDumpParserLexer.token

BeaStackDumpParser.java contains header information but
not the BeaStackDumpParserLexer file.


Any idea ? May be the generated "BeaStackDumpParser.lexer.g"
should include the same header section ?

Best regards,
David Crosson.

ps : thanks Terence, for your response to my previous mail, you were right
I forgot to add the "output=AST;" option to my grammar file.







More information about the antlr-interest mailing list