module UVMHS.Lib.Parser.Examples where

import UVMHS.Core
import UVMHS.Lib.Pretty
import UVMHS.Lib.Parser.Core
import UVMHS.Lib.Parser.ParserInput
import UVMHS.Lib.Parser.Regex
import UVMHS.Lib.Parser.CParser

testParsingSmall  IO ()
testParsingSmall :: IO ()
testParsingSmall = CParser ℂ 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain CParser ℂ 𝕊
parser 𝕊
"<small example>" 𝕍 (ParserToken ℂ)
input
  where
    parser :: CParser ℂ 𝕊
parser = 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord (𝕊 -> CParser ℂ 𝕊) -> 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ [ℂ] -> 𝕊
𝕤 [ℂ]
"xyzxyz"
    input :: 𝕍 (ParserToken ℂ)
input = 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xyzxycxyz"

testParsingMultiline  IO ()
testParsingMultiline :: IO ()
testParsingMultiline = CParser ℂ () -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain CParser ℂ ()
parser 𝕊
"<multiline example>" 𝕍 (ParserToken ℂ)
input
  where
    parser :: CParser ℂ ()
parser = 𝐼 (CParser ℂ ()) -> CParser ℂ ()
forall (m :: * -> *) t. (Monad m, ToIter (m ()) t) => t -> m ()
exec (𝐼 (CParser ℂ ()) -> CParser ℂ ())
-> 𝐼 (CParser ℂ ()) -> CParser ℂ ()
forall a b. (a -> b) -> a -> b
$ CParser ℂ () -> 𝐿 (CParser ℂ ()) -> 𝐼 (CParser ℂ ())
forall a t. ToIter a t => a -> t -> 𝐼 a
inbetween (CParser ℂ 𝕊 -> CParser ℂ ()
forall (m :: * -> *) a. Functor m => m a -> m ()
void (CParser ℂ 𝕊 -> CParser ℂ ()) -> CParser ℂ 𝕊 -> CParser ℂ ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord (𝕊 -> CParser ℂ 𝕊) -> 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ [ℂ] -> 𝕊
𝕤 [ℂ]
"\n") (𝐿 (CParser ℂ ()) -> 𝐼 (CParser ℂ ()))
-> 𝐿 (CParser ℂ ()) -> 𝐼 (CParser ℂ ())
forall a b. (a -> b) -> a -> b
$ 𝐼 (CParser ℂ ()) -> 𝐿 (CParser ℂ ())
forall a t. ToIter a t => t -> 𝐿 a
list (𝐼 (CParser ℂ ()) -> 𝐿 (CParser ℂ ()))
-> 𝐼 (CParser ℂ ()) -> 𝐿 (CParser ℂ ())
forall a b. (a -> b) -> a -> b
$ ℕ -> (ℕ -> CParser ℂ ()) -> 𝐼 (CParser ℂ ())
forall n a. (Eq n, Zero n, One n, Plus n) => n -> (n -> a) -> 𝐼 a
replicateI (ℕ -> ℕ
𝕟 7) ((ℕ -> CParser ℂ ()) -> 𝐼 (CParser ℂ ()))
-> (ℕ -> CParser ℂ ()) -> 𝐼 (CParser ℂ ())
forall a b. (a -> b) -> a -> b
$ \ n  𝕊 -> CParser ℂ () -> CParser ℂ ()
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpNewContext 𝕊
"line" (CParser ℂ () -> CParser ℂ ()) -> CParser ℂ () -> CParser ℂ ()
forall a b. (a -> b) -> a -> b
$ CParser ℂ 𝕊 -> CParser ℂ ()
forall (m :: * -> *) a. Functor m => m a -> m ()
void (CParser ℂ 𝕊 -> CParser ℂ ()) -> CParser ℂ 𝕊 -> CParser ℂ ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord (𝕊
"xyz" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 n)
    input :: 𝕍 (ParserToken ℂ)
