Change KxmlParser.next() to use one while loop instead of two.

This cleans up some of the structural problems with the KxmlParser code.
It was unclear how different text tokens (text, CDATA and entity tokens)
were concatenated in next() but not nextToken(). This moves the token loop
from the next() method into the nextImpl() method, saving redundant calls
to peekNext().

The code also had an instance field 'token' that was only well-defined
during calls to next() and nextToken(). I've removed this field and passed
parameters instead.

This fixes some implementation bugs:
 - empty CDATA blocks aren't reported
 - empty entities aren't reported
 - double dash in comments are forbidden in strict mode <!-- -- -->

Change-Id: I8c17b61d63e84622556f3751dbf8af282c601d09
http://b/3090550
2 files changed