{-| This model contains unit-tests for 'GLL.Combinators.Interface'.

= Included examples

  * Elementary parsers
  * Sequencing
  * Alternatives
  * Simple binding
  * Binding with alternatives
  * Recursion (non-left)

  * Higher-order patterns:

      * Optional
      * Kleene-closure / positive closure
      * Seperator
      * Inline choice

  * Ambiguities:

      * "aaa"
      * longambig
      * aho_s
      * EEE

  * Left recursion
  * Hidden left-recursion
-}
module GLL.Combinators.Test.BinaryInterface where

import Control.Monad
import Data.Char (ord)
import Data.List (sort, nub)
import Data.IORef

import GLL.Combinators.BinaryInterface
import GLL.Parseable.Char ()

-- | Defines and executes multiple1 unit-tests 
main :: IO ()
main = do
    IORef Integer
count <- forall a. a -> IO (IORef a)
newIORef Integer
1
    let test :: Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test Maybe (MemoRef a)
mref [Char]
name s t a
p t ([t], [a])
arg_pairs = do
            Integer
i <- forall a. IORef a -> IO a
readIORef IORef Integer
count
            forall a. IORef a -> (a -> a) -> IO ()
modifyIORef IORef Integer
count forall a. Enum a => a -> a
succ
            IORef Char
subcount <- forall a. a -> IO (IORef a)
newIORef Char
'a'
            [Char] -> IO ()
putStrLn ([Char]
">> testing " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Integer
i forall a. [a] -> [a] -> [a]
++ [Char]
" (" forall a. [a] -> [a] -> [a]
++ [Char]
name forall a. [a] -> [a] -> [a]
++ [Char]
")")
            forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ t ([t], [a])
arg_pairs forall a b. (a -> b) -> a -> b
$ \([t]
str,[a]
res) -> do
                case Maybe (MemoRef a)
mref of -- empty memtable between parses
                    Maybe (MemoRef a)
Nothing     -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
                    Just MemoRef a
ref    -> forall a. MemoRef a -> IO ()
memClear MemoRef a
ref 
                Char
j <- forall a. IORef a -> IO a
readIORef IORef Char
subcount
                forall a. IORef a -> (a -> a) -> IO ()
modifyIORef IORef Char
subcount forall a. Enum a => a -> a
succ
                let parse_res :: [a]
parse_res   = forall t (s :: * -> * -> *) a.
(Show t, Parseable t, IsSymbExpr s) =>
ParseOptions -> CombinatorOptions -> s t a -> [t] -> [a]
parseWithParseOptions [ParseOption
noSelectTest] [CombinatorOption
useMemoisation] s t a
p [t]
str
                    norm :: [a] -> [a]
norm        = forall a. Int -> [a] -> [a]
take Int
100 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => [a] -> [a]
sort forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a]
nub
                    norm_p_res :: [a]
norm_p_res  = [a] -> [a]
norm [a]
parse_res
                    b :: Bool
b           = [a]
norm_p_res forall a. Eq a => a -> a -> Bool
== [a] -> [a]
norm [a]
res
                [Char] -> IO ()
putStrLn ([Char]
"  >> " forall a. [a] -> [a] -> [a]
++ [Char
j,Char
')',Char
' '] forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Bool
b)
                forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
b ([Char] -> IO ()
putStrLn ([Char]
"    >> " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show [a]
norm_p_res))

    --  Elementary parsers
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"eps1" (forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0) [([Char]
"", [Integer
0])]
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"eps2" (forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0) [([Char]
"", [Integer
0]), ([Char]
"111", [])]
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"single" (Char -> SymbExpr Char Char
char Char
'a') [([Char]
"a", [Char
'a'])
                    ,([Char]
"abc", [])]
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"semfun1" (Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a') [([Char]
"a", [Integer
1])]

    --  Elementary combinators
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<**>" ((\Char
b -> [Char
'1',Char
b]) forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> Char -> SymbExpr Char Char
char Char
'b')
         [([Char]
"ab", [[Char]
"1b"])
         ,([Char]
"b", [])]
   
    --  Alternation
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<||>" (Char -> Int
ord forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> Char -> SymbExpr Char Char
char Char
'b' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Char -> Int
ord forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> Char -> SymbExpr Char Char
char Char
'c')
         [([Char]
"a", []), ([Char]
"ab", [Int
98]), ([Char]
"c", [Int
99]), ([Char]
"cab", [])]

    --  Simple binding
    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> Char -> Int
