On Tue, Oct 23, 2001 at 02:53:19PM +0200, Nadim Khemir wrote: > > Don't we already have that in Perl 5? > > > > if ( /\G\s+/gc ) { # whitespaces } > > elsif ( /\G[*/+-]/gc ) { # operator } > > elsif ( /\G\d+/gc ) { # term } > > elsif ( /\G.+/gc ) { # unrecognized token } > > > > Tad McClellan > > The answer is NO, regexes and a lexer are totally different. I would > recommend Tad to study a bit more what parsing is before thinking it's jut > about writing regexes. Having a lexer allows perl do some kind of text > processing (raw lexing and parsing) at a much faster. If it is of some > interest I could benchmark a simple example.
So, aren't you saying, "yes, but it would be slow"? I can't think of anything a lexer is capable of that I can't (and probably haven't) done in Perl with relative ease. Now, if you want a PARSER, that's a different matter, but a simple lexical scanner is trivial to write in Perl with logic and regular expressions. In terms of speed, this is particularly ideal because you can identify what parts of your Perl code slow the lexer down, and re-code those using C/XS. The best of all 2,384 worlds... that's Perl! -AJS -- Aaron Sherman [EMAIL PROTECTED] finger [EMAIL PROTECTED] for GPG info. Fingerprint: www.ajs.com/~ajs 6DC1 F67A B9FB 2FBA D04C 619E FC35 5713 2676 CEAF "Write your letters in the sand for the day I'll take your hand In the land that our grandchildren knew." -Queen/_'39_