lojix/logic/src/main/com/thesett/aima/logic/fol/isoprologparser/PrologParser.java
private boolean peekAndConsume(int kind)
    {
        Token nextToken = tokenSource.peek();

        if (nextToken.kind == kind)
        {
            try
            {
                consumeToken(kind);
            }
            catch (SourceCodeException e)
            {
                // If the peek ahead kind can not be consumed then something strange has gone wrong so report this
                // as a bug rather than try to recover from it.
                throw new IllegalStateException(e);
            }

            return true;
        }
        else
        {
            return false;
        }
    }
private boolean peekAndConsume(int kind)
    {
        Token nextToken = tokenSource.peek();

        if (nextToken.kind == kind)
        {
            try
            {
                consumeToken(kind);
            }
            catch (SourceCodeException e)
            {
                // If the peek ahead kind can not be consumed then something strange has gone wrong so report this
                // as a bug rather than try to recover from it.
                throw new IllegalStateException(e);
            }

            return true;
        }
        else
        {
            return false;
        }
    }
Peeks ahead for the given token type, and if one is foudn with that type, it is consumed.

@param  kind The token kind to look for.

@return <tt>true</tt> iff the token was found and consumed.