[antlr-interest] Problem with lexer rule for an optional suffix

Scott Oakes scott.oakes62 at googlemail.com
Sat Nov 14 01:08:25 PST 2009


Hoping for some newbie help on the following lexer.

  fragment DIGIT:      '0'..'9';
  fragment LETTER: ('a'..'z'|'A'..'Z');

  ID:  (LETTER | '.')+ ('.' DIGIT+)?
       | DIGIT+
      ;

The idea is that ID is things like: "foo", "32", "bar.baz", or
"foo.bar.32". However with input "foo.bar.32", I get two tokens,
"foo.bar." and "32". How could I rewrite this so I get a single ID
token, "foo.bar.32"?


More information about the antlr-interest mailing list