input = 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xyz0\nxyz1\nxyz2\nxyc3\nxyz4\nxyz5\nxyz6\n"

testParsingBranching  IO ()
testParsingBranching :: IO ()
testParsingBranching = CParser ℂ 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain CParser ℂ 𝕊
parser 𝕊
"<branching example>" 𝕍 (ParserToken ℂ)
input
  where
    parser  CParser  𝕊
    parser :: CParser ℂ 𝕊
parser = [CParser ℂ 𝕊] -> CParser ℂ 𝕊
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries
      [ 𝕊 -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpNewContext 𝕊
"XXX*" (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ [CParser ℂ 𝕊] -> CParser ℂ 𝕊
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries
          [ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
pink]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xxxy"
          , Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
pink]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xxxz"
          ]
      , 𝕊 -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpNewContext 𝕊
"XXXZ" (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ do
          𝕊
x  𝕊 -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpErr 𝕊
"XX" (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
blue]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xx"
          𝕊
y  𝕊 -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpErr 𝕊
"XZ" (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
green]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xz"
          𝕊 -> CParser ℂ 𝕊
forall a. a -> CParser ℂ a
forall (m :: * -> *) a. Return m => a -> m a
return (𝕊 -> CParser ℂ 𝕊) -> 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊
x 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
y
      , 𝕊 -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpNewContext 𝕊
"XXZZ" (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xxzz"
      , 𝕊 -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => 𝕊 -> CParser t a -> CParser t a
cpNewContext 𝕊
"XXXAorB" (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
teal]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ do
          𝕊
x  𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xxx"
          𝕊
y  ℂ -> 𝕊
forall a t. Single a t => a -> t
single (ℂ -> 𝕊) -> CParser ℂ ℂ -> CParser ℂ 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ [CParser ℂ ℂ] -> CParser ℂ ℂ
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries
            [ ℂ -> CParser ℂ ℂ
forall t. Ord t => t -> CParser t t
cpToken 'a'
            , ℂ -> CParser ℂ ℂ
forall t. Ord t => t -> CParser t t
cpToken 'b'
            ]
          𝕊 -> CParser ℂ 𝕊
forall a. a -> CParser ℂ a
forall (m :: * -> *) a. Return m => a -> m a
return (𝕊 -> CParser ℂ 𝕊) -> 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊
x 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
y
      ]
    input  𝕍 (ParserToken )
    input :: 𝕍 (ParserToken ℂ)
input = 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxxx"
    
-- testParsingAmbiguity ∷ IO ()
-- testParsingAmbiguity = parseIOMain parser input
--   where
--     parser = concat ^$ pOneOrMore $ tries 
--       [ ppFG yellow ∘ ppString ∘ single ^$ pToken 'y'
--       , ppFG green ∘ ppString ∘ single ^$ pToken 'x'
--       , ppFG blue ∘ ppString ^$ pWord "xx" 
--       ]
--     input = tokens "xxx"

testParsingGreedy  IO ()
testParsingGreedy :: IO ()
testParsingGreedy = CParser ℂ Doc -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain CParser ℂ Doc
parser 𝕊
"<greedy example>" 𝕍 (ParserToken ℂ)
input
  where
    parser :: CParser ℂ Doc
parser = 𝐿 Doc -> Doc
forall a t. (Monoid a, ToIter a t) => t -> a
concat (𝐿 Doc -> Doc) -> CParser ℂ (𝐿 Doc) -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ CParser ℂ Doc -> CParser ℂ (𝐿 Doc)
forall t a. Ord t => CParser t a -> CParser t (𝐿 a)
cpOneOrMore (CParser ℂ Doc -> CParser ℂ (𝐿 Doc))
-> CParser ℂ Doc -> CParser ℂ (𝐿 Doc)
forall a b. (a -> b) -> a -> b
$ [CParser ℂ Doc] -> CParser ℂ Doc
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries 
      [ Color -> Doc -> Doc
ppFG Color
yellow (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> (ℂ -> 𝕊) -> ℂ -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 ℂ -> 𝕊
forall a t. Single a t => a -> t
single (ℂ -> Doc) -> CParser ℂ ℂ -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ ℂ -> CParser ℂ ℂ
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
yellow]) (CParser ℂ ℂ -> CParser ℂ ℂ) -> CParser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ Parser ℂ ℂ -> CParser ℂ ℂ
forall t a. Parser t a -> CParser t a
toCParser (Parser ℂ ℂ -> CParser ℂ ℂ) -> Parser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ ℂ -> Parser ℂ ℂ
forall t. Eq t => t -> Parser t t
pToken 'y'
      , Color -> Doc -> Doc
ppFG Color
green (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> (ℂ -> 𝕊) -> ℂ -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 ℂ -> 𝕊
forall a t. Single a t => a -> t
single (ℂ -> Doc) -> CParser ℂ ℂ -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ ℂ -> CParser ℂ ℂ
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
green]) (CParser ℂ ℂ -> CParser ℂ ℂ) -> CParser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ Parser ℂ ℂ -> CParser ℂ ℂ
forall t a. Parser t a -> CParser t a
toCParser (Parser ℂ ℂ -> CParser ℂ ℂ) -> Parser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ ℂ -> Parser ℂ ℂ
forall t. Eq t => t -> Parser t t
pToken 'x'
      , Color -> Doc -> Doc
