[antlr-interest] How to specify lexer options without composite grammars

Gavin Lambert antlr at mirality.co.nz
Mon Jun 16 12:48:58 PDT 2008


At 07:16 17/06/2008, Achim Westermann wrote:
 >I need to specify the lexer option filter.
 >Within one file it seems impossible to start:
 >
 >...
 >lexer grammar myname; -> unexpected token "lexer"
 >
 >I tried this in order to start an options block for the lexer.

You can't "restart" a grammar midway through the file.  Each 
grammar file can only contain one grammar.

 >The wiki example for filter lexers shows only a single lexer
 >grammar. So the next try was to use a composite grammar ant
 >import the lexer grammar from the parser grammar.

You can't combine composite grammars and filter lexers at all.  If 
you want to use a filter lexer, then you will have to create one 
"lexer grammar" (in its own file) and one "parser grammar" (in its 
own file), and link them via the vocabulary options.



More information about the antlr-interest mailing list