ord forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'b'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<:=>" BNF Char Int
pX [([Char]
"ab",[Int
97]),([Char]
"a",[])]

    --  Simple binding
    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> Char -> Int
ord forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'b'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<::=>" BNF Char Int
pX [([Char]
"ab",[Int
97]),([Char]
"a",[])]

    let  pX :: BNF Char [Char]
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall a b c. (a -> b -> c) -> b -> a -> c
flip (:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char [Char]
pY forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> Char -> SymbExpr Char Char
char Char
'a'
         pY :: BNF Char [Char]
pY = [Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> (\Char
x Char
y -> [Char
x,Char
y]) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> Char -> SymbExpr Char Char
char Char
'b' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> Char -> SymbExpr Char Char
char Char
'c'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<::=> 2" BNF Char [Char]
pX [([Char]
"bca", [[Char]
"abc"]), ([Char]
"cba", [])]

    --  Binding with alternatives
    let pX :: SymbExpr Char Char
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> SymbExpr Char Char
pY forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'c'
        pY :: SymbExpr Char Char
pY = [Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Char -> SymbExpr Char Char
char Char
'b'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<::=> <||>" SymbExpr Char Char
pX [([Char]
"ac", [Char]
"a"), ([Char]
"bc", [Char]
"b")]

    --  (Right) Recursion
    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (forall a. Num a => a -> a -> a
+Integer
1) forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pX forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0 
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"rec1" BNF Char Integer
pX [([Char]
"", [Integer
0]), ([Char]
"aa",[Integer
2]), (forall a. Int -> a -> [a]
replicate Int
42 Char
'a', [Integer
42]), ([Char]
"bbb", [])]

    --  EBNF
    let pX :: BNF Char (Maybe Char)
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. a -> a
id forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'b' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"optional" BNF Char (Maybe Char)
pX [([Char]
"abz", [forall a. a -> Maybe a
Just Char
'z']), ([Char]
"abab", []), ([Char]
"ab", [forall a. Maybe a
Nothing])]

    let pX :: SymbExpr Char Char
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Char -> SymbExpr Char Char
char Char
'b')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"<||> optional" (SymbExpr Char Char
pX forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z'))
                [([Char]
"az", [Char]
"a"), ([Char]
"bz", [Char]
"b"), ([Char]
"z", []), ([Char]
"b", [Char]
"b"), ([Char]
"a", [Char]
"a")]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'a') forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'b'))
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"optional-ambig" (BNF Char Integer
pX forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z'))
                [([Char]
"az", [Integer
1]), ([Char]
"bz", [Integer
2]), ([Char]
"z", [Integer
1,Integer
2]), ([Char]
"b", [Integer
2]), ([Char]
"a", [Integer
1])]

    let pX :: SymbExpr Char Char
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. a -> a
id forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> (Char -> SymbExpr Char Char
char Char
'b' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Char -> SymbExpr Char Char
char Char
'c')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"inline choice (1)" SymbExpr Char Char
pX
                [([Char]
"ab", [Char]
"b"), ([Char]
"ac", [Char]
"c"), ([Char]
"a", []), ([Char]
"b", [])]

    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'1')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple" BNF Char Int
