Skip to content

Commit

Permalink
Fix: ssParser [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
fisx committed Dec 23, 2024
1 parent b237893 commit de7840c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions integration/test/Testlib/ModService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Control.Monad.Reader
import Control.Retry (fibonacciBackoff, limitRetriesByCumulativeDelay, retrying)
import Data.Aeson hiding ((.=))
import qualified Data.Attoparsec.Text as Parser
import Data.Char (isSpace)
import Data.Default
import Data.Foldable
import Data.Function
Expand Down Expand Up @@ -312,7 +313,7 @@ parseSS :: Text -> Either String (Maybe (String, ProcessID))
parseSS input =
if Text.null input
then pure Nothing
else Just <$> Parser.parseOnly (ssParser <* Parser.endOfInput) input
else Just <$> Parser.parseOnly ssParser input

-- Example input:
-- LISTEN 0 4096 127.0.0.1:8082 0.0.0.0:* users:(("brig",pid=51468,fd=79))
Expand All @@ -328,11 +329,12 @@ ssParser = do
_ <- Parser.char ','
p <- pid
_ <- Parser.many1 noNewLine
Parser.endOfInput
pure (name, p)
where
spaces = void $ Parser.many' Parser.space
noSpace = Parser.satisfy (/= ' ')
noSpaces = Parser.many1 noSpace
noSpaces = Parser.takeWhile1 (not . isSpace)
noDoubleQuote = Parser.takeWhile1 (/= '"')
token p = do
spaces
res <- p
Expand All @@ -344,7 +346,7 @@ ssParser = do
quoted = do
token $ do
_ <- Parser.char '"'
tok <- noSpaces
tok <- Text.unpack <$> noDoubleQuote
_ <- Parser.char '"'
pure tok
pid = do
Expand Down

0 comments on commit de7840c

Please sign in to comment.