Brent Dax wrote: > Honestly, though, I'm no longer sure the full regex engine is a good idea. > A fast index op, a fast ord op, a character class op, and the intstack is > really all that's needed to make a regex engine from plain Parrot opcodes.
I agree with you on one level. That is enough to make a regex engine. However -- we don't want a regex engine, we want a pattern engine. Grammars are a lot more complicated than regexes[1], and there are many better ways to parse them. One of the small goals of Perl 6 is to eventually get people to use it instead of yacc. Which means it's got to be competitive in speed[2]. And, I will keep grinding this into people's heads until they finally decide to listen, Recursive Descent Will Not Be Competitive In Speed! No matter how well it's implemented. And of the parsing algorithms available to us, recursive descent is the only one which requires only an intstack. All the others need at least a character table. Okay, now I'll stop ranting and start thinking. I think a predictive parser would be pretty well suited. It's got a couple advantages over recursive descent which makes it much faster, but it's sufficiently compatible such that it's possible to switch over to recursive descent when things get too complicated for the algorithm (which they will, once in a while). You need a quick token lookup table to implement that well (things can be tokenized on-the-fly in top-down parsing, so that you don't need a discrete set). Bottom-up methods seem appealing because they're so fast. But they're not sufficiently versatile for what Perl needs. I'm tired, so I'll put some more thought into this later. But this is definitely something that needs to be approached with lateral thinking, and we've got to end up with something good (but not necessarily the first, er, third time :-). After all, Perl's still got to be good at its claim to fame: text processing. Luke [1] I'm speaking in the usual case here. That is, regexes (of the Perl variety) can do everything grammars can, but grammars do the "advanced" stuff a whole lot more often. [2] Not faster, because that would be pretty impossible. But not agonizingly slow for complex things. > --Brent Dax <[EMAIL PROTECTED]> > Perl and Parrot hacker