Created
April 8, 2022 13:45
-
-
Save NikolaiRuhe/8556a5e7b45a1cff691fac858627bb08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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