The construction of a PDA from a CFG on wikipedia (1) is like a nice exercise for implementing a minimal-and-slow-but-functional parsing algorithm. I have a question about termination of the PDA that is constructed. Specifically, given an input that is not in the language accepted by the PDA, is it guaranteed that the PDA will terminate?
For example, given the following CFG, which accepts an a followed by a string of b's:
A -> Ab
A -> a
Obviously, the string "b" is not accepted by this grammar. I suspect that if you run the PDA encoding of this CFG with input "b", the PDA will infinitely expand the A. I think this will happen because expanding a non-terminal does not consume an input token, so this process can just repeat. Am I missing a subtle part of the encoding, or is this encoding indeed sound but incomplete, in the sense that it accepts words in the language, but is not guaranteed to reject words not in the language?