parseSel function

ReadSelector parseSel(
  1. String? sel
)

Parses a selector string (as returned by SplitReadPath.sel) into a ReadSelector. Unrecognized selectors fall through to ReadSelectorNone — archive/SQLite readers consume their own colon syntax — but compounds that LOOK read-like yet are malformed throw (omp's invalidSelector), so a mistyped selector never silently widens into a whole-file read.

Implementation

ReadSelector parseSel(String? sel) {
  if (sel == null || sel.isEmpty) return const ReadSelectorNone();

  // Compound selector: `1-50:raw` or `raw:1-50`. Split into chunks and accept
  // exactly one line range (possibly multi) plus the literal `raw`.
  if (sel.contains(':')) return _parseCompoundSel(sel);

  if (sel.toLowerCase() == 'raw') return const ReadSelectorRaw();
  final ranges = parseLineRanges(sel);
  if (ranges != null) {
    return ReadSelectorLines(ranges);
  }
  // Unrecognized selectors fall through; sqlite/archive readers consume
  // their own colon syntax.
  return const ReadSelectorNone();
}