Even at the price of making it a bit harder to scan (as we would need to jump out of constructor), I'd at least suggest extracting the parsing loop into a separate method, with code and tokens as argument (as such the buffered logic & flush_output could actually hide within that function).
I guess it could be carried down a bit into extracting the '{%' logic as it's one for '{{' already