parseOn method

  1. @override
  2. @noBoundsChecks
Result<String> parseOn(
  1. Context context
)
override

Parses the given context.

Overridden in concrete subclasses to implement the parser-specific logic. Takes a parse context and returns the resulting context, which is either a Success or Failure context.

Implementation

@override
@noBoundsChecks
Result<String> parseOn(Context context) {
  final buffer = context.buffer;
  final position = context.position;
  final stop = position + literal.length;
  if (stop <= buffer.length) {
    final result = buffer.substring(position, stop);
    if (equalsIgnoreAsciiCase(literal, result)) {
      return context.success(result, stop);
    }
  }
  return context.failure(message);
}