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 .