token method

Parser token(
  1. Object source, [
  2. String? name
])

Implementation

Parser token(Object source, [String? name]) {
  if (source is String) {
    return source.toParser(message: 'Expected ${name ?? source}').trim();
  } else if (source is Parser) {
    ArgumentError.checkNotNull(name, 'name');
    return source.flatten('Expected $name').trim();
  } else {
    throw ArgumentError('Unknown token type: $source.');
  }
}