Indeed, there is a grammatical explanation. If you take a close look at the L&S entry, you might notice that virtually in all the 'as long as' examples the verb is imperfect, while it's perfect in the 'until' meaning. There's a good reason for this: Latin possesses two similar temporal conjunctions, dōnec and dum, that originally were complementary and well-differentiated, but got mixed up in the course of time and of some writers' stylistic experiments:
- dōnec is fundamentally perfective, aoristic, terminative; it denotes a point on the time scale when a change of affairs occurs: 'up until the point when'. As such, its clause normally contains a perfect verb:
haud dēsinam dōnec perfēcerō ('I'm not going to stop until it's done'); neque crēdēbam prīmō mihimet Sōsiae, dōnec Sōsia illic egomet fēcit sibi utī crēderem ('and at first I didn't believe Sosia, that is myself, until that Sosia, that is myself, made me believe him')
- whereas dum forms its imperfective, progressive counterpart, and denotes a stretch of time during which something did, does or will go on or hold as true: 'while, as long as'. Accordingly, its clause normally has an imperfect verb, and moreover usually in the present tense regardless of the tense of the narration:
mihi tū, tuī, tua omnia maximae cūrae sunt et, dum vīvam, erunt ('I care greatly about you, your family and everything that is yours, and will continue to do so for as long as I live'); dum haec loquimur, ad macellum advēnimus ('while talking these things we arrived at the marketplace')
One can distinguish several specialised uses depending on tense and mood combinations between the two clauses (such as the 'expecting' subjunctive), but I won't go into this here. What's relevant to us is that at some point, dum started being used - let's say artistically - to express temporally limited actions while highlighting their progressive nature. A probable starting point for this usage can be exemplified with this:
Tītyre, dum redeō (brevis est via) pāsce capellās ('Tityrus my man, look after my goats while I'm away - I won't be long')
Literally it says 'while I'm coming back', but because the verb redīre is terminative itself, the interpretation is 'until I come back, till I return' without the need for the explicitly terminative dōnec or a perfect tense. Now, this usage itself is totally normal, but then Vergil ventures to stick a future perfect verb in there because with a future imperfect it would mean 'as long as':
bellum ingēns geret [...] tertia dum Latiō rēgnāntem vīderit aestās ('until a third summer has seen him rule in Latium')
- Funnily enough, while looking up the passage I've stumbled upon Servius making the same observation on it in his commentary:
'dum' autem prō 'dōnec', ut "dum conderet urbem", id est 'dōnec' ('dum here is used for dōnec, as in...')
And then everyone goes: hey, why don't us artistic types (*cough* Tacitus *cough*) flip this around by using dōnec with imperfect tenses in the function of dum? And so it came to pass; so that in late Latin both conjunctions may be used promiscuously.
If one doesn't consider themselves an artsy Latin stylist, the distinction is plain, which I'll recapitulate:
- for 'until [a point]' use dōnec + perfect;
- for 'while, as long as' use dum + imperfect;
- if you see dōnec + imperfect, understand it as dum;
- if you see dum + perfect, understand it as dōnec;
- dōnec + impf. subj. for reaching an (undesirable) tipping point may be a special case, contrasting with the progressively anticipating dum + impf. subj.