LT method

  1. @override
Token? LT(
  1. int k
)
override

Get the Token instance associated with the value returned by LA. This method has the same pre- and post-conditions as IntStream.LA. In addition, when the preconditions of this method are met, the return value is non-null and the value of LT(k).getType()==LA(k).

TODO: in this doc it says that is non-null, but the implementation says otherwise

Se also: ntStream.LA

Implementation

@override
Token? LT(int k) {
  lazyInit();
  if (k == 0) return null;
  if (k < 0) return LB(-k);

  final i = p + k - 1;
  sync(i);
  if (i >= tokens.length) {
    // return EOF token
    // EOF must be last token
    return tokens.last;
  }
//		if ( i>range ) range = i;
  return tokens[i];
}