pX [([Char]
"", [Int
0]), ([Char]
"11", [Int
2]), (forall a. Int -> a -> [a]
replicate Int
12 Char
'1', [Int
12])]

    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple1 (Char -> SymbExpr Char Char
char Char
'1')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple1" BNF Char Int
pX [([Char]
"", []), ([Char]
"11", [Int
2]), (forall a. Int -> a -> [a]
replicate Int
12 Char
'1', [Int
12])]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'a') forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'b')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"(multiple <||> multiple) <**> optional" (BNF Char Integer
pX forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z'))
                [([Char]
"az", [Integer
1]), ([Char]
"bz", [Integer
2]), ([Char]
"z", [Integer
1,Integer
2])
                ,([Char]
"", [Integer
1,Integer
2]), ([Char]
"b", [Integer
2]), ([Char]
"a", [Integer
1])]

    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> BNF Char Int
pY forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z')
         where pY :: BNF Char Int
pY = [Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'a')
                          forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple1 (Char -> SymbExpr Char Char
char Char
'b') forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'e'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple & multiple1 & optional" 
        BNF Char Int
pX  [([Char]
"aaaz", [Int
3]), ([Char]
"bbbez", [Int
3]), ([Char]
"ez", []), ([Char]
"z", [Int
0])
            ,([Char]
"aa", [Int
2]), ([Char]
"bbe", [Int
2]) 
            ]

    -- multiple with nullable argument
    let pX :: BNF Char Integer
pX = Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple (nullable arg)" 
        (forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple BNF Char Integer
pX) [([Char]
"11", [[Integer
1,Integer
1]]), ([Char]
"",[[]]), ([Char]
"e", [])]

    --  Simple ambiguities
    let pX :: BNF Char [Char]
pX = forall a. [a] -> [a] -> [a]
(++) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char [Char]
pA forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char [Char]
pB
        pA :: BNF Char [Char]
pA = [Char]
"a" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"aa" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'a'
        pB :: BNF Char [Char]
pB = [Char]
"b" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"bb" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'a' 
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"aaa" BNF Char [Char]
pX   [([Char]
"aaa", [[Char]
"aab", [Char]
"abb"])
                    ,([Char]
"aa", [[Char]
"ab"])]

    let pX :: BNF Char [Integer]
pX = (\Integer
x Integer
y -> [Integer
x,Integer
y]) forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pL forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pL forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'e'
        pL :: BNF Char Integer
pL =    Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'b'
            forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'b' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'c'
            forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
3 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'c' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'd'
            forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
4 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'd'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"longambig" BNF Char [Integer]
pX [([Char]
"abcde", [[Integer
1,Integer
3],[Integer
2,Integer
4]]), ([Char]
"abcdd", [])]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple1 (Char -> SymbExpr Char Char
char Char
'a') forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'b'))
        pY :: BNF Char Integer
