[antlr-interest] Lexer rule problem - ANTLR 2.7.7

Gavin Lambert antlr at mirality.co.nz
Thu Jan 31 23:45:09 PST 2008


At 07:14 1/02/2008, Mark Edgeworth wrote:
 >As a relatively new user of ANTLR I have spent literally ages on 

 >just this sort of issue recently.  ANTLR is a great tool and 
just
 >so powerful, but will often accept 'unusual' grammar constructs
 >from newbies like me that can never work properly.  Any extra
 >build time checks are worth their weight in gold to me as I
 >learn... (ie 'lint' for .g files?)

Unit testing.  Construct a test harness for your lexer/parser in 
the language of your choice (eg. via JUnit, NUnit, CppUnit, or one 
of the many other frameworks) and run it frequently to ensure that 
changes you've made to your grammar haven't broken anything.

It's not quite build time (although it could be -- some build 
utilities can automatically run tests after building) but it's 
very specific and helps you make sure that your parser is doing 
what you think it's doing.

It's especially useful for testing the lexer in isolation, since 
you can't really do that properly in ANTLRworks.



More information about the antlr-interest mailing list