State marshalling patch, complete rewrite

Rewrite of the previous patch.
The state marshalled has the form:

    line,col,<marshalled-data>

where line and col are integers, marshalled-data is printed in hexadecimal
representation.

The line,col pair is the end position of the last processed token, such that
multiline tokens are correctly handled.