[Pkg-haskell-commits] r720 - in /packages/haskell-uulib/branches/upstream/current: README src/UU/Parsing/Interface.hs src/UU/Parsing/MachineInterface.hs

arjan at users.alioth.debian.org arjan at users.alioth.debian.org
Mon May 28 15:06:09 UTC 2007


Author: arjan
Date: Mon May 28 15:06:08 2007
New Revision: 720

URL: http://svn.debian.org/wsvn/pkg-haskell/?sc=1&rev=720
Log:
[svn-upgrade] Integrating new upstream version, haskell-uulib (0.9.3~snapshot20070528)

Modified:
    packages/haskell-uulib/branches/upstream/current/README
    packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/Interface.hs
    packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/MachineInterface.hs

Modified: packages/haskell-uulib/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-uulib/branches/upstream/current/README?rev=720&op=diff
==============================================================================
--- packages/haskell-uulib/branches/upstream/current/README (original)
+++ packages/haskell-uulib/branches/upstream/current/README Mon May 28 15:06:08 2007
@@ -73,10 +73,10 @@
 URL: https://svn.cs.uu.nl:12443/repos/uust-repo/uulib/trunk
 Repository Root: https://svn.cs.uu.nl:12443/repos/uust-repo
 Repository UUID: 30b93d28-2606-0410-b7f1-95e0edb40354
-Revision: 140
+Revision: 178
 Node Kind: directory
 Schedule: normal
-Last Changed Author: doaitse
-Last Changed Rev: 135
-Last Changed Date: 2007-04-13 15:39:36 +0200 (Fri, 13 Apr 2007)
+Last Changed Author: arthurvl
+Last Changed Rev: 154
+Last Changed Date: 2007-05-09 13:55:16 +0200 (Wed, 09 May 2007)
 

Modified: packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/Interface.hs
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/Interface.hs?rev=720&op=diff
==============================================================================
--- packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/Interface.hs (original)
+++ packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/Interface.hs Mon May 28 15:06:08 2007
@@ -25,37 +25,74 @@
 -- ===== PARSER CLASSES ==================================================================
 -- =======================================================================================
 
+-- | The 'IsParser' class contains the base combinators with which
+-- to write parsers. A minimal complete instance definition consists of
+-- definitions for '(<*>)', '(<|>)', 'pSucceed', 'pLow', 'pFail', 
+-- 'pCostRange', 'pCostSym', 'getfirsts', 'setfirsts', 'getzerop' 
+-- and 'setzerop'.
 class  IsParser p s | p -> s where
   -- | Sequential composition. Often used in combination with <$>.
+  -- The function returned by parsing the left-hand side is applied 
+  -- to the value returned by parsing the right-hand side.
   (<*>) :: p (a->b) -> p a -> p b
+  -- | Value ignoring versions of sequential composition. These ignore
+  -- either the value returned by the parser on the right-hand side or 
+  -- the left-hand side, depending on the visual direction of the
+  -- combinator.
   (<* ) :: p a      -> p b -> p a
   ( *>) :: p a      -> p b -> p b
   -- | Applies the function f to the result of p after parsing p.
   (<$>) :: (a->b)   -> p a -> p b
   (<$ ) :: b        -> p a -> p b
+  -- | Two variants of the parser for empty strings. 'pSucceed' parses the
+  -- empty string, and fully counts as an alternative parse. It returns the
+  -- value passed to it.
   pSucceed :: a -> p a
+  -- | 'pLow' parses the empty string, but alternatives to pLow are always
+  -- preferred over 'pLow' parsing the empty string.
   pLow     :: a -> p a
   f <$> p = pSucceed f <*> p
   f <$  q = pSucceed f <*  q
   p <*  q = pSucceed       const  <*> p <*> q
   p  *> q = pSucceed (flip const) <*> p <*> q
-  -- | Alternative combinator.
+  -- | Alternative combinator. Succeeds if either of the two arguments
+  -- succeed, and returns the result of the best success parse.
   (<|>) :: p a -> p a -> p a
-  -- | This parser always fails.
+  -- | This parser always fails, and never returns any value at all.
   pFail :: p a
