protected Token consumeToken ( int kind ) throws SourceCodeException { Token nextToken = tokenSource . peek ( ) ; if ( nextToken . kind != kind ) { throw new SourceCodeException ( "Was expecting " + tokenImage [ kind ] + " but got " + tokenImage [ nextToken . kind ] + "." , null , null , null , new SourceCodePositionImpl ( nextToken . beginLine , nextToken . beginColumn , nextToken . endLine , nextToken . endColumn ) ) ; } else { nextToken = tokenSource . poll ( ) ; return nextToken ; } }
Consumes a token of the expected kind from the token sequence . If the next token in the sequence is not of the expected kind an error will be raised .