[antlr-interest] * (zero or more) not matching greedily

Petteri Räty betelgeuse at gentoo.org
Fri Apr 10 11:05:52 PDT 2009


The relevant stuff from a grammar:

category:	(alphanum|'+'|'_'|DOT) ( alphanum|'+'|'_'|DOT|'-')* {
System.out.println($category.text); };

alphanum:	LOWER|UPPER|DIGIT;

DOT 	: '.';

DIGIT	:	'0'..'9';
LOWER	:	'a'..'z';
UPPER	:	'A'..'Z';

Why does it only take the first character for category? Isn't * supposed
to be greedy? I also tried adding options {greedy=true;} to the subrule
but it doesn't make a difference.

betelgeuse at pena ~/python/depend $ ATOM="app-foo" make
java -cp <snip long cp> Main app-foo
a

Regards,
Petteri

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090410/51716419/attachment.bin 


More information about the antlr-interest mailing list