[antlr-interest] fragment and option greedy=false

Sam Harwell sharwell at pixelminegames.com
Wed Nov 12 08:01:04 PST 2008


In a lexer, '*/' is two consecutive characters and not a set, so while ANTLR lets you complement it without a warning, it doesn't work as expected. At least that was the result when I tried a similar method on another rule.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Hendrik Maryns
Sent: Wednesday, November 12, 2008 6:10 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] fragment and option greedy=false

Sam Harwell schreef:
> COMMENT
>     : '/*'
>       (   (~'*' | '*' ~'/') => VALID_CHAR
>       )*
>       '*/'
>     ;

Why not simply

 (~'*/') => VALID_CHAR

?

H.
-- 
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html



More information about the antlr-interest mailing list