[antlr-interest] Quoted Name Value Pairs

Gavin Lambert antlr at mirality.co.nz
Tue Apr 22 12:47:23 PDT 2008


At 07:29 23/04/2008, Jesse Anderson wrote:
 >Here is my file:

You've left some of the rules out, so it's hard to give a complete 
answer.  But for starters:

 >WHITESPACE : WHITESPACECHAR+ ;
 >
 >WHITESPACECHAR : ( '\t' | ' ' | '\r' | '\n'| '\u000C' ) ;

WHITESPACECHAR should be a fragment.

 >SEMICOLON : ( ';' )* ;

This permits SEMICOLON to match nothing, and lexer rules that can 
match nothing are a big no-no.  Either change the * to a + or 
remove it entirely and match multiple SEMICOLON tokens in the 
parser.

When you're starting out, it's useful to write a test harness for 
the lexer alone; feed it some sample input and print out the 
tokens it generates.  You'll often find that the parser isn't 
behaving the way you expect because it's getting different tokens 
than you expect.  ANTLRworks currently doesn't really show this 
very well.



More information about the antlr-interest mailing list