private Token match ( Token . Kind kind ) { checkNotEof ( ) ; Token token = tokens . get ( index ++ ) ; if ( token . kind != kind ) { syntaxError ( "expecting \"" + kind + "\" here" , token ) ; } return token ; }
Match a given token kind whilst moving passed any whitespace encountered inbetween . In the case that meet the end of the stream or we don t match the expected token then an error is thrown .