From 2b7f13df4a4cb148469052e993a935d923963e47 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Wed, 1 Nov 2023 23:37:54 +0000 Subject: [PATCH] Formatting --- src/Data/Attoparsec/Args.hs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Data/Attoparsec/Args.hs b/src/Data/Attoparsec/Args.hs index ca3fc21b7f..46e825c3ba 100644 --- a/src/Data/Attoparsec/Args.hs +++ b/src/Data/Attoparsec/Args.hs @@ -28,18 +28,24 @@ parseArgs mode = P.parseOnly (argsParser mode) parseArgsFromString :: EscapingMode -> String -> Either String [String] parseArgsFromString mode = P.parseOnly (argsParser mode) . T.pack --- | A basic argument parser. It supports space-separated text, and --- string quotation with identity escaping: \x -> x. +-- | A basic argument parser. It supports space-separated text, and string +-- quotation with identity escaping: \x -> x. argsParser :: EscapingMode -> P.Parser [String] -argsParser mode = many (P.skipSpace *> (quoted <|> unquoted)) <* - P.skipSpace <* (P.endOfInput "unterminated string") +argsParser mode = + many + ( P.skipSpace + *> (quoted <|> unquoted) + ) + <* P.skipSpace + <* (P.endOfInput "unterminated string") where - unquoted = P.many1 naked quoted = P.char '"' *> str <* P.char '"' - str = many ( case mode of - Escaping -> escaped <|> nonquote - NoEscaping -> nonquote - ) + unquoted = P.many1 naked + str = many + ( case mode of + Escaping -> escaped <|> nonquote + NoEscaping -> nonquote + ) escaped = P.char '\\' *> P.anyChar nonquote = P.satisfy (/= '"') naked = P.satisfy (not . flip elem ("\" " :: String))