0
votes

I'm thinking about using ANTLR in my lecture on formal languages since it's input language is pretty clean and easy to learn. Since I am not an expert using ANTLR I tried some standard examples to get familiar with it's syntax, error messages etc. Doing so I found out, that:

lexer grammar KFG;
R  : 'a'R'b' | 'ab';

is a valid lexer that can be executed e.g. by:

echo "aaabbb" | grun KFG tokens -tokens

Since the grammar is context free it should only be parsable by a parser an not a lexer.

Is there any way to force ANTLR to accept only type 3 grammars for lexers?

Cheers, Alex

1

1 Answers

0
votes

Is there any way to force ANTLR to accept only type 3 grammars for lexers?

AFAIK, no, that is not possible.