[antlr-interest] Lexer bug? (with test cases!)
Gavin Lambert
antlr at mirality.co.nz
Wed Oct 24 12:22:33 PDT 2007
At 05:12 25/10/2007, Jim Idle wrote:
>Remember that not all the target languages have exceptions and
>that exceptions are tediously slow as they are meant to be used
>for actual exception conditions, not ways of programming your
>way out of algorithmic paths. It seems that not too many people
>are aware of this, and it is perhaps because the term exception
>implies that you can make your own algorithmic exceptions I
guess.
As Loring said, this is a red herring because exceptions are
already used for this purpose in both ANTLR 2 and 3. I wouldn't
do this with exceptions, though, since they *are* slow -- it's
easy enough to write the equivalent rollback code without needing
to use exceptions.
>Most people want/need efficient recognizers :-)
True, but it's counterproductive to program for efficiency by
sacrificing correctness.
>Personally, as I can trivially express such a case in an
>ANTLR lexer, and the resulting code is more maintainable
>(because I do not have to imagine the implied interactions), I
>don't worry about it. It seems trite.
Ok, please show how you'd rewrite one of my other examples that
doesn't work properly at the moment:
ONE: 'one';
TWO: 'two';
OTHER: .;
I don't see how you can get anything cleaner and more maintainable
than that.
>and the way that ANLTR produces lexers is not down to some
>lack of knowledge on his part about other ways of constructing
>lexer generators, which I think most people would have to agree
>with.
I don't think anyone is saying that Ter has a lack of
knowledge. Just a blind spot in this particular case :)
More information about the antlr-interest
mailing list