[antlr-interest] separat lexer + parser grammars

Mark Volkmann r.mark.volkmann at gmail.com
Fri Feb 15 15:06:04 PST 2008


On Fri, Feb 15, 2008 at 5:01 PM, Oliver Kowalke <oliver.kowalke at gmx.de> wrote:
> Hi,
>  I want to sepparat lexer and parser into different files.
>  I don't know where I've to put the tokens option.
>  tokens
>  {
>         WORKFLOW = 'workflow';
>  }
>
>  If I put it into the lexer file I get:
>  literals are illegal in lexer tokens{} section: 'workflow'
>
>  I I put it into the parser grammar I get:
>  literal has no associated lexer rule: 'workflow'
>
>  Could you please give me an hint, please?

Is 'workflow' a real token that can appear in an input stream or is it
an imaginary token that only appears in ASTs that your parser grammar
creates?

I think if it's a token that can appear in input then you should
define it in your lexer grammar. Otherwise you should define it in
your parser grammar. I only have experience with using "tokens { ...
}" for imaginary tokens and so I only use it in parser grammars. I'm
sure others can shed more light on this.

-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list