toParser method

  1. @useResult
Parser<String> toParser({
  1. bool isPattern = false,
  2. bool caseInsensitive = false,
  3. String? message,
})

Converts this string to a corresponding parser.

Implementation

@useResult
Parser<String> toParser({
  bool isPattern = false,
  bool caseInsensitive = false,
  String? message,
}) {
  if (isEmpty) {
    return epsilonWith<String>(this);
  } else if (length == 1) {
    return caseInsensitive
        ? charIgnoringCase(this, message)
        : char(this, message);
  } else {
    if (isPattern) {
      return caseInsensitive
          ? patternIgnoreCase(this, message)
          : pattern(this, message);
    } else {
      return caseInsensitive
          ? stringIgnoreCase(this, message)
          : string(this, message);
    }
  }
}