private void checkTimeout ( ) throws ParserException { if ( timeout > 0 ) { if ( System . currentTimeMillis ( ) - startTime > timeout * 1000 ) { throw new ParserException ( "Timeout after " + timeout + " seconds near '" + getTokenStream ( ) . getCodeSample ( maxPosition ) + "'!" ) ; } } }
This method checks for the timeout . If the time ran out an ParserException is thrown and the parser process is finished .