Remove global ERRORCOUNT, move to ParserState, return NULL Policy on failed parse.

Close #2416, #2417