Skip to content

Instantly share code, notes, and snippets.

@NikolaiRuhe
Created April 8, 2022 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikolaiRuhe/8556a5e7b45a1cff691fac858627bb08 to your computer and use it in GitHub Desktop.
Save NikolaiRuhe/8556a5e7b45a1cff691fac858627bb08 to your computer and use it in GitHub Desktop.
func testQuotedField() throws {
let quotedField = Parse {
"|".utf8
Many(into: "") { result, element in
result += String(element)!
} element: {
OneOf {
Parse { "||".utf8 }.map { Substring("|").utf8 }
Prefix(1...) { $0 != .init(ascii: "|") }
}
}
"|".utf8
}
let input = "|Clarice loves ||Bob|||"
let result = try quotedField.parse(input)
XCTAssertEqual("Clarice loves |Bob|", result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment