[antlr-interest] literal has no associated lexer rule...
Jim Idle
jimi at temporal-wave.com
Tue May 12 14:45:11 PDT 2009
Yurushkin Michael wrote:
> Good day!
> I use Antlr 3.
> There are 2 grammar files (lexer and parser). Lexer contains tokens
> definitions and parser imports tokens tabel.
> Is it possible to avoid definition of all literals (such as '+', '-'
> etc)...
>
> I want to write such rules in parser:
> "expr : (expr '+' factor) | (expr '-' factor) | factor;"
>
> but the "literal has no associated lexer rule: '+'" error appears.
>
No, you need to define the literals in the lexer and use tokens rather
than literals in the parser. When you come to print error messages and
so on, you wil likely want this anyway.
Jim
More information about the antlr-interest
mailing list