Version 1.13 of VitRegex is released:
- fixed an "off by one" error in POSIX character classes inside bracket
expressions that was introduced in vers 1.05 - we were advancing one
character too few for the next loop iteration.
- previously in analyseFirstCharSet I had a statement at the bottom
"Non-alternating groups would require recursive analysis - skip for now"
This was intended as something to come back to at a later date (and that
later date is now). That's a roundabout way of saying I had forgotten all
about it until now <g>. The code has now been extended to cover this as
previously a non-alternating group with something like say "(\d+)foo" or
"([A-Z]+):" as the first token meant the first-character optimisation
was not done but completely skipped. We now do this by looking at the
first token inside the group.
- found another similar comment in analyseFirstCharSet:
! Merge this token's first chars into merged set
! (Simplified: just handle literals and char classes for now)
This meant that patterns like \d, \w, \R, etc were not optimised as the
group-alternation only handled L (literals) and C (Character classes).
The code has now been expanded to do a full optimisation.
- and found yet another similar earlier comment again in analyseFirstCharSet:
! Groups are complex - could contain alternation, optional elements, etc.
! For now, skip optimisation if branch starts with a group
! (Could be enhanced later to recursively analyse the group)
So again the time has come to flesh this out for a fuller optimisation.
Note that this is in the top-level alternation branch-scanning loop
(where scanForAlternation(1) is true), and up to now it aborted entirely
whenever a top-level branch started with a group so things like
"(cat|dog)|fish" or "(\d+)|abc" were not optimised - but they are now.
So one bug fix and three lots of optimisations to analyseFirstCharSet.
I should add that my test suite has now passed 900 tests. ![]()