[antlr-interest] Limit the occurrence of a character in the Lexer
jack zhang
jackgzhang2 at yahoo.com
Mon Sep 22 11:49:05 PDT 2008
Hi,
I want to limit the occurrence of the character * and ? in a string. Say, the * and ? can appear anywhere and multiple times in a string like:
(1) a*b
(2) a**b
(3) **ab
(4) ab*
(5) a?b*
(6) ?ab
But the string cannot ONLY contains these 2 character. For example, Following are invalid:
(10) **
(11) ?*
(12) ??**
(13) ??
Currently my WORD grammar is:
WORD: ('a'..'z' | 'A'..'Z' | '.' | ',' | '0'..'9' | '?' | '\u002A')+ ;
Which only covers the valid cases. Is there a way to do this without writing Java code in the Lexer and Parser?
Thx !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080922/d840aba0/attachment.html
More information about the antlr-interest
mailing list