-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- begin matches are matched a single time (they no longer need to be rematched after found) - look-ahead should now work properly for begin matches because of this change - should be a tiny bit faster Before The old parser would build a list of regexes per mode and then combine that into a large regex. This is what was used to scan your code for matches. But after a match was found it had no way on known WHICH match - so it would then have to re-run all the rules sequentially on the bit of match text trying to figure out which rule had matched. The problem is while the original matcher was running agianst the full code this "rematch" was only running aginst the matched text. So look-ahead matches would naturally fail becasue the content they were tryign to look-ahead to was no longer present. After We take the list of regexes per mode and combine then into a larger regex, but with match groups. We keep track of which match group position correspond to which rule. Now when we hit a match we can check which match group was matched and find the associated rule/mode that was matched withotu having to double check. Look-ahead begin matches now "just work" because the rules are always running against the full body of text and not just a subset. Caveats This doesn't solve look-ahead for end matching so naturally it also does nothing for endSameAsBegin. IE, don't expect look-aheads to work properly in those situations yet.
- Loading branch information
1 parent
7a94cff
commit 2981f8e
Showing
1 changed file
with
165 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters