Saturday, February 26, 2005 04:50 AM
Define your rules in the lexer. The parser retreives tokens from there. The lexer combines a series of letters into a token. It also converts the token type into an unique literal token (reserved keyword) if the text of the token is located in the list of reserved words. In your case, the keywords are "a" and "b". So, despite of the ANTLR's parser and lexer tight integration, you'll have to define a lex rule like
The most intriguing question I have here to ask from the Information Theory scientists and experts: what is the need for parser/lexer grammar separation? As you see, the barrier disturbs otherwise correct grammar.