ppFG Color
blue (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> CParser ℂ 𝕊 -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
yellow]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xx" 
      ]
    input :: 𝕍 (ParserToken ℂ)
input = 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxx"

testParsingGreedyAmbiguity  IO ()
testParsingGreedyAmbiguity :: IO ()
testParsingGreedyAmbiguity = CParser ℂ Doc -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain CParser ℂ Doc
parser 𝕊
"<greedy ambiguity example>" 𝕍 (ParserToken ℂ)
input
  where
    parser :: CParser ℂ Doc
parser = 𝐿 Doc -> Doc
forall a t. (Monoid a, ToIter a t) => t -> a
concat (𝐿 Doc -> Doc) -> CParser ℂ (𝐿 Doc) -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ CParser ℂ Doc -> CParser ℂ (𝐿 Doc)
forall t a. Ord t => CParser t a -> CParser t (𝐿 a)
cpOneOrMore (CParser ℂ Doc -> CParser ℂ (𝐿 Doc))
-> CParser ℂ Doc -> CParser ℂ (𝐿 Doc)
forall a b. (a -> b) -> a -> b
$ [CParser ℂ Doc] -> CParser ℂ Doc
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries 
      [ Color -> Doc -> Doc
ppFG Color
yellow (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> (ℂ -> 𝕊) -> ℂ -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 ℂ -> 𝕊
forall a t. Single a t => a -> t
single (ℂ -> Doc) -> CParser ℂ ℂ -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ ℂ -> CParser ℂ ℂ
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
yellow]) (CParser ℂ ℂ -> CParser ℂ ℂ) -> CParser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ Parser ℂ ℂ -> CParser ℂ ℂ
forall t a. Parser t a -> CParser t a
toCParser (Parser ℂ ℂ -> CParser ℂ ℂ) -> Parser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ ℂ -> Parser ℂ ℂ
forall t. Eq t => t -> Parser t t
pToken 'y'
      , [CParser ℂ Doc] -> CParser ℂ Doc
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries
          [ Color -> Doc -> Doc
ppFG Color
blue (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> CParser ℂ 𝕊 -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
blue]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"x" 
          , Color -> Doc -> Doc
ppFG Color
pink (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> CParser ℂ 𝕊 -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
pink]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord 𝕊
"xx" 
          ]
      , Color -> Doc -> Doc
ppFG Color
green (Doc -> Doc) -> (𝕊 -> Doc) -> 𝕊 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝕊 -> Doc
ppString (𝕊 -> Doc) -> (ℂ -> 𝕊) -> ℂ -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
 ℂ -> 𝕊
