‘It’ – ambiguous antecedent?
Take the following sentence:
And even if the program inputted one token and then invoked newLine(), wouldn't it input a blank?
I've been told that this sentence has a clear pronoun reference. Why? Couldn't it refer to either program or token?
Grammatically, yes. Semantically, no.
The first sentence has program as the subject of input, with token being the object. Since the following sentence uses the same word in an obviously parallel manner, we unambiguously deduce that the subject is the same, especially because tokens do not usually input anything in programs.
As Edwin shows in his comment, the grammatical ambiguity can be made semantic as well (making the sentence properly ambiguous) if you change the sentence around so that the verb in the second clause can plausibly apply to either subject or object of the first clause:
When John gets to use Steve as a punching bag, is he doing him a favour?
It's unclear here whether Steve is doing John a favour by letting himself be used as a punching bag, or whether John is doing Steve (presumably a masochist) a favour by using him as a punching bag, because neither interpretation really makes that much sense, and both are somewhat unlikely.
Ambiguity is usually the result of two or more possible interpretations being too close in likelihood, more than of them just being there.