Python 3 support

Following discussion on PR #32, this adds Python 3 support without any external dependencies. Python 2.6 and above and Python 3.3 and above should work; older versions will not.

The tests are passing on Python 2 and 3; I haven't tried the examples.
It is made a staticmethod below. I can't see how that makes sense, since it takes and uses `self`, but there is no usage of it in the code, and there are a bunch of duplicates of this file in different projects on Github, all seemingly with the same code here.

Looking at the top of this file, it appears to have been copied in from a PyANTLR project which looks like it's long since unmaintained. That makes sense, since ANTLR itself is a Java project, and I suspected that this code was written like Java. I probably shouldn't have bothered to touch these random unused bits. Should I revert the changes, or just leave them as is?

Looking further ahead, you will probably want to look for a replacement for this module, since it seems to be unmaintained and is clearly broken in some fairly obvious ways. I don't know enough about the parser tools space to know what's a good option there. pyparsing is one pure Python one that I'm aware of.