forall a t. Single a t => a -> t
single (ℂ -> Doc) -> CParser ℂ ℂ -> CParser ℂ Doc
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ Formats -> CParser ℂ ℂ -> CParser ℂ ℂ
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
green]) (CParser ℂ ℂ -> CParser ℂ ℂ) -> CParser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ Parser ℂ ℂ -> CParser ℂ ℂ
forall t a. Parser t a -> CParser t a
toCParser (Parser ℂ ℂ -> CParser ℂ ℂ) -> Parser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ ℂ -> Parser ℂ ℂ
forall t. Eq t => t -> Parser t t
pToken 'x'
      ]
    input :: 𝕍 (ParserToken ℂ)
input = 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxx"

testParsingSuccess  IO ()
testParsingSuccess :: IO ()
testParsingSuccess = CParser ℂ 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain CParser ℂ 𝕊
parser 𝕊
"<success example>" 𝕍 (ParserToken ℂ)
input
  where
    parser :: CParser ℂ 𝕊
parser = 𝐿 𝕊 -> 𝕊
forall a t. (Monoid a, ToIter a t) => t -> a
concat (𝐿 𝕊 -> 𝕊) -> CParser ℂ (𝐿 𝕊) -> CParser ℂ 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ CParser ℂ 𝕊 -> CParser ℂ (𝐿 𝕊)
forall t a. Ord t => CParser t a -> CParser t (𝐿 a)
cpOneOrMore (CParser ℂ 𝕊 -> CParser ℂ (𝐿 𝕊)) -> CParser ℂ 𝕊 -> CParser ℂ (𝐿 𝕊)
forall a b. (a -> b) -> a -> b
$ [CParser ℂ 𝕊] -> CParser ℂ 𝕊
forall (m :: * -> *) a t.
(Monad m, MonadFail m, ToIter (m a) t) =>
t -> m a
tries 
      [ Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
green]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord (𝕊 -> CParser ℂ 𝕊) -> 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ [ℂ] -> 𝕊
𝕤 [ℂ]
"xx"
      , Formats -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall t a. Ord t => Formats -> CParser t a -> CParser t a
cpRender ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
blue]) (CParser ℂ 𝕊 -> CParser ℂ 𝕊) -> CParser ℂ 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> CParser ℂ 𝕊
forall s t. (Eq t, s ⇄ 𝐼 t) => s -> CParser t s
cpWord (𝕊 -> CParser ℂ 𝕊) -> 𝕊 -> CParser ℂ 𝕊
forall a b. (a -> b) -> a -> b
$ [ℂ] -> 𝕊
𝕤 [ℂ]
"yy"
      ]
    input :: 𝕍 (ParserToken ℂ)
input = 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxxxyyxxyy"

testParsingErrorNewline  IO ()
testParsingErrorNewline :: IO ()
testParsingErrorNewline = CParser ℂ 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain (𝐿 ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string (𝐿 ℂ -> 𝕊) -> CParser ℂ (𝐿 ℂ) -> CParser ℂ 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ CParser ℂ ℂ -> CParser ℂ (𝐿 ℂ)
forall t a. Ord t => CParser t a -> CParser t (𝐿 a)
cpMany (CParser ℂ ℂ -> CParser ℂ (𝐿 ℂ)) -> CParser ℂ ℂ -> CParser ℂ (𝐿 ℂ)
forall a b. (a -> b) -> a -> b
$ Parser ℂ ℂ -> CParser ℂ ℂ
forall t a. Parser t a -> CParser t a
toCParser (Parser ℂ ℂ -> CParser ℂ ℂ) -> Parser ℂ ℂ -> CParser ℂ ℂ
forall a b. (a -> b) -> a -> b
$ ℂ -> Parser ℂ ℂ
forall t. Eq t => t -> Parser t t
pToken 'x') 𝕊
"<error newline example>" (𝕍 (ParserToken ℂ) -> IO ()) -> 𝕍 (ParserToken ℂ) -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxx\nx"

