peek method

Token peek(
  1. int distance
)

Get a token at a relative distance from current position.

Implementation

Token peek(int distance) {
  Token? result = curTok;
  for (var i = distance; i != 0; i.sign > 0 ? --i : ++i) {
    result = i.sign > 0 ? result?.next : result?.previous;
  }

  return result ?? endOfFile;
}