Allow InputTransformers to raise SyntaxErrors

This is a relatively trivial modification of the IPython main loop to
catch a possible SyntaxError and print it instead of
quitting. Doctesting this change is somewhat tricky since we actually
need to run the main TerminalInteractiveShell.interact() loop, and is
done through a subprocess and piping in a testcase.
Also catch SyntaxErrors from InputTransformers in run_cell()

The run_cell() method is not used in the IPython terminal, so there
are two code paths where the SyntaxError needs to be caught.  Also,
this commit moves the terminal test to IPython/terminal/test/ instead
of IPython/app/test. I've checked that this works in the terminal, the
Qt console, and the html notebook.
Refactor run_cell for clarity.
Don't clear input if InputTransformer raises SyntaxError.
Mechanism for testing terminal interact loop in-process.

While this is complex, I much prefer it to starting a separate process
and piping commands in.
Protect Qt console against SyntaxError from input transformers.
Simplify IPythonInputSplitter API
Catch transformer syntax errors in zmq terminal console
Document changes to input transformers
Add comment and remove line as suggested by @fperez
Merge pull request #4504 from takluyver/inputtransformer-syntaxerror

Allow input transformers to raise SyntaxError, if they consider a line of input code invalid.  

The main motivating use case for this was Sage, this is a continuation of @vbraun's gh-4089.  For background, see http://python.6.x6.nabble.com/Raising-a-SyntaxError-in-InputTransformer-td5027773.html.

Also, took advantage of the opportunity to refactor and simplify `run_cell` a bit.