testParsingErrorEof  IO ()
testParsingErrorEof :: IO ()
testParsingErrorEof = CParser ℂ () -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall a t ts.
(Pretty a, ToIter (ParserToken t) ts, Ord t) =>
CParser t a -> 𝕊 -> ts -> IO ()
parseIOMain (𝐼 (CParser ℂ ()) -> CParser ℂ ()
forall (m :: * -> *) t. (Monad m, ToIter (m ()) t) => t -> m ()
exec (𝐼 (CParser ℂ ()) -> CParser ℂ ())
-> 𝐼 (CParser ℂ ()) -> CParser ℂ ()
forall a b. (a -> b) -> a -> b
$ ℕ -> CParser ℂ () -> 𝐼 (CParser ℂ ())
forall n a. (Eq n, Zero n, One n, Plus n) => n -> a -> 𝐼 a
replicate (ℕ -> ℕ
𝕟 3) (CParser ℂ () -> 𝐼 (CParser ℂ ()))
-> CParser ℂ () -> 𝐼 (CParser ℂ ())
forall a b. (a -> b) -> a -> b
$ CParser ℂ ℂ -> CParser ℂ ()
forall (m :: * -> *) a. Functor m => m a -> m ()
void (CParser ℂ ℂ -> CParser ℂ ()) -> CParser ℂ ℂ -> CParser ℂ ()
forall a b. (a -> b) -> a -> b
$ ℂ -> CParser ℂ ℂ
forall t. Ord t => t -> CParser t t
cpToken 'x') 𝕊
"<error eof example>" (𝕍 (ParserToken ℂ) -> IO ()) -> 𝕍 (ParserToken ℂ) -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xx"

testTokenizeSimple  IO ()
testTokenizeSimple :: IO ()
testTokenizeSimple = 
  let rgx :: Regex CharClass ℂ () ()
rgx = 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"x" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 () -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
o -> Regex c t o u
oepsRegex ()
      dfa :: DFA CharClass ℂ () ()
dfa = Regex CharClass ℂ () () -> DFA CharClass ℂ () ()
forall c t o u.
(Pretty t, Pretty o, Pretty u, Ord c, Ord t, Classified c t, All c,
 Ord o, Ord u, Additive u) =>
Regex c t o u -> DFA c t o u
compileRegex Regex CharClass ℂ () ()
rgx
  in Lexer CharClass ℂ () () 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall c t o u w.
(Show u, Ord c, Ord t, Pretty t, Classified c t, Eq o, Eq u,
 Plus u, Pretty w) =>
Lexer c t o u w -> 𝕊 -> 𝕍 (ParserToken t) -> IO ()
tokenizeIOMain ((() -> DFA CharClass ℂ () ())
-> (𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊) -> () -> Lexer CharClass ℂ () () 𝕊
forall c t o u w.
(u -> DFA c t o u)
-> (𝐼C t -> 𝑂 o -> 𝔹 ∧ w) -> u -> Lexer c t o u w
Lexer (DFA CharClass ℂ () () -> () -> DFA CharClass ℂ () ()
forall a b. a -> b -> a
const DFA CharClass ℂ () ()
dfa) ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a
const ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝕊 -> 𝔹 ∧ 𝕊) -> 𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (𝔹 -> 𝕊 -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a ∧ b
(:*) 𝔹
False) (𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝐼C ℂ -> 𝕊) -> 𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝐼C ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) ()) 𝕊
"<tokenize simple example>" (𝕍 (ParserToken ℂ) -> IO ()) -> 𝕍 (ParserToken ℂ) -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxx"

testTokenize  IO ()
testTokenize :: IO ()
testTokenize = 
  let rgx :: Regex CharClass ℂ () ()
