packages feed

razom-text-util 0.1.1.0 → 0.1.2.0

raw patch · 6 files changed

+52/−17 lines, 6 filesdep +textdep ~basedep ~regex-applicativedep ~smaoinPVP ok

version bump matches the API change (PVP)

Dependencies added: text

Dependency ranges changed: base, regex-applicative, smaoin

API changes (from Hackage documentation)

+ Text.Razom.Lexer: tokenizeText :: Advance Char -> Regex t -> Text -> LexResult t

Files

NEWS view
@@ -1,3 +1,31 @@+This file lists the user-visible interesting changes between releases. For a+full list of changes to the source, see the ChangeLog.++++razom-text-util 0.1.2.0 -- 2015-06-18+=====================================++General, build and documentation changes:++* (None)++New APIs, features and enhancements:++* Add `tokenizeText` function, producing tokens from lazy Text input++Bug fixes:++* `literal` regex accepts empty literals, e.g. as in `{{}}::<typeuid>`++Dependency changes:++* Adapt to smaoin-0.3+++++ razom-text-util 0.1.1.0 -- 2015-05-30 ===================================== 
razom-text-util.cabal view
@@ -1,5 +1,5 @@ name:                razom-text-util-version:             0.1.1.0+version:             0.1.2.0 synopsis:            Common text/parsing tools for Razom language packages. description:         This is a library of utilities for writing code that                      handles semantic information documents (text files). It is@@ -34,8 +34,9 @@   -- other-extensions:       build-depends:       base              >=4.7 && <5                      , regex-applicative >=0.3.1-                     , smaoin            >=0.1.0.0-                     , text-position     >=0.1.0.0+                     , smaoin            >=0.3+                     , text              >=1.2+                     , text-position     >=0.1   hs-source-dirs:      src   default-language:    Haskell2010 @@ -44,8 +45,8 @@   type:                exitcode-stdio-1.0   hs-source-dirs:      test   main-is:             test.hs-  build-depends:       base              >=4.7 && <5+  build-depends:       base                      , QuickCheck        >=2.8                      , razom-text-util-                     , regex-applicative >=0.3.1-                     , smaoin            >=0.1.1.1+                     , regex-applicative+                     , smaoin
src/Text/Razom/Lexer.hs view
@@ -15,11 +15,14 @@  module Text.Razom.Lexer     ( tokenizeString+    , tokenizeText     , tokenizeFile     ) where +import Control.Monad (liftM) import Data.Position+import qualified Data.Text.Lazy as T import Text.Razom.Types import Text.Regex.Applicative import System.IO@@ -30,12 +33,15 @@         re'   = many $ bless re         syms' = fst $ enrich adv syms     in case findLongestPrefix re' syms' of-        Just (ts, [])                      ->+        Just (ts, [])                    ->             Right $ depos ts-        Just (ts, ((Positioned c pos):ps)) ->-            Left $ LexError pos (depos ts) (c : (depos ps))-        Nothing                            ->+        Just (ts, Positioned c pos : ps) ->+            Left $ LexError pos (depos ts) (c : depos ps)+        Nothing                          ->             Left $ LexError firstPosition [] syms +tokenizeText :: Advance Char -> Regex t -> T.Text -> LexResult t+tokenizeText adv re = tokenizeString adv re . T.unpack+ tokenizeFile :: Advance Char -> Regex t -> FilePath -> IO (LexResult t)-tokenizeFile adv re fp = readFile fp >>= return . tokenizeString adv re+tokenizeFile adv re fp = liftM (tokenizeString adv re) $ readFile fp
src/Text/Razom/Number.hs view
@@ -30,7 +30,7 @@ where  import Data.Char (digitToInt, isOctDigit)-import Data.Smaoin (RealNum (..))+import Data.Smaoin (RealNum, realnum) import Text.Razom.Types import Text.Regex.Applicative import Text.Regex.Applicative.Common@@ -71,5 +71,5 @@ -- >>> fromDigits [1, 4, 2] [8, 5, 7] -- RealNum 142857 -3 fromDigits :: [Int] -> [Int] -> RealNum-fromDigits s e = RealNum (fromIntegral $ digitsToNum 10 $ s ++ e)+fromDigits s e = realnum (fromIntegral $ digitsToNum 10 $ s ++ e)                          (fromIntegral $ negate $ length e)
src/Text/Razom/Value.hs view
@@ -32,7 +32,7 @@ literal :: Regex String literal = string "{{" *> lbody <* string "}}"     where-    lbody = snd <$> withMatched (some lpart)+    lbody = snd <$> withMatched (many lpart)     lpart = Nothing <$ lchar <|> Nothing <$ sym '\\' <* psym isGraphical     lchar = psym $ \ c -> isGraphical c && c /= '\\' && c /= '}' @@ -48,7 +48,7 @@ -- | Given an escaped value literal, do minimal default unescapes: for the -- escape character and for the closing delimiter. unescapeMinimal :: String -> String-unescapeMinimal [] = []+unescapeMinimal []             = [] unescapeMinimal ('\\':'\\':cs) = '\\' : unescapeMinimal cs unescapeMinimal ('\\':'}':cs)  = '}'  : unescapeMinimal cs unescapeMinimal ('\\':c:cs)    = '\\' : c : unescapeMinimal cs
test/test.hs view
@@ -14,7 +14,7 @@  -}  import Control.Monad (unless)-import Data.Smaoin (RealNum (..))+import Data.Smaoin (realnum) import System.Exit import Test.QuickCheck import Test.QuickCheck.Test@@ -32,7 +32,7 @@                 && digitsToNum 16 [15, 15]           == 255  prop_fromDigits :: Bool-prop_fromDigits = fromDigits [1, 4, 2] [8, 5, 7] == RealNum 142857 (-3)+prop_fromDigits = fromDigits [1, 4, 2] [8, 5, 7] == realnum 142857 (-3)  prop_uid :: Bool prop_uid = match uid "<12<34\\>46\\\\7>" == Just "12<34>46\\7"