in Cyborg/DrawingCommand.swift [205:217]
func parse<T>(command: XMLString,
followedBy: @escaping Parser<T>,
convertToPathCommandsWith convert: @escaping (T) -> PathSegment) -> Parser<PathSegment> {
return { stream, index in
literal(command)(stream, index)
.chain(into: stream) { stream, index in
followedBy(stream, index)
.map { result, index in
.ok(convert(result), index)
}
}
}
}