alex/rply — pull request #23 by nvie (2014-03-24 15:36:35+00:00)
Title: Unify error handling, add expected tokens to context

This does two things:

1. Change error handler invocation to include a set of expected tokens. This is really useful to create error message to end users;
2. It unifies error handling by always calling the error handler with 3 arguments, in an order that makes sense: `token`, `expected`, `state`. This means the order, and existence/absense of arguments does not depend on whether or not the parser has been initialized with a state or not. The state is always included, even if it's `None`.

I realize this is a backward-incompatible change, but it definitely is a lot cleaner, I think. Let me know if you think this should be dealt with differently.

Example:

```python
@pg.error
def error_handler(token, expected, state):
exp = ', '.join(sorted(expected))
msg = 'Ran into %s where it was expecting any of %s' % (token, exp)
raise ValueError(msg)
```