Initial commit for Python3 target.

This just copies the Python runtime, templates, tests, and unittests,
to provide a starting point for diffs between the Python3 version
and the Python2 version.
Rewrite the Python target to support Python3.

Functional changes in the runtime:
- (2to3) Use __next__ for iterators.
- (2to3) Use "except Exception as e" syntax.
- (2to3) Replace basestring and unicode with str, long with int,
  and chr with unichr.
- (2to3) Replace StringIO module with io.
- Use relative imports.
- Move compatible_api_versions to constants to avoid circular
  dependency.
- main.py: Replace optparse with argparse.
  (This makes us require Python 3.2.)
- Nuke compat.py and everything relating to stringtemplate3.
- Rearrange some loops and conditionals to be simpler.
- Stop using exceptions for control flow.
- Replace a handful of deprecated setters and getters with properties.
  Change many things to use those instead (mostly for Token objects).
- Use a with statement for opening a file.
- Don't use exceptions for control flow.
- Put common properties of Token subclasses in the Token class itself.
- Remove an unnecessary argument from a matchAny function.
- Fix a newline that was meant to be two characters.
- Axe the use of encodings entirely (which will result in all files
  being opened as UTF-8, which is fine because all strings are unicode
  in Python 3), because bytes are no longer the same as strings.

Cosmetic changes in the runtime:
- Use super() instead of super(Class, self) or
  SuperClass.function(self).
- Fix some spelling errors in comments and such.
- Replace tabs with spaces and correct some off-by-one indenting.
- Remove commented-out print statements.
- dfa.py: Remove a comment asking for a bitwise op to check equality
  against 0xFFFF. This can be done with (((a + 1) & 0xFFFF) - 1), but it
  is substantially slower than the conditional.
- Use decorators.
- Use the implied string concatenator instead of putting '+' on each
  line.
- Use single-quotes instead of escaping double-quotes.
- Replace all '%' based string formatting with the new .format syntax.
- Add spacing between some binary operands.
- Use raw strings instead of doubling backslashes.
- Remove unnecessary semicolons.
- Remove unused tokenNames argument for some error handling functions
  that use self.tokenNames anyway.

Template changes:
- Remove likely unnecessary C# booleanLiteral rule.
- Use super() instead of super(Class, self).
- Use relative imports if the generated code is being used as a library,
  absolute imports otherwise.
- Insert comment about circular dependencies within the generated
  parser.
- Don't pass arguments to matchAny().
- Don't need to say u"" anymore.
- Remove all hard tabs. *Correctly* remove all hard tabs, that is.
- Access Tokens' properties directly. But not recognizers and trees.
- Remove an unnecessary semicolon.
Add a Python3Target class to the tool.

