advance method

Token advance([
  1. int distance = 1
])

Advance till reach distance, return the token at original position.

Implementation

Token advance([int distance = 1]) {
  final previous = curTok;
  for (var i = distance; i > 0; --i) {
    curTok = curTok.next ?? endOfFile;
    line = curTok.line;
    column = curTok.column;
  }
  return previous;
}