match method

Token match(
  1. String type
)

If the token match the type provided, advance 1 and return the original token. If not, generate an error.

Implementation

Token match(String type) {
  if (curTok.type != type) {
    final err = HTError.unexpectedToken(type, curTok.lexeme,
        filename: currrentFileName,
        line: curTok.line,
        column: curTok.column,
        offset: curTok.offset,
        length: curTok.length);
    errors.add(err);
  }

  return advance();
}