(It's a copy of PythonTarget, but with s/PythonTarget/Python3Target/.)

This is necessary so that generated code correctly compares the bytes
(given by LA) to character ordinals, for literal tokens.

Also add an explicit cast in GrammarAST, to shut javac up so I can
compile the Python3Target into a class for testing.
Convert unittests to Python 3.

- (2to3) Unicode strings don't need u prefixes.
- (2to3) StringIO module is now io.
- String formatting with .format instead of %.
- Move to use unittest assertion methods instead of bare asserts
  deprecated aliases, or fail() inside a try block.
- Use implied string concatenation.
- Remove unnecessary encoding information.
- Don't use exceptions for control flow.
- Remove unused argument 'x' from testtree.
- Use 'not in set' conditionals instead of 'foo == A or foo == B' etc.
- Use 'foo or bar' or the ternary operator instead of looking up into a
  list by using True or False (1 and 0 respectively) as indices.
- Remove unnecessary semicolons.
Carefully update tests to Python3.

- (2to3) New exception handling syntax "except Exception as e".
- (2to3) print is a function now.
- (2to3) Don't need to cast to unicode now.
- (2to3) The StringIO module is now io.
- Grammars use Python3 as their target language.
- Use unittest assertion methods instead of bare asserts, deprecated
  aliases, or fail() in a try block (where possible). This also means
  we don't need to do our own diffing for error messages.
- Use with blocks instead of open(foo).read().
- Remove some dead/unused commented-out test code
  (some of which was Java... o_O).
- Use ' as string delimiters when we want to include " in the string.
- Assert lists are equal to the empty list instead of asserting their
  length is 0.
- Use super() instead of manual calls or super(Class, self).
- set, frozenset, and reversed are builtins in Python 3, don't need any
  compatibility-related code.
- Use "if r" instead of "if r is not None" in most cases.
- Don't call encode anymore. It returns bytes, which aren't strings.
  (Except for hashlib, where we do want bytes.)
- Remove some unnecessary semicolons in the grammars.
- Update required test jar files to the ones I have that I can use (with
  the templates and Python3Target.class added appropriately).
- Remove unnecessary assertListEqual definition
  (unittest.TestCase has one).
- Fix assert appearing in an impossible conditional in testbase.
- Attempt to fix t059debug.py.
Python3 setup scripts.

Include a warning when run under any Python version before 3.2.
Convert dfaEdgeSwitch to use set inclusion.

This makes it so the condition is eg. "LA3 in {FOO, BAR, BAZ}"
instead of "LA3 == FOO or LA3 == BAR or LA3 == BAZ".

Unfortunately other cases that would benefit from this approach
(such as setTest) are structured in such a way that they don't have
an easy way (so far as I can tell) to discern what to be checking
("LA3" in the above example).
Allow genSetExpr/setTest to actually use sets.

This adds three additional possible arguments to setTest which allow
language templates to use set inclusion tests instead of repeated
equality and range checking tests:
- varName, which is either the temp variable the LA token is saved to,
  or the LA() function call. This is given by two new templates,
  lookaheadVarName and isolatedLookaheadVarName, which match their
  counterpart lookaheadTest rules.
- allValues, the flattened full list of token names to match against.
- allValuesAsInt, the flattened full list of token ids to match against,
  similar to atomAsInt in the lookaheadTest rules.

To receive allValues and/or allValuesAsInt, all three of these arguments
must be listed in the setTest definition. This also stops the ranges
argument from being passed in. Alternately, the setTest template can define
only ranges and varName as arguments, in which case it does not receive
allValues or allValuesAsInt. (This can be useful if you'd like to test
set inclusion for only the individual elements in ranges, and keep the
range tests themselves.)

And finally, make use of this feature in the Python3 target, since
Python3 allows raw definitions of sets, making these checks consistently
faster than the old behavior.
Final fixes to debug and its tests.

- Enable buffering since otherwise we have to use bytes instead of text.
- Output couldBacktrack as an integer.
- Debugger isn't a TestCase object, so use raw asserts.
Let token.typeName return the actual token name.

- Fix the circular parser dependency by giving each parser tokenNames.
- Give each recognizer a tokenNamesMap mapping token type to token name.
  (I would have done just tokenNames, but the lexer apparently doesn't
  receive anything for it.)
- Give the Token class a registerTokenNamesMap function so that all
  tokens can look up a reference to the names map in order to give a
  proper token type name when requested.
Add a pylintrc and fix some problems pylint found.

- Use super().__init__() in classes that derive from other classes.
- Fix some references to nonexistent variables that would have caused
  crashes had any of the tests run into them.
- Delete a function never used because later in the same class it was
  redefined. Delete the second instance of an abstract function
  similarly defined, but move its doc comment into the other instance.
- Give BaseRecognizer a default grammarFileName of None.
- Remove unused import CommonToken in streams.
- Move standard line and charPositionInLine properties to CharStream.
- Fix a few more % formatting and old-style super calls.
Copy doxygen scripts from Python target.
Remove xmlrunner references from setup.py.
Add LICENSE and update all the years to 2012.
Add .gitignore, AUTHORS, ChangeLog.
Fix last-minute bugs found by tests.

- Subclasses of Tree that override toString should also redefine __str__
  to toString.
- Test cases should assert that they get the string name of the token.
- Use a try/except block to import grammar delegates, since the
  delineation between running in a package and not is not just
   __name__ == "__main__".
Replace relative import hack with path changes.

(Somewhat more reasonable to do this rather than catching an exception,
in my opinion.)

Also remove a few more semicolons spotted while testing this.
Remove excess definitions and newlines.
Fix handling of syntactic predicate fragments.

(Specifically for python3)
- Don't use the base templates for synpred fragments.
  This fixes issue 29.
- Don't handle backtracking stuff in synpred fragments.
  This fixes a related issue that arose due to the fix above.
Add README.

It's mostly just the Python README with s/Python/Python3/,
though I also updated some information that pointed to the
old bugtracker.