I’m curious how editors are able to highlight syntax so quickly. I don’t care so much about the exact implementation, but the concept.
Regular expressions are generally pretty slow, but I know some great editors, at least Textmate, use them for the grammar definitions and are still plenty fast on rather large files.
Surely they don’t rerun their regex’s every keystroke, but they probably have also not gone deep enough into the regex engine to test if the new version will still pass in the same way as the previous version, gar gar gar.
Does it reparse like every second or so, and just always match the color of the typed character with the previous character until it gets the chance to reparse?