rgx = [Regex CharClass ℂ () ()] -> Regex CharClass ℂ () ()
forall a t. (Monoid a, ToIter a t) => t -> a
concat [𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"x",𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xy",𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"y"] Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 () -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
o -> Regex c t o u
oepsRegex ()
      dfa :: DFA CharClass ℂ () ()
dfa = Regex CharClass ℂ () () -> DFA CharClass ℂ () ()
forall c t o u.
(Pretty t, Pretty o, Pretty u, Ord c, Ord t, Classified c t, All c,
 Ord o, Ord u, Additive u) =>
Regex c t o u -> DFA c t o u
compileRegex Regex CharClass ℂ () ()
rgx
  in Lexer CharClass ℂ () () 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall c t o u w.
(Show u, Ord c, Ord t, Pretty t, Classified c t, Eq o, Eq u,
 Plus u, Pretty w) =>
Lexer c t o u w -> 𝕊 -> 𝕍 (ParserToken t) -> IO ()
tokenizeIOMain ((() -> DFA CharClass ℂ () ())
-> (𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊) -> () -> Lexer CharClass ℂ () () 𝕊
forall c t o u w.
(u -> DFA c t o u)
-> (𝐼C t -> 𝑂 o -> 𝔹 ∧ w) -> u -> Lexer c t o u w
Lexer (DFA CharClass ℂ () () -> () -> DFA CharClass ℂ () ()
forall a b. a -> b -> a
const DFA CharClass ℂ () ()
dfa) ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a
const ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝕊 -> 𝔹 ∧ 𝕊) -> 𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (𝔹 -> 𝕊 -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a ∧ b
(:*) 𝔹
False) (𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝐼C ℂ -> 𝕊) -> 𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝐼C ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) ()) 𝕊
"<tokenize example>" (𝕍 (ParserToken ℂ) -> IO ()) -> 𝕍 (ParserToken ℂ) -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxyxyxyxyxxyy"

testTokenizeFailure1  IO ()
testTokenizeFailure1 :: IO ()
testTokenizeFailure1 = 
  let rgx :: Regex CharClass ℂ () ()
rgx = [Regex CharClass ℂ () ()] -> Regex CharClass ℂ () ()
forall a t. (Monoid a, ToIter a t) => t -> a
concat
        [ 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"x" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
green]) Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 ℕ64 -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
ℕ64 -> Regex c t o u
lepsRegex (ℕ -> ℕ64
𝕟64 2)
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"x" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
yellow]) Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 ℕ64 -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
ℕ64 -> Regex c t o u
lepsRegex (ℕ -> ℕ64
𝕟64 1)
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xx" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
blue])
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xy" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
teal])
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xz" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
pink])
        ] Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 () -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
o -> Regex c t o u
oepsRegex ()
      dfa :: DFA CharClass ℂ () ()
dfa = Regex CharClass ℂ () () -> DFA CharClass ℂ () ()
forall c t o u.
(Pretty t, Pretty o, Pretty u, Ord c, Ord t, Classified c t, All c,
 Ord o, Ord u, Additive u) =>
Regex c t o u -> DFA c t o u
compileRegex Regex CharClass ℂ () ()
rgx
  in Lexer CharClass ℂ () () 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall c t o u w.
(Show u, Ord c, Ord t, Pretty t, Classified c t, Eq o, Eq u,
 Plus u, Pretty w) =>
Lexer c t o u w -> 𝕊 -> 𝕍 (ParserToken t) -> IO ()
tokenizeIOMain ((() -> DFA CharClass ℂ () ())
-> (𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊) -> () -> Lexer CharClass ℂ () () 𝕊
forall c t o u w.
(u -> DFA c t o u)
-> (𝐼C t -> 𝑂 o -> 𝔹 ∧ w) -> u -> Lexer c t o u w
Lexer (DFA CharClass ℂ () () -> () -> DFA CharClass ℂ () ()
forall a b. a -> b -> a
const DFA CharClass ℂ () ()
dfa) ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a
const ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝕊 -> 𝔹 ∧ 𝕊) -> 𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (𝔹 -> 𝕊 -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a ∧ b
(:*) 𝔹
False) (𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝐼C ℂ -> 𝕊) -> 𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝐼C ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) ()) 𝕊
"<tokenize failure1 example>" (𝕍 (ParserToken ℂ) -> IO ()) -> 𝕍 (ParserToken ℂ) -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxxxy"