+  -- | Parses a range of symbols with an associated cost and the symbol to
+  -- insert if no symbol in the range is present. Returns the actual symbol
+  -- parsed.
   pCostRange   :: Int{-#L-} -> s -> SymbolR s -> p s
+  -- | Parses a symbol with an associated cost and the symbol to insert if
+  -- the symbol to parse isn't present. Returns either the symbol parsed or
+  -- the symbol inserted.
   pCostSym     :: Int{-#L-} -> s -> s         -> p s
-  -- | Parses a symbol.
+  -- | Parses a symbol. Returns the symbol parsed.
   pSym         ::                   s         -> p s
   pRange       ::              s -> SymbolR s -> p s
+  -- | Get the firsts set from the parser, i.e. the symbols it expects.
   getfirsts    :: p v -> Expecting s
+  -- | Set the firsts set in the parser.
   setfirsts    :: Expecting s -> p v ->  p v
   pSym a       =  pCostSym   5{-#L-} a a
   pRange       =  pCostRange 5{-#L-}
+  -- | 'getzerop' returns @Nothing@ if the parser can not parse the empty
+  -- string, and returns @Just p@ with @p@ a parser that parses the empty 
+  -- string and returns the appropriate value.
   getzerop     ::              p v -> Maybe (p v)
+  -- | 'getonep' returns @Nothing@ if the parser can only parse the empty
+  -- string, and returns @Just p@ with @p@ a parser that does not parse any
+  -- empty string.
   getonep      :: p v -> Maybe (p v)
 
 
+-- | The fast 'AnaParser' instance of the 'IsParser' class. Note that this
+-- requires a functioning 'Ord' for the symbol type s, as tokens are
+-- often compared using the 'compare' function in 'Ord' rather than always
+-- using '==' rom 'Eq'. The two do need to be consistent though, that is
+-- for any two @x1@, @x2@ such that @x1 == x2@ you must have 
+-- @compare x1 x2 == EQ at .
 instance (Ord s, Symbol s, InputState state s p, OutputState result) => IsParser (AnaParser state result s p) s   where
   (<*>) p q = anaSeq libDollar  libSeq  ($) p q
   (<* ) p q = anaSeq libDollarL libSeqL const p q

Modified: packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/MachineInterface.hs
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/MachineInterface.hs?rev=720&op=diff
==============================================================================
--- packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/MachineInterface.hs (original)
+++ packages/haskell-uulib/branches/upstream/current/src/UU/Parsing/MachineInterface.hs Mon May 28 15:06:08 2007
@@ -1,17 +1,33 @@
 module UU.Parsing.MachineInterface where
 
+-- | The 'InputState' class contains the interface that the AnaParser
+-- parsers expect for the input. A minimal complete instance definition
+-- consists of 'splitStateE', 'splitState' and 'getPosition'.
 class InputState state s pos | state -> s, state -> pos where
+ -- | Splits the state in a strict variant of 'Either', with 'Left'' if a symbol
+ --   can be split off and 'Right'' if none can
  splitStateE :: state             -> Either' state s
+ -- | Splits the state in the first symbol and the remaining state
  splitState  :: state             -> ({-#L-} s, state  {-L#-})
+ -- | Gets the current position in the input
  getPosition :: state             -> pos
+ -- | Reports an error
  reportError :: Message s pos     -> state -> state
  reportError _ = id
+ -- | Modify the state as the result of inserting a symbol 's' in the input.
+ -- The symbol that has already been considered as having been inserted 
+ -- is passed. It should normally not be added to the state.
  insertSymbol :: s                -> state -> state
  insertSymbol _ = id
+ -- | Modify the state as the result of deleting a symbol 's' from the input.
+ -- The symbol that has already been deleted from the input state is passed.
+ -- It should normally not be deleted from the state.
  deleteSymbol :: s                -> state -> state
  deleteSymbol _ = id
  {-# INLINE splitStateE #-}
  {-# INLINE splitState  #-}
+ {-# INLINE insertSymbol  #-}
+ {-# INLINE deleteSymbol  #-}
 
 class OutputState r  where
   acceptR      ::                     v                   -> rest        -> r v rest




More information about the Pkg-haskell-commits mailing list