equals method

bool equals(
  1. Object other, [
  2. List<String>? log
])

Compares this token with other. If log is provided, differences are appended in a human-readable format with JSON-style paths.

Implementation

bool equals(Object other, [List<String>? log]) {
  if (identical(this, other)) {
    return true;
  }
  if (other is! SToken) {
    log?.add('Type mismatch: $runtimeType != ${other.runtimeType}');
    return false;
  }
  var ok = true;
  if (offset != other.offset) {
    ok = false;
    log?.add(r'$.offset: $offset != ${other.offset}');
  }
  if (length != other.length) {
    ok = false;
    log?.add(r'$.length: $length != ${other.length}');
  }
  if (lexeme != other.lexeme) {
    ok = false;
    log?.add(r'$.lexeme: $lexeme != ${other.lexeme}');
  }
  if (tokenType != other.tokenType) {
    ok = false;
    log?.add(r'$.tokenType: $tokenType != ${other.tokenType}');
  }
  return ok;
}