Python: Extracting a proper interface for the scanner, so tools that
use the scanner can be written.
The interface is a bit preliminary and the code is not free from print
statements. Refinements are welcome.