packages feed

HaLeX 1.2.2 → 1.2.4

raw patch · 12 files changed

+267/−102 lines, 12 files

Files

HaLeX.cabal view
@@ -1,5 +1,5 @@ name:                HaLeX-version:             1.2.2+version:             1.2.4 synopsis:            HaLeX enables modelling, manipulation and animation of regular languages description:         This library was developed in the context of a programming methodology course for                      undergraduate students, and as a consequence, it was defined mainly for educational purposes.
HaLeX_lib/Language/HaLex/Dfa.hs view
@@ -29,6 +29,7 @@               , transitionsFromTo               , destinationsFrom               , transitionTableDfa+              , transitionTableDfa'               , reachedStatesFrom               -- * Printing               , beautifyDfa@@ -217,6 +218,24 @@                                               | aq <- q                                               , av <- v                                               ]+++-- | Produce the transition table of a given 'Dfa'. +--   Given a 'Dfa', it returns a list of triples of the form+-- @+--                 (Origin,[Destination])+-- @+-- defining all the transitions of the 'Dfa'.+--++transitionTableDfa' :: (Ord st, Ord sy) +                    => Dfa st sy          -- ^ Automaton+                    -> [(st,[st])]        -- ^ Transition table++transitionTableDfa' (Dfa v q s z delta) = sort [ ( aq , map (delta aq) v )  +                                               | aq <- q +                                               ]+   -- | Reconstruct a 'Dfa' from a transition table.
HaLeX_lib/Language/HaLex/FaAsDiGraph.hs view
@@ -1,10 +1,10 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Language.HaLex.FaAsDiGraph--- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005+-- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005, 2016 -- License     :  LGPL ----- Maintainer  :  jas@di.uminho.pt+-- Maintainer  :  saraiva@di.uminho.pt -- Stability   :  provisional -- Portability :  portable --@@ -20,7 +20,9 @@                     , dfa2graphviz                     , dfa2graphviz2file                     , tographviz+                    , tographviz'		                         , tographvizIO+		    , tographvizIO'                     , dfa2DiGraphWithNoSyncSt                     , dfaDiGraphWithNoSyncStIO                     , genOneArrow@@ -38,20 +40,21 @@ ndfa2graphviz ndfa name = tographviz ndfa name "circle" "LR" (show . show)  -- | Print a 'Ndfa' in GraphViz in a file-ndfa2graphviz2file ndfa name = writeFile (name++".dot") (ndfa2graphviz ndfa  name)+ndfa2graphviz2file ndfa name =+         writeFile (name++".dot") (ndfa2graphviz ndfa  name)   -- | Print a 'Dfa' in GraphViz-dfa2graphviz dfa name = tographviz (dfa2ndfa dfa) name "circle" "LR" (show . show)+dfa2graphviz dfa name =+         tographviz (dfa2ndfa dfa) name "circle" "LR" (show . show)  -- | Print a 'Dfa' in GraphViz in a file dfa2graphviz2file dfa name = writeFile (name++".dot") (dfa2graphviz dfa  name)   --- | Print a 'Ndfa' in GraphViz--tographviz :: (Eq sy, Show sy, Ord st , Show st)+-- | Print a 'Ndfa' in GraphViz/dot notation (default function)+tographviz :: (Eq sy, Show sy, Ord st, Show st)         => Ndfa st sy            -- ^ Automaton         -> [Char]                -- ^ Graph's name         -> [Char]                -- ^ Node's shape@@ -59,67 +62,89 @@         -> (st -> [Char])        -- ^ Show function to print the state ids         -> [Char] tographviz ndfa@(Ndfa v q s z delta) name shape orientation showState =-  "digraph " ++ name ++ " {\n "-             ++ "rankdir = " ++ orientation ++ " ;\n "-             ++ (showElemsListPerLine (showStates q)) ++ "\n "-             ++ (showElemsListPerLine (showInitialStates s)) ++ "\n "+  tographviz' ndfa name shape orientation showState show  False False+++-- | Print a 'Ndfa' in GraphViz/dot notation+tographviz' :: (Eq sy, Show sy, Ord st, Show st) +        => Ndfa st sy            -- ^ Automaton+        -> [Char]                -- ^ Graph's name+        -> [Char]                -- ^ Node's shape+        -> [Char]                -- ^ Orientation+        -> (st -> [Char])        -- ^ Show function to print the state ids+        -> (sy -> [Char])        -- ^ Show function to print the labels+        -> Bool                  -- ^ Show dead states?+        -> Bool                  -- ^ Show sync states?+        -> [Char]+tographviz' ndfa@(Ndfa v q s z delta) name shape orientation +           showState showLabel deadSt syncSt = "digraph " ++ name ++ " {\n " +             ++ "rankdir = " ++ orientation ++ " ;\n " +             ++ (showElemsListPerLine (showStates q)) ++ "\n " +             ++ (showElemsListPerLine (showInitialStates s)) ++ "\n "               ++ (showElemsListPerLine (showFinalStates' z))-             ++ (showElemsListPerLine (showNdfaArrows'' ndfa))+             ++ (showElemsListPerLine (showNdfaArrows ndfa showState showLabel deadSt syncSt))               ++ "node [shape=none, lavel=initialState, style = invis];\n"-             ++ (createInitialArrows (mirroredInitialStates s) s)+             ++ (createInitialArrows (mirroredInitialStates s 1) s)              ++ "\n}"-  where+  where      showElemsListPerLine :: [String] -> String     showElemsListPerLine []    = ""-    showElemsListPerLine (h:t) = ((showString h) "\n ") ++-                                 (showElemsListPerLine t)--    showStates qs = [(showState q) ++-                     " [shape=" ++ shape ++" , label=" ++ (showState q) ++ " ,color=black];"-                    | q <- qs , not (ndfaIsStDead delta v z q ) ]+    showElemsListPerLine (h:t) = ((showString h) "\n ") ++ (showElemsListPerLine t)  +    showStates qs = ["\"" ++ (showState q) ++ "\"" ++ +                     " [shape=" ++ shape ++" , label=\"" ++ (showState q) ++ "\" ,color=black];" +                    | q <- qs +                    , not (ndfaIsStDead delta v z q ) || deadSt+                    , not (ndfaIsSyncState delta v z q) || syncSt]+      showInitialStates ss = map showInitialState ss -    showInitialState  s = (showState s)-                          ++ " [shape=" ++ shape ++ " , label= " ++ (showState s)-                          ++ ", color=green];\n "+    showInitialState  s = "\"" ++ (showState s) +                          ++ "\" [shape=" ++ shape ++ " , label= \"" ++ (showState s) +                          ++ "\", color=green];\n "   --    showFinalStates' :: Show a => [a] -> [String]-    showFinalStates' zs = [ (showState z)-                          ++ " [shape=double" ++ shape ++" , color=red];" | z <- zs ]+    showFinalStates' zs = [ "\"" ++ (showState z) ++ "\" [shape=double" ++ shape ++" , color=red];" +                          | z <- zs ] ---     showNdfaArrows' :: (Eq sy,  Show sy) => Ndfa st sy -> [String]-    showNdfaArrows' ndfa-       = map (\ (o,l,d) -> genOneArrow (showState o) (show l) (showState d))-             ((groupMoves . transitionTableNdfa) ndfa) ---     showNdfaArrows'' :: (Ord st, Eq sy, Show st, Show sy) => Ndfa st sy -> [String]-    showNdfaArrows'' ndfa@(Ndfa v q s z delta)-         = map (\ (o,l,d) -> if (ndfaIsStDead delta v z o) || (ndfaIsStDead delta v z d) then ""-                             else genOneArrow (showState o) (showListMaybe l) (showState d))-                                  ((groupMoves . transitionTableNdfa) ndfa) - -- Creating the incoming arrows for the initial states -- (for each state we create an invisible node and a arrow connecting to the initial one) -    mirroredInitialStates = map (\state -> "_newState" ++ (show state))+    mirroredInitialStates [] _     = []+    mirroredInitialStates (x:xs) n = ("\"_newState_" ++ (show n) ++ "\"") : +                                     mirroredInitialStates xs (n+1)+     createInitialArrows [] []         = " "-    createInitialArrows (x:xs) (y:ys) = x ++ " -> " ++ (showState y) ++-                                        "[color = green];\n" +++    createInitialArrows (x:xs) (y:ys) = x ++ " -> \"" ++ (showState y) ++ +                                        "\" [color = green];\n" ++                                          createInitialArrows xs ys  -showListMaybe []     = ""-showListMaybe (x:xs) = case x of-                       Just a -> (show a) ++ if (showListMaybe xs == "") then ""-                                   else ("," ++ showListMaybe xs)-                       Nothing -> "Epsilon" ++ if (showListMaybe xs == "") then ""-                                   else ("," ++ showListMaybe xs) ---++-- | Show the arrows between nodes (states) induced by the 'Ndfa' transitions.+showNdfaArrows :: (Ord st,Show st,Show sy,Eq sy)+               => Ndfa st sy         -- ^ Automaton+	       -> (st -> String)     -- ^ Show function to print the state ids+	       -> (sy -> String)     -- ^ Show function to print the labels+	       -> Bool               -- ^ Show dead states?+	       -> Bool               -- ^ Show sync states?+	       -> [String]+showNdfaArrows ndfa@(Ndfa v q s z delta) showState showLabel deadSt syncSt = +     map (\ (o,l,d) -> if deadSt then  if (not syncSt) && (ndfaIsSyncState delta v z o) || (ndfaIsSyncState delta v z d)  then ""+                                          else  genOneArrow (showState o) (showLabels showLabel l) (showState d) +                          else if ((ndfaIsStDead delta v z o) || (ndfaIsStDead delta v z d)) then ""+                                  else genOneArrow (showState o) (showLabels showLabel l) (showState d))+         ((groupMoves . transitionTableNdfa) ndfa)+++++-- | Group labels with same origin and destination. -- Given the Transition Table of a Ndfa it groups the transtions with--- the same origin and destination into a single transtion, whose transtion+-- the same origin and destination into a single transition, whose transtion -- is the list of labels of the original transtions. -- @@ -139,7 +164,7 @@              new_label = if l'' == [] then [l']                                       else l' : l'' -+{- showNdfaArrows :: (Ord st,Show st,Show sy) => Ndfa st sy -> [String] showNdfaArrows (Ndfa vs qs s z delta) = [ genOneArrow (show q) (show v) (show r)                                         | q <- qs , v <- vs@@ -153,15 +178,52 @@                                         , not (ndfaIsStDead delta vs z r )                                         , not (ndfaIsStDead delta vs z q )                                         ]+-} -genOneArrow orin label dest = orin-                              ++ " -> " ++ dest-                              ++ " [label = " ++ (show label) ++ "];"  +showLabels :: (st -> String) -> [Maybe st] -> String+showLabels _ []             = ""+showLabels showLabel (x:xs) = +     case x of+         Just a -> (showLabel a) ++ if (showLabels showLabel xs == "") then ""+                               else ("," ++ showLabels showLabel xs)+         Nothing -> "Epsilon" ++ if (showLabels showLabel xs == "") then ""+                                 else ("," ++ showLabels showLabel xs) ++genOneArrow :: String -> String -> String -> String+genOneArrow orin label dest = orin ++ " -> " ++ dest+                              ++ " [label = " ++ (show label) ++ "];"+++-- | Save a 'Ndfa' in a GraphViz/dot file (default function)+tographvizIO :: (Eq sy, Show sy, Ord st , Show st) +        => Ndfa st sy            -- ^ Automaton+        -> [Char]                -- ^ Graph's name+        -> [Char]                -- ^ Node's shape+        -> [Char]                -- ^ Orientation+        -> (st -> [Char])        -- ^ Show function to print the state ids+        -> IO() tographvizIO ndfa name shape orientation showState =    writeFile (name++".dot") (tographviz ndfa name shape orientation showState)+++-- | Save a 'Ndfa' in a GraphViz/dot file+tographvizIO' :: (Eq sy, Show sy, Ord st , Show st) +        => Ndfa st sy            -- ^ Automaton+        -> [Char]                -- ^ Graph's name+        -> [Char]                -- ^ Node's shape+        -> [Char]                -- ^ Orientation+        -> (st -> [Char])        -- ^ Show function to print the state ids+        -> (sy -> [Char])        -- ^ Show function to print the labels+        -> Bool                  -- ^ Show dead states?+        -> Bool                  -- ^ Show sync states?+        -> IO()++tographvizIO' ndfa name shape orient showSt showLb deadSt syncSt =+   writeFile (name++".dot")+             (tographviz' ndfa name shape orient showSt showLb deadSt syncSt)   dfa2DiGraphWithNoSyncSt dfa name = dfa2graphviz dfa name
HaLeX_lib/Language/HaLex/FaClasses.hs view
@@ -21,6 +21,7 @@ import Language.HaLex.Dfa import Language.HaLex.Ndfa import Language.HaLex.FaOperations+import Language.HaLex.Sentences import Language.HaLex.Equivalence import Language.HaLex.Minimize import Language.HaLex.FaAsDiGraph@@ -35,6 +36,7 @@   minimize   :: fa st sy -> Dfa [[st]] sy   reverseFa  :: fa st sy -> Ndfa st sy   deadstates :: fa st sy -> [st]+  sentences  :: fa st sy -> [[sy]]   toHaskell' :: fa st sy -> String -> IO ()   toGraph    :: fa st sy -> String -> String   toGraphIO  :: fa st sy -> String -> IO()@@ -55,10 +57,12 @@   minimize   = minimizeDfa   reverseFa  = reverseDfa   deadstates = dfadeadstates+  sentences  = sentencesDfa   toHaskell' = toHaskell   toGraph    = dfa2graphviz   toGraphIO  = dfa2graphviz2file +     unionFa    = unionDfa   starFa     = starDfa   concatFa   = concatDfa@@ -73,6 +77,7 @@   minimize   = minimizeNdfa   reverseFa  = reverseNdfa   deadstates = ndfadeadstates+  sentences  = sentencesNdfa   toHaskell' = toHaskell   toGraph    = ndfa2graphviz   toGraphIO  = ndfa2graphviz2file
HaLeX_lib/Language/HaLex/Minimize.hs view
@@ -124,13 +124,14 @@             => Dfa st sy                      -- ^ Original 'Dfa'             -> Dfa [st] sy                    -- ^ Equivalent Minimized 'Dfa' -minimizeExp (Dfa t lst si lsf d) = Dfa t l (head (filter (\x->elem si x) l))-                                        (filter (\x->intersect x lsf /= []) l) ndelta-                                where (a,b)=partition f lst-			              f x = elem x lsf-				      l = (minaux lst d t) [a,b]-				      ndelta st s | elem st l = rfind (d (head st) s) l-					          | otherwise = []+minimizeExp (Dfa t lst si lsf d) =+   Dfa t l (head (filter (\x->elem si x) l))+           (filter (\x->intersect x lsf /= []) l) ndelta+      where (a,b)=partition f lst+            f x = elem x lsf+            l = (minaux lst d t) [a,b]+            ndelta st s | elem st l = rfind (d (head st) s) l+                        | otherwise = []  rfind :: Eq a => a -> [[a]] -> [a] rfind _ []=[]@@ -140,18 +141,19 @@ minaux :: (Ord a) => [a] -> (a -> b -> a) -> [b] -> [[a]] -> [[a]] minaux lst d simb p | p == p' = p                     | otherwise = minaux lst d simb p'-		    where p' =concatMap (partes lst d simb p []) p+     where p' =concatMap (partes lst d simb p []) p  partes :: Eq a => [a] -> (a -> b -> a) -> [b] -> [[a]] -> [a] -> [a] -> [[a]] partes _ _ _ _ _ []  =[]-partes _ _ _ _ ac [h] | elem h ac = []-                      | otherwise = [[h]]-partes lst d simb p ac (h:hs) |(elem h ac) = partes lst d simb p ac hs-                              |otherwise = ([h]++r):(partes lst d simb p  (ac++r) hs)-			      where r = raux hs-			            raux []=[]-		                    raux (x:xs) | (comparaDelta lst d simb p h x) = x:(raux xs)-			                        | otherwise = raux xs+partes _ _ _ _ ac [h] |  elem h ac = []+                      |  otherwise = [[h]]+partes lst d simb p ac (h:hs)+                      |  (elem h ac) = partes lst d simb p ac hs+                      |  otherwise   = ([h]++r):(partes lst d simb p  (ac++r) hs)+               where r = raux hs+                     raux [] = []+                     raux (x:xs) | (comparaDelta lst d simb p h x) = x:(raux xs)+                                 | otherwise = raux xs   mesmoGrupo :: Eq a => [a] -> [[a]] -> a -> a -> Bool@@ -167,7 +169,7 @@ comparaDeltaSimb :: Eq a => [a] -> (a -> b -> a) -> [[a]] -> a -> a -> b -> Bool comparaDeltaSimb lst d p s t v = mesmoGrupo lst p s' t'                                  where s' = d s v-				       t' = d t v+                                       t' = d t v   -----------------------------------------------------------------------------
HaLeX_lib/Language/HaLex/Ndfa.hs view
@@ -1,10 +1,10 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Language.HaLex.Ndfa--- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005+-- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005, 2016 -- License     :  LGPL ----- Maintainer  :  jas@di.uminho.pt+-- Maintainer  :  saraiva@di.uminho.pt -- Stability   :  provisional -- Portability :  portable --@@ -39,6 +39,7 @@              , ndfadeadstates              -- * Properties of States              , ndfaIsStDead+             , ndfaIsSyncState              , ndfanumberIncomingArrows              , ndfanumberOutgoingArrows              ) where@@ -321,12 +322,25 @@ -- | Checks whether a 'Ndfa' state is a sync state or not -- --isSyncState :: Ord st => st -> [sy] -> [st] -> (st -> Maybe sy -> [st]) -> Bool-isSyncState st vs z d = (not (st `elem` z)) && (and qs)+{-+ndfaIsSyncState :: Ord st => st -> [sy] -> [st] -> (st -> Maybe sy -> [st]) -> Bool+ndfaIsSyncState st vs z d = (not (st `elem` z)) && (and qs)   where qs = [ [st] == (d st (Just v))                && (([st] == d st Nothing) || ([] == d st Nothing))              | v <- vs+             ]+-}++ndfaIsSyncState :: Ord st+                => (st -> Maybe sy -> [st])     -- ^ Transition Function+                -> [sy]                         -- ^ Vocabulary+                -> [st]                         -- ^ Set of Final States+                -> st                           -- ^ State+                -> Bool+ndfaIsSyncState d vs z st = (not (st `elem` z)) && (and qs)+  where qs = [ [st] == (d st (Just v)) +               && (([st] == d st Nothing) || ([] == d st Nothing))+             | v <- vs               ]  
HaLeX_lib/Language/HaLex/Parser.hs view
@@ -17,6 +17,8 @@  module Language.HaLex.Parser where +import Prelude hiding ((<$>), (<*>))+ infixl 3 <|> ; infixl 4 <*>  @@ -65,5 +67,12 @@ (f <$> p) xs = [(f y, ys) | (y,ys) <- p xs ]  -+--+--  More combinators+-- +oneOrMore  :: Parser s a -> Parser s [a]+oneOrMore p =   f <$>  p <*> oneOrMore p+           <|>  g <$>  p+   where f a as = a:as+         g a    = [a]
HaLeX_lib/Language/HaLex/RegExp.hs view
@@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Language.HaLex.RegExp--- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005+-- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005, 2016 -- License     :  LGPL --  -- Maintainer  :  jas@di.uminho.pt@@ -44,21 +44,23 @@                 | Star      (RegExp sy)              -- ^ Repetition, possibly zero time                 | OneOrMore (RegExp sy)              -- ^ One or more times (extended RegExp)                 | Optional  (RegExp sy)              -- ^ Optional (extended RegExp)+                | RESet     [sy]                     -- ^ Set (extended RegExp)    deriving (Read, Eq)     -- | Catamorphism induced by the 'RegExp' inductive data type  cataRegExp :: ( re                , re-              , re -> re -> re-              , re -> re-              , sy -> re-              , re -> re -> re-              , re -> re-              , re -> re+              , re   -> re -> re+              , re   -> re+              , sy   -> re+              , re   -> re -> re+              , re   -> re+              , re   -> re+              , [sy] -> re               ) -> RegExp sy -> re -cataRegExp (empty,epsilon,or,star,lit,th,one,opt) = cata+cataRegExp (empty,epsilon,or,star,lit,th,one,opt,set) = cata  where cata Empty          = empty         cata Epsilon        = epsilon        cata (Or er1 er2)   = or (cata er1) (cata er2)@@ -67,6 +69,7 @@        cata (Then er1 er2) = th (cata er1) (cata er2)        cata (OneOrMore er) = one (cata er)        cata (Optional er)  = opt (cata er)+       cata (RESet st)     = set st  ----------------------------------------------------------------------------- -- * Matching@@ -131,7 +134,7 @@  sizeRegExp :: RegExp sy      -- ^ Regular Expression            -> Int            -- ^ Size-sizeRegExp = cataRegExp (0,0,(+),id,\x -> 1,(+),id,id)+sizeRegExp = cataRegExp (0,0,(+),id,\x -> 1,(+),id,id,length)   -----------------------------------------------------------------------------@@ -154,34 +157,37 @@                      , \ l r -> "(" ++ l ++ r ++ ")"                      , \ er  -> "(" ++ er ++ ")+"                      , \ er  -> "(" ++ er ++ ")?"+                     , \ set -> show set                      )  -- | Pretty print of regular expressions.  instance Show sy => Show (RegExp sy) where           showsPrec _ Empty             = showString "{}"- 	  showsPrec _ Epsilon           = showChar '@'- 	  showsPrec _ (Literal c)       = showsPrec 0 c+          showsPrec _ Epsilon           = showChar '@'+          showsPrec _ (Literal c)       = showsPrec 0 c {-                | isSymbol c            = showChar '\''                                         . showChar c                                         . showChar '\''                 | otherwise             = showChar c -}-   	  showsPrec n (Star e)          = showsPrec 10 e . showChar '*'- 	  showsPrec n (OneOrMore e)     = showParen (n == 4)+          showsPrec n (Star e)          = showsPrec 10 e . showChar '*'+          showsPrec n (OneOrMore e)     = showParen (n == 4)                                         $ showsPrec 10 e                                         . showChar '+'- 	  showsPrec _ (Optional e)      = showsPrec 10 e+          showsPrec _ (Optional e)      = showsPrec 10 e                                         . showChar '?'- 	  showsPrec n (e1 `Or` e2)      = showParen (n /= 0 && n /= 4)+          showsPrec n (e1 `Or` e2)      = showParen (n /= 0 && n /= 4)                                         $ showsPrec 4 e1                                         . showChar '|'                                         . showsPrec 4 e2-	  showsPrec n (e1 `Then` e2)    = showParen (n /= 0 && n /= 6)+          showsPrec n (e1 `Then` e2)    = showParen (n /= 0 && n /= 6)                                         $ showsPrec 6 e1                                         . showChar ' '                                         . showsPrec 6 e2+          showsPrec _ (RESet set)       = showList set  +  isSymbol x = x `elem` "|? "  -----------------------------------------------------------------------------@@ -196,7 +202,7 @@  simplifyRegExp (Star x)     = case x' of                                -- Algebraic Rules:                                Epsilon      -> Epsilon                  -- @*       = @-  		               Empty        -> Epsilon                  -- {}*      = @+                               Empty        -> Epsilon                  -- {}*      = @                                Or Epsilon a -> Star (simplifyRegExp a)  -- (a | @)* = a*                                Or a Epsilon -> Star (simplifyRegExp a)  -- (@ | a)* = a*                                _            -> Star x'@@ -240,13 +246,16 @@  simplifyRegExp (Optional x) = Optional (simplifyRegExp x) +simplifyRegExp (RESet set) = RESet set ++ ----------------------------------------------------------------------------- -- * Normalization  -- | Rewrite extended regular expressions to --   plain regular expression. This means that the 'OneOrMore' ---   and 'Optional' constructors are normalized away.+--   'Optional' and 'RESet' constructors are normalized away.  extREtoRE :: RegExp sy -> RegExp sy extREtoRE  = cataRegExp ( Empty@@ -257,6 +266,7 @@                         , \ l r -> Then l r                          , \ er  -> Then er (Star er)                         , \ er  -> Or Epsilon er+                        , \ set -> foldr1 Or (map Literal set)                         )   -----------------------------------------------------------------------------
HaLeX_lib/Language/HaLex/RegExp2Fa.hs view
@@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Language.HaLex.RegExp2Fa--- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005+-- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005,2016 -- License     :  LGPL -- -- Maintainer  :  jas@di.uminho.pt@@ -111,6 +111,21 @@                  dd' q Nothing = sp `union` z'                 dd' _ _ = []++regExp2Ndfa' (RESet set) n = (Ndfa set [ss,zs] [ss] [zs] delta , n+2)+  where ss = n+        zs = n+1 +        delta q (Just v) | q == ss && (v `elem` set) = [zs]+        delta _ _ = []+++regExp2Ndfa' (OneOrMore re) n = regExp2Ndfa' re' n+  where re' = re ` Then` (Star re)++regExp2Ndfa' (Optional re) n = regExp2Ndfa' re' n+  where re' = Epsilon `Or` re++  -- | Compute a 'Dfa' from a 'RegExp'. --   (via the intermediate 'Ndfa')
HaLeX_lib/Language/HaLex/RegExpParser.hs view
@@ -2,7 +2,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Language.HaLex.Dfa--- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005+-- Copyright   :  (c) João Saraiva 2001,2002,2003,2004,2005, 2016 -- License     :  LGPL -- -- Maintainer  :  jas@di.uminho.pt@@ -61,13 +61,42 @@ factor =  f <$> letterOrDigit       <|> g <$> symbol '\'' <*> satisfy (\ x -> True) <*> symbol '\''       <|> h <$> symbol '(' <*> expr <*> symbol ')'+      <|> k <$> symbol '[' <*> (oneOrMore range) <*> symbol ']'+      <|> l <$> symbol '[' <*> symbol '^' <*> range <*> symbol ']'   where-     f a     = Literal a-     g _ e _ = Literal e-     h _ e _ = e+     f a         = Literal a+     g _ e _     = Literal e+     h _ e _     = e+     k _ l _     = RESet (concat l)+     l _ _ l _   = RESet [ x | x <- ascii+                         , not (x `elem` l)+			 ]  +range :: Parser Char [Char]+range  =  f   <$> letterOrDigit <*> symbol '-' <*> letterOrDigit+      <|> id  <$> oneOrMore (satisfy (\ x -> x `elem` ascii+                                             && x /= '-' && x /= '^'))+  where f a _ c = [a..c]++      + letterOrDigit :: Parser Char Char letterOrDigit = satisfy (\x -> isDigit x || isAlpha x)++setRegExp :: Char                -- ^ first elem of the set+          -> Char                -- ^ last elem of the set+          -> RegExp Char         -- ^ Regular Expression for the set+setRegExp a b = foldr1 Or (map Literal [a..b])++++-- Ascii characteres (C Language)+ascii =  ['a'..'z']                             -- lower letter+      ++ ['A'..'Z']                             -- capital letters+      ++ [' ','\n','\t']                        -- Tab Or New line Or Space+      ++ "~|#$%^&*)(_+|\\`-={}[]:\";<>?,./"     -- Special Characters++  -- Not used yet spaces :: Parser Char ()
INSTALL view
@@ -1,7 +1,7 @@    HaLeX: A Haskell Library to Model,                                Manipulate and -                              Animate Regular Languages+                              Visualize Regular Languages          http://www.di.uminho.pt/~jas/Research/HaLeX @@ -12,7 +12,7 @@           jas@di.uminho.pt  -Version: 1.2.2 (August, 2016)+Version: 1.2.4 (January, 2017)   - halex batch tool
README.md view
@@ -4,7 +4,7 @@    HaLeX: A Haskell Library to Model,                                Manipulate and -                              Animate Regular Languages+                              Visualize Regular Languages          http://www.di.uminho.pt/~jas/Research/HaLeX @@ -12,10 +12,10 @@           Department of Computer Science,           University of Minho,            Braga, Portugal-          jas@di.uminho.pt+          saraiva@di.uminho.pt  -Version: 1.2.2 (August, 2016)+Version: 1.2.4 (January, 2017)   1- What is HaleX