testTokenizeFailure2  IO ()
testTokenizeFailure2 :: IO ()
testTokenizeFailure2 = 
  let rgx :: Regex CharClass ℂ () ()
rgx = [Regex CharClass ℂ () ()] -> Regex CharClass ℂ () ()
forall a t. (Monoid a, ToIter a t) => t -> a
concat
        [ 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"x" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
green]) Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 ℕ64 -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
ℕ64 -> Regex c t o u
lepsRegex (ℕ -> ℕ64
𝕟64 2)
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"x" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
yellow]) Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 ℕ64 -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
ℕ64 -> Regex c t o u
lepsRegex (ℕ -> ℕ64
𝕟64 1)
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xx" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
blue])
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xy" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
teal])
        , 𝕊 -> Regex CharClass ℂ () ()
forall u o.
(Zero u, Ord o, Ord u, Additive u) =>
𝕊 -> Regex CharClass ℂ o u
lWord 𝕊
"xz" Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 Formats -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
Formats -> Regex c t o u
fepsRegex ([Format] -> Formats
forall t. ToIter Format t => t -> Formats
formats [Color -> Format
FG Color
pink])
        ] Regex CharClass ℂ () ()
-> Regex CharClass ℂ () () -> Regex CharClass ℂ () ()
forall a. Seq a => a -> a -> a
 () -> Regex CharClass ℂ () ()
forall c t o u.
(Ord c, Ord t, Ord o, Ord u, Zero u) =>
o -> Regex c t o u
oepsRegex ()
      dfa :: DFA CharClass ℂ () ()
dfa = Regex CharClass ℂ () () -> DFA CharClass ℂ () ()
forall c t o u.
(Pretty t, Pretty o, Pretty u, Ord c, Ord t, Classified c t, All c,
 Ord o, Ord u, Additive u) =>
Regex c t o u -> DFA c t o u
compileRegex Regex CharClass ℂ () ()
rgx
  in Lexer CharClass ℂ () () 𝕊 -> 𝕊 -> 𝕍 (ParserToken ℂ) -> IO ()
forall c t o u w.
(Show u, Ord c, Ord t, Pretty t, Classified c t, Eq o, Eq u,
 Plus u, Pretty w) =>
Lexer c t o u w -> 𝕊 -> 𝕍 (ParserToken t) -> IO ()
tokenizeIOMain ((() -> DFA CharClass ℂ () ())
-> (𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊) -> () -> Lexer CharClass ℂ () () 𝕊
forall c t o u w.
(u -> DFA c t o u)
-> (𝐼C t -> 𝑂 o -> 𝔹 ∧ w) -> u -> Lexer c t o u w
Lexer (DFA CharClass ℂ () () -> () -> DFA CharClass ℂ () ()
forall a b. a -> b -> a
const DFA CharClass ℂ () ()
dfa) ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a
const ((𝔹 ∧ 𝕊) -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝕊 -> 𝔹 ∧ 𝕊) -> 𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (𝔹 -> 𝕊 -> 𝔹 ∧ 𝕊
forall a b. a -> b -> a ∧ b
(:*) 𝔹
False) (𝕊 -> 𝑂 () -> 𝔹 ∧ 𝕊) -> (𝐼C ℂ -> 𝕊) -> 𝐼C ℂ -> 𝑂 () -> 𝔹 ∧ 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝐼C ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string) ()) 𝕊
"<tokenize failiure2 example>" (𝕍 (ParserToken ℂ) -> IO ()) -> 𝕍 (ParserToken ℂ) -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝕍 (ParserToken ℂ)
tokens 𝕊
"xxxyxxxzxc"