[antlr-interest] Whitespace: More than meets the eye?

Graham Wideman gwlist at grahamwideman.com
Wed Aug 5 17:10:18 PDT 2009


Hi folks:

Could someone clue me in to the zen of whitespace (or where this is discussed in The Books or online)?  By that I mean as follows: 

I see that grammars generally have a lexer rule that specifies the pattern for whitespace, but what's the correspondence between that and what ANTLR does with lexer rules, where the WHITESPACE token is generally not used.

I'm assuming that ANTLR makes assumptions that whitespace either may or must appear between tokens that appear in lexer rules, right?  Either that or it's picking up something from lexer rules that's subtler than I've noticed.

To pick a simple example, suppose you're defining what a function call should look like:

functionCall
    : Identifier LParen args RParen -> ....

... what variations does one need in order to assert that whitespace is, or is not, permitted or required between Identifier and LParen?

Thanks!

Graham


More information about the antlr-interest mailing list