Commits

Samuel Bronson committed abd0d4c

Add pMatch function in accordance with Jeremy Shaw's wishes

  • Participants
  • Parent commits f29f02b

Comments (0)

Files changed (1)

File ByteStringParser.hs

           (Left _) -> Left (st, [msg])
           ok -> ok
 
+-- |get remaining input
+getInput :: Parser C.ByteString C.ByteString
+getInput = Parser (\st -> Right (st,st))
+
 
 -- * Things like in @Parsec.Char@
 
                          else o
                      x -> x
 
+-- | parse some input with the given parser and return that input without copying it
+pMatch :: Parser C.ByteString a -> Parser C.ByteString C.ByteString
+pMatch p = do start <- getInput
+              p
+              end <- getInput
+              return (C.take (C.length start - C.length end) start)
+
 
 -- * Running parsers