[antlr-interest] composite grammar fails to generate lexer

Jim Idle jimi at temporal-wave.com
Wed May 27 17:34:22 PDT 2009


What I do is generate the lexer standalone and use vocab import. Then  
your parser is a parser grammar T;

Jim

Sent from my iPhone

On May 26, 2009, at 9:04 PM, T Stotts <timotheus at tstotts.net> wrote:

>
> Hello. I have written a simple composite grammar. Antlr 3.1 fails to
> generate a lexer when the lexer grammar is in its own file; but
> generates a lexer when the grammar is combined into one file. The
> eventual grammar will be very large, so I need to implement it as a
> composite grammar. What do I do? Is this a bug in the software, and  
> why
> does this problem not show up for the antlr v3 examples?
>
> Clarification: by failing to generate a lexer, I do mean that the tool
> fails to create a Vhdl2008Lexer.java file.
>
>
> /*   File Vhdl2008.g  */
> grammar Vhdl2008;
>
> options {
>    language='Java';
> }
>
> import Vhdl2008LexerRules;
>
> entity_declaration :
>    ENTITY Identifier IS
>    END (ENTITY)? (Identifier)? SEMICOLON
>    ;
>
>
> /*   File Vhdl2008LexerRules.g  */
> lexer grammar Vhdl2008LexerRules;
>
> END : ('E'|'e')('N'|'n')('D'|'d') ;
> ENTITY : ('E'|'e')('N'|'n')('T'|'t')('I'|'i')('T'|'t')('Y'|'y') ;
> IS : ('I'|'i')('S'|'s') ;
>
> SEMICOLON : ';';
>
> Identifier : ('A'..'Z'|'a'..'z') ( ('_')?  
> 'A'..'Z'|'a'..'z'|'0'..'9' )*;
>
> WS : (' '|'\t'|'\r'|'\n')+ {$channel=HIDDEN;};
>
>
> -- 
> aka:   timotheus
> web:   http://tstotts.net/
>
> 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