[antlr-interest] help requested for selective whitespace

Martin Probst mail at martin-probst.com
Mon Feb 6 01:43:12 PST 2006


> note_desc
>   : NOTENAME (OCTAVE)? (DURATION)? (DOT)?
>   ;

What about:

note_desc
    : NOTENAME WS (OCTAVE)? WS (DURATION)? WS (DOT)?
    ;

and in the Lexer

WS
    : ( ' ' | '\t' | '\n' | '\r' )+;
(no $setType(Token.SKIP) here!).

This way you can explicitly ask for white space to be between your
tokens.

Martin



More information about the antlr-interest mailing list