Created
October 11, 2017 09:18
Revisions
-
santoshrajan created this gist
Oct 11, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import Foundation typealias ParseResult = (output: Any, rest: Substring)? func stringParser(input: Substring) -> ParseResult { if input[input.startIndex] != "\"" { return nil } var isEscape = true let index = input.index() { if $0 == "\"" && !isEscape { return true } isEscape = $0 == "\\" ? true : false return false } if let index = index { return (input[input.index(after: input.startIndex)...input.index(before: index)], input[input.index(after: index)...]) } return nil }