* Joshua Hoblitt ([EMAIL PROTECTED]) [25 Jun 2003 17:59]: > > If something is of a static length, use lengths.
> Say I have the years 2003 and -2003. In order to use > static lengths I need to have two separate regexs, > /(-\d\d\d\d)/ and /(\d\d\d\d)/. If I have a lot of rules > that need to match both negative and positive years group > tags can cut the worst case scenario in half. Good, good. > But what if I use /(-?\d\d\d\d)/ as the regex and set the > length => [ qw( 4 5 ) ]? :) cvs update Your wish is my small patch. > I wonder if an optimization of this would be to internally > create two separate specrefs with the same regex but one > with a length of 4 and one with a length of 5? The optimization is to just create the one parser from the spec ref and assign it into the lengths hash. As it's a reference, it's lighter than making a separate parser coderef for each array. But it's just the way one would write it anyway rather than being explicitly optimized. > The overhead of this may not be worth it - too bad we > don't have compiled code. I was briefly contemplating having it so that Builder (or, rather, an API clone of Builder with almost completely different innards) would produce actual code that one could save, thus eliminating the need for the average user to have Builder installed. But it proved too much for my tortured brain. I think the current situation works well enough. > > Note that a Dispatch parser can have a length. Which > > works as one might expect it to. Though I'm starting to > > have difficulty keeping potential combinations of things > > in my head =) > This just blows me away. Now try writing tests. Although some of the features have come in handy for some of the tests. The new multiple lengths for a single parser are being tested with the help of the multiple lengths feature you got the other day, combined with the preprocessor. cheers, -- Iain.