pY = [Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pX forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pY
                   forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple1 & multiple & recursion + ambiguities" BNF Char Integer
pY
        [([Char]
"ab", [Integer
3]),([Char]
"aa", [Integer
1,Integer
2]), (forall a. Int -> a -> [a]
replicate Int
10 Char
'a', [Integer
1..Integer
10])]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=>  Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
        pY :: BNF Char Integer
pY = [Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pX forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pY
    -- shouldn't this be 1 + infinite 0's?
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"no parse infinite rec?" BNF Char Integer
pY 
        [([Char]
"a", [])]

    let pS :: BNF Char Integer
pS = [Char]
"S" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> ((\Integer
x Integer
y -> Integer
xforall a. Num a => a -> a -> a
+Integer
yforall a. Num a => a -> a -> a
+Integer
1) forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pS forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pS) forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0    
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"aho_S" BNF Char Integer
pS [([Char]
"", [Integer
0]), ([Char]
"1", [Integer
1]), (forall a. Int -> a -> [a]
replicate Int
5 Char
'1', [Integer
5])]


    let pS :: BNF Char [Char]
pS = [Char]
"S" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> ((\[Char]
x [Char]
y -> Char
'1'forall a. a -> [a] -> [a]
:[Char]
xforall a. [a] -> [a] -> [a]
++[Char]
y) forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char [Char]
pS forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char [Char]
pS) forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy [Char]
"0"
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"aho_S" BNF Char [Char]
pS [([Char]
"", [[Char]
"0"]), ([Char]
"1", [[Char]
"100"]), ([Char]
"11", [[Char]
"10100", [Char]
"11000"])
                    ,(forall a. Int -> a -> [a]
replicate Int
5 Char
'1', [[Char]]
aho_S_5)]

    let pE :: BNF Char Integer
pE = [Char]
"E" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (\Integer
x Integer
y Integer
z -> Integer
xforall a. Num a => a -> a -> a
+Integer
yforall a. Num a => a -> a -> a
+Integer
z) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pE forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pE forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pE 
                             forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1'
                             forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"EEE" BNF Char Integer
pE [([Char]
"", [Integer
0]), ([Char]
"1", [Integer
1]), ([Char]
"11", [Integer
2])
                  ,(forall a. Int -> a -> [a]
replicate Int
5 Char
'1', [Integer
5]), ([Char]
"112", [])]

    let pE :: BNF Char [Char]
pE = [Char]
"E" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (\[Char]
x [Char]
y [Char]
z -> [Char]
xforall a. [a] -> [a] -> [a]
++[Char]
yforall a. [a] -> [a] -> [a]
++[Char]
z) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char [Char]
pE forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char [Char]
pE forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char [Char]
pE 
                             forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"1" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1'
                             forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy [Char]
"0"
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"EEE ambig" BNF Char [Char]
pE [([Char]
"", [[Char]
"0"]), ([Char]
"1", [[Char]
"1"])
                        ,([Char]
"11", [[Char]
"110", [Char]
"011", [Char]
"101"]), ([Char]
"111", [[Char]]
_EEE_3)]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=>  forall b a. b -> (a -> b) -> Maybe a -> b
maybe Integer
0 (forall a b. a -> b -> a
const Integer
1) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z') 
                    forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> (forall a. Num a => a -> a -> a
+Integer
1) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pX forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'1'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"simple left-recursion" BNF Char Integer
pX [([Char]
"", [Integer
0]), ([Char]
"z11", [Integer
3]), ([Char]
"z", [Integer
1])
                                    ,(forall a. Int -> a -> [a]
replicate Int
100 Char
'1', [Integer
100])]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0 
                    forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> (forall a. Num a => a -> a -> a
+Integer
1) forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ BNF Char Integer
pB forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pX forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'1'
        pB :: BNF Char Integer
pB = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Integer
0 (forall a b. a -> b -> a
const Integer
0) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional (Char -> SymbExpr Char Char
char Char
'z')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"hidden left-recursion" BNF Char Integer
pX 
        [([Char]
"", [Integer
0]), ([Char]
"zz11", [Integer
2]), ([Char]
"z11", [Integer
2]), ([Char]
"11", [Integer
2])
        ,(forall a. Int -> a -> [a]
replicate Int
100 Char
'1', [Integer
100])]

    let pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pY forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pA
        pA :: BNF Char Integer
pA = Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'b' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
        pY :: BNF Char Integer
pY = [Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0 forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> BNF Char Integer
pX 
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"hidden left-recursion + infinite derivations" BNF Char Integer
pX
        [([Char]
"", [Integer
0]), ([Char]
"ab", [Integer
1]), ([Char]
"ababab", [Integer
3])]

    [Char] -> IO ()
putStrLn [Char]
"Tests that use memoisation"

    let tab :: MemoRef a
tab = forall a. MemoRef a
newMemoTable
        pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple1 (Char -> SymbExpr Char Char
char Char
'a') forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'b'))
        pY :: BNF Char Integer
pY = forall t a. (Ord t, Show t) => MemoRef [a] -> BNF t a -> BNF t a
memo forall a. MemoRef a
tab ([Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pX forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pY
                   forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0)
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test (forall a. a -> Maybe a
Just forall a. MemoRef a
tab) [Char]
"multiple1 & multiple & recursion + ambiguities" BNF Char Integer
pY
        [([Char]
"ab", [Integer
3]),([Char]
"aa", [Integer
1,Integer
2]), (forall a. Int -> a -> [a]
replicate Int
10 Char
'a', [Integer
1..Integer
10])]

    let tab :: MemoRef a
tab = forall a. MemoRef a
newMemoTable 
        pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=>  Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
        pY :: BNF Char Integer
pY = forall t a. (Ord t, Show t) => MemoRef [a] -> BNF t a -> BNF t a
memo forall a. MemoRef a
tab ([Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pX forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pY)
    -- shouldn't this be 1 + infinite 0's?
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test (forall a. a -> Maybe a
Just forall a. MemoRef a
tab) [Char]
"no parse infinite rec?" BNF Char Integer
pY 
        [([Char]
"a", [])]

    --  Higher ambiguities
    let tab :: MemoRef a
tab = forall a. MemoRef a
newMemoTable
        pE :: BNF Char Integer
pE = forall t a. (Ord t, Show t) => MemoRef [a] -> BNF t a -> BNF t a
memo forall a. MemoRef a
tab ([Char]
"E" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> (\Integer
x Integer
y Integer
z -> Integer
xforall a. Num a => a -> a -> a
+Integer
yforall a. Num a => a -> a -> a
+Integer
z) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pE forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pE forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pE 
                             forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1'
                             forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0)
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test (forall a. a -> Maybe a
Just forall a. MemoRef a
tab) [Char]
"EEE" BNF Char Integer
pE [([Char]
"", [Integer
0]), ([Char]
"1", [Integer
1]), ([Char]
"11", [Integer
2])
                             ,(forall a. Int -> a -> [a]
replicate Int
5 Char
'1', [Integer
5]), ([Char]
"112", [])]

    let tab :: MemoRef a
tab = forall a. MemoRef a
newMemoTable
        pX :: BNF Char Integer
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Integer
pY forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Integer
pA
        pA :: BNF Char Integer
pA = Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'b' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0
        pY :: BNF Char Integer
pY = forall t a. (Ord t, Show t) => MemoRef [a] -> BNF t a -> BNF t a
memo forall a. MemoRef a
tab ([Char]
"Y" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy Integer
0 forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> BNF Char Integer
pX)
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test (forall a. a -> Maybe a
Just forall a. MemoRef a
tab) [Char]
"hidden left-recursion + infinite derivations" BNF Char Integer
pX
        [([Char]
"", [Integer
0]), ([Char]
"ab", [Integer
1]), ([Char]
"ababab", [Integer
3])]

    [Char] -> IO ()
putStrLn [Char]
"Testing ambiguity reduction combinators"
    let pX :: BNF Char [Char]
pX = forall a. [a] -> [a] -> [a]
(++) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char [Char]
pA forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**>>> BNF Char [Char]
pB
        pA :: BNF Char [Char]
pA = [Char]
"a" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"aa" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'a'
        pB :: BNF Char [Char]
pB = [Char]
"b" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"bb" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'a' 
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"A<A" BNF Char [Char]
pX   [([Char]
"aaa", [[Char]
"aab"]),([Char]
"aa", [[Char]
"ab"])]

    let pX :: BNF Char [Char]
pX = forall a. [a] -> [a] -> [a]
(++) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char [Char]
pA forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<<<**> BNF Char [Char]
pB
        pA :: BNF Char [Char]
pA = [Char]
"a" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"aa" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'a'
        pB :: BNF Char [Char]
pB = [Char]
"b" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> [Char]
"bb" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'a' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'a' 
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"A>A" BNF Char [Char]
pX   [([Char]
"aaa", [[Char]
"abb"]),([Char]
"aa", [[Char]
"ab"])] 

    let pX :: BNF Char [Integer]
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple BNF Char Integer
pY
         where pY :: BNF Char Integer
pY = Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'1'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple" BNF Char [Integer]
pX 
      [([Char]
"", [[]]), ([Char]
"1", [[Integer
1]]), ([Char]
"11", [[Integer
1,Integer
1],[Integer
2]]), ([Char]
"111", [[Integer
1,Integer
1,Integer
1], [Integer
2,Integer
1], [Integer
1,Integer
2]])]

    let pX :: BNF Char [Integer]
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
some BNF Char Integer
pY
         where pY :: BNF Char Integer
pY = Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'1'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"some" BNF Char [Integer]
pX 
      [([Char]
"", [[]]), ([Char]
"1", [[Integer
1]]), ([Char]
"11", [[Integer
2]]), ([Char]
"111", [[Integer
2,Integer
1]])]

{-
    -- a combinatar `fewest` (variant of multiple) should behave as follows
    let pX = "X" <:=> fewest pY
         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
    test Nothing "some" pX 
      [("", [[]]), ("1", [[1]]), ("11", [[2]]), ("111", [[2,1], [1,2]])]
-}

    let pX :: BNF Char [Integer]
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
many BNF Char Integer
pY
         where pY :: BNF Char Integer
pY = Integer
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> Integer
2 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'1'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"many" BNF Char [Integer]
pX 
      [([Char]
"", [[]]), ([Char]
"1", [[Integer
1]]), ([Char]
"11", [[Integer
1,Integer
1]]), ([Char]
"111", [[Integer
1,Integer
1,Integer
1]])]
 
    let pX :: BNF Char [Char]
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> [Char]
"1" forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy (Char -> SymbExpr Char Char
char Char
'1') (Char -> SymbExpr Char Char
char Char
';')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multipleSepBy" BNF Char [Char]
pX
      [([Char]
"", [[Char]
""]), ([Char]
"1", [[Char]
"1", [Char]
"1"]), ([Char]
"1;1", [[Char]
"11"])]

    -- pX matches epsilon, therefore leading to infinitely many derivations
    let pX :: BNF Char Int 
        pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> Int
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy BNF Char Int
pX (Char -> SymbExpr Char Char
char Char
';')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multipleSepBy2" BNF Char Int
pX
      [([Char]
"", [Int
0]), ([Char]
"1", [Int
1,Int
1]), ([Char]
"1;1", [Int
2]), ([Char]
";1", [Int
1]),  ([Char]
";1;1", [Int
2])]

    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'1')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple1" BNF Char Int
pX
      [([Char]
"", [Int
0]), ([Char]
"11", [Int
2]), (forall a. Int -> a -> [a]
replicate Int
10 Char
'1', [Int
10])]

    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple (Char -> SymbExpr Char Char
char Char
'1') forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'z'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple2" BNF Char Int
pX
      [([Char]
"", []), ([Char]
"11z", [Int
2]), (forall a. Int -> a -> [a]
replicate Int
10 Char
'1' forall a. [a] -> [a] -> [a]
++ [Char]
"z", [Int
10])]

    let pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> forall (t :: * -> *) a. Foldable t => t a -> Int
length forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple BNF Char ()
pEps forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** Char -> SymbExpr Char Char
char Char
'z'
          where pEps :: BNF Char ()
pEps = forall t a. (Show t, Ord t) => a -> BNF t a
satisfy () forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> () forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1'
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multiple & epsilon" BNF Char Int
pX
      [([Char]
"", []), ([Char]
"z", [Int
0])]

    let pX :: BNF Char Int 
        pX :: BNF Char Int
pX = [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> Int
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1' forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy BNF Char Int
pX (Char -> SymbExpr Char Char
char Char
';')
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"multipleSepBy and multiple" (forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple BNF Char Int
pX)
      -- why not ("", [[0]]) ??
      [([Char]
"", [[]]), ([Char]
"1", [[Int
1],[Int
1]]), ([Char]
"1;1", [[Int
1,Int
0,Int
1],[Int
1,Int
1],[Int
2]])
      ,([Char]
";1;1", [[Int
0,Int
1,Int
0,Int
1],[Int
0,Int
1,Int
1], [Int
0,Int
2], [Int
1,Int
0,Int
1], [Int
1,Int
1], [Int
2]])]
{-
    let pX :: BNF Char Int 
        pX = "X" <::=> 1 <$$ char '1' <||> sum <$$> multipleSepBy pX (char ';')
    test Nothing "manySepBy and multiple" (many pX)
      -- why not ("", [[0]]) ??
      [("", [[]]), ("1", [[1],[1]]), ("1;1", [[1,0,1]])]-}

    let pX :: BNF Char Int -> BNF Char Int
        pX :: BNF Char Int -> BNF Char Int
pX BNF Char Int
p = forall t a. (Show t, Ord t) => BNF t a -> [Char] -> [Char]
mkNt BNF Char Int
p [Char]
"X" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<::=> BNF Char Int
p forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall a. Num a => a -> a -> a
(+) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF Char Int -> BNF Char Int
pX (BNF Char Int
p) forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF Char Int
p
    forall {t :: * -> *} {a} {t} {s :: * -> * -> *} {a}.
(Foldable t, Show a, Ord a, Parseable t, IsSymbExpr s) =>
Maybe (MemoRef a) -> [Char] -> s t a -> t ([t], [a]) -> IO ()
test forall a. Maybe a
Nothing [Char]
"sequence" (BNF Char Int -> BNF Char Int
pX ([Char]
"hash" forall t a. (Show t, Ord t) => [Char] -> BNF t a -> BNF t a
<:=> Int
1 forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ Char -> SymbExpr Char Char
char Char
'1'))
      [([Char]
"1", [Int
1]), ([Char]
"11",[Int
2]),([Char]
"111", [Int
3])
      ,([Char]
"", []), ([Char]
"21",[]), ([Char]
"1(1)1", [])]

    {- tests fails to terminate as the grammar is infinitely big
    let pX :: BNF Char Int -> BNF Char Int
        pX p = mkNt p "X" <::=> p 
                          <||> (+) <$$> pX (within (char '(') p (char ')')) <**> p
    test Nothing "growing sequence (left-recursive)" (pX ("hash" <:=> 1 <$$ char '1'))
      [("1", [1]), ("(1)1",[2]),("((1))(1)1", [3])
      ,("", []), ("11",[]), ("1(1)1", [])]
    -}
    {-let pX :: BNF Char Int -> BNF Char Int
        pX p = mkNt p "X" <::=> p 
                          <||> (+) <$$> p <**> pX (within (char '(') p (char ')'))
    test Nothing "growing sequence (right-recursive)" 
      (pX ("hash" <:=> 1 <$$ char '1'))
      [("1", [1]),("1(1)",[2]),("1(1)((1))", [3]),("1(1)((1))(((1)))",[4])
      ,("", []), ("11",[]), ("1(1)1", []), ("1(1)(1)", [])]-}
 where
    aho_S_5 :: [[Char]]
aho_S_5 = [[Char]
"10101010100",[Char]
"10101011000",[Char]
"10101100100",[Char]
"10101101000",[Char]
"10101110000",[Char]
"10110010100",[Char]
"10110011000",[Char]
"10110100100",[Char]
"10110101000",[Char]
"10110110000",[Char]
"10111000100",[Char]
"10111001000",[Char]
"10111010000",[Char]
"10111100000",[Char]
"11001010100",[Char]
"11001011000",[Char]
"11001100100",[Char]
"11001101000",[Char]
"11001110000",[Char]
"11010010100",[Char]
"11010011000",[Char]
"11010100100",[Char]
"11010101000",[Char]
"11010110000",[Char]
"11011000100",[Char]
"11011001000",[Char]
"11011010000",[Char]
"11011100000",[Char]
"11100010100",[Char]
"11100011000",[Char]
"11100100100",[Char]
"11100101000",[Char]
"11100110000",[Char]
"11101000100",[Char]
"11101001000",[Char]
"11101010000",[Char]
"11101100000",[Char]
"11110000100",[Char]
"11110001000",[Char]
"11110010000",[Char]
"11110100000",[Char]
"11111000000"]

    _EEE_3 :: [[Char]]
_EEE_3 = [[Char]
"00111",[Char]
"01011",[Char]
"01101",[Char]
"01110",[Char]
"10011",[Char]
"10101",[Char]
"10110",[Char]
"11001",[Char]
"11010",[Char]
"111",[Char]
"11100"]