[antlr-interest] C# parser grammar problem

Gavin Lambert antlr at mirality.co.nz
Thu Mar 8 03:47:54 PST 2007


At 00:04 9/03/2007, Johannes Luber wrote:
 >Besides, if naming would be the only way to distinguish between
 >parser and lexer rules, how could ANTLR know when one uses the
 >wrong naming convention? I suppose that one could write a parser 

 >with doing the work of the lexer so there would be no need to
 >codify that convention in that case. A simple "Best Practice"
 >would be then sufficient.

I'm not quite sure what you mean by this.  Lexer and parser rules 
act on different input as well (lexer rules act only on 
characters, and parser rules act only on tokens), so they're 
fairly different.  The capitalisation of the rule gives the hint 
to ANTLR about how to interpret the contents of the rule (eg. how 
it should treat string/character constants), so if you get it 
wrong then you'll usually (but not always) get an error, though 
it's not a particularly easy to understand one.  Especially since 
the capitalisation convention wasn't documented.



More information about the antlr-interest mailing list