packages feed

uu-parsinglib 2.5.1.1 → 2.5.2

raw patch · 4 files changed

+37/−32 lines, 4 files

Files

src/Text/ParserCombinators/UU.hs view
@@ -19,7 +19,7 @@                                  , module Text.ParserCombinators.UU.BasicInstances                                  , module Text.ParserCombinators.UU.Derived                                  , module Text.ParserCombinators.UU.Merge-                                 , module Text.ParserCombinators.UU.Merge) where+                                 , module Text.ParserCombinators.UU.Perms) where import Text.ParserCombinators.UU.Core import Text.ParserCombinators.UU.BasicInstances import Text.ParserCombinators.UU.Derived
src/Text/ParserCombinators/UU/CHANGELOG.hs view
@@ -1,5 +1,9 @@ -- | This module just contains the CHANGELOG --+--   Version 2.5.2+-- +--       * Fixed bug in abstrcat interpretaion of seqentail composition with pure in left-hand side operand (reported by Dominique Devriese)+-- --   Version 2.5.1.1 --  --       * Now with the correct Changelog
src/Text/ParserCombinators/UU/Core.hs view
@@ -100,7 +100,7 @@  -- * The  descriptor @`P`@ of a parser, including the tupled parser corresponding to this descriptor -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%--- %%%%%%%%%%%%% Parser Descriptors    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+-- %%%%%%%%%%%%% Parser Descriptors    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  data  P   st  a =  P         (T  st a) --  actual parsers@@ -108,41 +108,42 @@                       Nat              --  minimal length                       (Maybe a)        --  possibly empty with value  -getOneP (P _ _  Zero _)    = error "The element is a special parser which cannot be combined"-getOneP (P _ Nothing l _ )    = Nothing-getOneP (P _ onep    l _ )    = Just( P (mkParser onep Nothing) onep    l Nothing)-getZeroP (P _ _ l Nothing) =  Nothing-getZeroP (P _ _ l pe)      =  Just ( P (mkParser Nothing pe)   Nothing l pe)+getOneP (P _ (Just _)  Zero _ )    =  error "The element is a special parser which cannot be combined"+getOneP (P _ Nothing   l    _ )    =  Nothing+getOneP (P _ onep      l    _ )    =  Just(mkParser onep l Nothing) +getZeroP (P _ _ l Nothing)         =  Nothing+getZeroP (P _ _ l pe)              =  Just (mkParser Nothing l pe) -mkParser Nothing Nothing    = empty-mkParser (Just nt) Nothing  = nt-mkParser Nothing   (Just a) = pure a-mkParser (Just nt) (Just a) = nt <|> pure a+mkParser np@Nothing   l  ne@Nothing   =  P empty           np l ne+mkParser np@(Just nt) l  ne@Nothing   =  P nt              np l ne+mkParser np@Nothing   l  ne@(Just a)  =  P (pure a)        np l ne+mkParser np@(Just nt) l  ne@(Just a)  =  P (nt <|> pure a) np l ne  -- ** Parsers are functors:  @`fmap`@ instance   Functor (P  state) where    fmap f   (P  ap np l me)   =  let nnp =  fmap (fmap     f)  np                                     nep =  f <$> me                                    -                                in  P  (mkParser nnp nep) nnp  l nep+                                in  mkParser nnp l nep   f <$     (P  ap np l me)   =  let nnp =  fmap (f <$)        np                                     nep =  f <$   me                                    -                                in  P  (mkParser nnp nep) nnp  l nep+                                in  mkParser nnp l nep   -- ** Parsers are Applicative:  @`<*>`@,  @`<*`@,  @`*>`@ and  @`pure`@ instance   Applicative (P  state) where-  P ap np  pl pe <*> ~(P aq nq  ql qe)  =  let nnp = do {npp <- np ;  return (npp <*> aq)}-                                               nep =  (pe <*> qe)-                                           in  P  (mkParser nnp nep) nnp (nat_add pl ql) nep-  P ap np pl pe  <*  ~(P aq nq  ql qe)   = let nnp = do {npp <- np ;  return (npp <* aq)}-                                               nep =  (pe <* qe)-                                           in  P  (mkParser nnp nep) nnp (nat_add pl ql) nep-  P ap np  pl pe  *>  ~(P aq nq ql qe)   = let nnp = do {npp <- np ;  return (npp *> aq)}-                                               nep =  (pe *> qe)-                                           in  P  (mkParser nnp nep) nnp (nat_add pl ql) nep +  P ap np  pl pe <*> ~(P aq nq  ql qe)  =  let nnp = combine np pe aq (<*>) (<$>)+                                           in  mkParser nnp  (nat_add pl ql) (pe <*> qe)+  P ap np pl pe  <*  ~(P aq nq  ql qe)   = let nnp = combine np pe aq (<*)  (<$)+                                           in  mkParser nnp (nat_add pl ql)  (pe <* qe)+  P ap np  pl pe  *>  ~(P aq nq ql qe)   = let nnp = combine np pe aq (*>)  (flip const)+                                           in  mkParser  nnp (nat_add pl ql) (pe *> qe)    pure a                                 = P (pure a) Nothing Zero (Just a) -+combine Nothing   Nothing  _  _   _   = Nothing +combine (Just p)  Nothing  aq op1 op2 = Just (p `op1` aq               )+combine (Just p)  (Just v) aq op1 op2 = Just (p `op1` aq <|> v `op2` aq)+combine Nothing   (Just v) aq _   op2 = Just (               v `op2` aq)+  -- ** Parsers are Alternative:  @`<|>`@ and  @`empty`@  instance   Alternative (P   state) where    P ap np  pl pe <|> P aq nq ql qe @@ -155,7 +156,7 @@                  (Nothing, _      ) -> qe                  (_      , Nothing) -> pe                  (_      , _      ) -> error "ambiguous parser because two sides of choice can be empty")-           in  P (mkParser nnp nep) nnp rl nep+           in  mkParser nnp rl nep   empty  =  P  empty empty  Infinite Nothing  -- ** An alternative for the Alternative, which is greedy:  @`<<|>`@@@ -243,7 +244,7 @@                                              ( \ k inp -> replaceExpected  ( pr k inp)))         replaceExpected (Fail _ c) = (Fail [label] c)         replaceExpected others     = others-    in P (mkParser nnp pe) nnp pl pe+    in mkParser nnp pl pe   @@ -255,7 +256,7 @@               Just ((T ph pf  pr)) -> Just(T ( \ k st -> ph (\ a st -> Micro i (k a st)) st)                                              ( \ k st -> pf (Micro i .k) st)                                              ( \ k st -> pr (Micro i .k) st))-    in P (mkParser nnp pe) nnp pl pe+    in mkParser nnp pl pe  -- ** Dealing with (non-empty) Ambigous parsers: @`amb`@  --   For the precise functionng of the combinators we refer to the technical report mentioned in the README file@@ -270,7 +271,7 @@                                              ( \k inp ->  combinevalues . removeEnd_f $ pf (\st -> End_f [k st] noAlts) inp)                                              ( \k     ->  removeEnd_h . pr (\ st' -> End_h ([undefined], \ _ -> k  st') noAlts)))         nep = (fmap pure pe)-    in  P (mkParser nnp nep) nnp pl nep+    in  mkParser nnp pl nep   -- ** Parse errors can be retreived from the state: @`pErrors`@@@ -285,7 +286,7 @@                             ( \ k inp -> let (errs, inp') = getErrors inp in push errs (k inp'))                             ( \ k inp -> let (errs, inp') = getErrors inp in            k inp' ))               nep =  (Just (error "pErrors cannot occur in lhs of bind"))  -- the errors consumed cannot be determined statically!-          in P (mkParser nnp nep) nnp Zero nep+          in mkParser nnp Zero nep   -- ** The current position  can be retreived from the state: @`pPos`@@@ -300,7 +301,7 @@                        ( \ k inp -> let pos = getPos inp in push pos (k inp))                        ( \ k inp -> let pos = getPos inp in           k inp ))             nep =  Just (error "pPos cannot occur in lhs of bind")  -- the errors consumed cannot be determined statically!-        in P (mkParser nnp nep) nnp Zero nep+        in mkParser nnp Zero nep   -- ** Starting and finalising the parsing process: @`pEnd`@ and @`parse`@@@ -323,7 +324,7 @@                                                   Just (i, inp') -> Fail [] [const (i, deleterest inp')]                                             in deleterest inp))               nep = Nothing --  (error "Unforeseen use of pEnd function; pEnd should only be used in function running the actual parser")-         in P (mkParser nnp nep) nnp Zero nep+         in mkParser nnp Zero nep              -- The function @`parse`@ shows the prototypical way of running a parser on a some specific input@@ -344,7 +345,7 @@                                                      in pf (\st2' -> k (back st2')) st2)                                         (\ k st1 ->  let (st2, back) = split st1                                                      in pr (\st2' -> k (back st2')) st2)) np-     in P (mkParser nnp pe) nnp pl pe+     in mkParser nnp pl pe  -- * Maintaining Progress Information -- | The data type @`Steps`@ is the core data type around which the parsers are constructed.
uu-parsinglib.cabal view
@@ -1,5 +1,5 @@ Name:                uu-parsinglib-Version:             2.5.1.1+Version:             2.5.2 Build-Type:          Simple License:             MIT Copyright:           S Doaitse Swierstra