CONTRIB-4149 Improve define/defined handling

This avoids zillions of unnecesary findNext() calls, that
for big files have a very negative impact. Instead, let's
handle it progresively (current token).

Detected when incorporating your sniffs to our codechecker:

https://tracker.moodle.org/browse/CONTRIB-4149

Ciao :-)