gll 0.4.1.1 → 0.4.1.2
raw patch · 11 files changed
+97/−68 lines, 11 filesdep ~arraydep ~basedep ~containersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: array, base, containers, pretty, regex-applicative, text, time
API changes (from Hackage documentation)
- GLL.Combinators.BinaryInterface: Infix :: (e -> String -> e -> e) -> Assoc -> Fixity e
- GLL.Combinators.BinaryInterface: LAssoc :: Assoc
- GLL.Combinators.BinaryInterface: NA :: Assoc
- GLL.Combinators.BinaryInterface: Prefix :: (String -> e -> e) -> Fixity e
- GLL.Combinators.BinaryInterface: RAssoc :: Assoc
- GLL.Combinators.BinaryInterface: altsOf :: (HasAlts a, Show t, Ord t) => a t b -> [AltExpr t b]
- GLL.Combinators.BinaryInterface: class HasAlts a
- GLL.Combinators.BinaryInterface: class IsAltExpr a
- GLL.Combinators.BinaryInterface: class IsSymbExpr a
- GLL.Combinators.BinaryInterface: data AltExpr t a
- GLL.Combinators.BinaryInterface: data Assoc
- GLL.Combinators.BinaryInterface: data Fixity e
- GLL.Combinators.BinaryInterface: foldr_multiple :: (IsSymbExpr s, Parseable t) => s t (a -> a) -> a -> BNF t a
- GLL.Combinators.BinaryInterface: foldr_multipleSepBy :: (IsSymbExpr s, Parseable t) => s t (a -> a) -> s t b -> a -> BNF t a
- GLL.Combinators.BinaryInterface: fromOpTable :: (SubsumesToken t, Parseable t, IsSymbExpr s) => String -> OpTable e -> s t e -> BNF t e
- GLL.Combinators.BinaryInterface: lexerEither :: SubsumesToken t => LexerSettings -> String -> Either String [t]
- GLL.Combinators.BinaryInterface: opTableFromList :: [(Double, [(String, Fixity e)])] -> OpTable e
- GLL.Combinators.BinaryInterface: toAlt :: (IsAltExpr a, Show t, Ord t) => a t b -> AltExpr t b
- GLL.Combinators.BinaryInterface: type AltExprs = OO [] AltExpr
- GLL.Combinators.BinaryInterface: type OpTable e = Map Double [(String, Fixity e)]
- GLL.Combinators.BinaryInterface: type MemoRef a = IORef (MemoTable a)
+ GLL.Combinators.BinaryInterface: type MemoRef a = IORef MemoTable a
- GLL.Combinators.BinaryInterface: type MemoTable a = IntMap (IntMap a)
+ GLL.Combinators.BinaryInterface: type MemoTable a = IntMap IntMap a
- GLL.Combinators.Interface: class HasAlts a
+ GLL.Combinators.Interface: class HasAlts (a :: Type -> Type -> Type)
- GLL.Combinators.Interface: class IsAltExpr a
+ GLL.Combinators.Interface: class IsAltExpr (a :: Type -> Type -> Type)
- GLL.Combinators.Interface: class IsSymbExpr a
+ GLL.Combinators.Interface: class IsSymbExpr (a :: Type -> Type -> Type)
- GLL.Combinators.Interface: type MemoRef a = IORef (MemoTable a)
+ GLL.Combinators.Interface: type MemoRef a = IORef MemoTable a
- GLL.Combinators.Interface: type MemoTable a = IntMap (IntMap a)
+ GLL.Combinators.Interface: type MemoTable a = IntMap IntMap a
- GLL.Combinators.Memoisation: type MemoRef a = IORef (MemoTable a)
+ GLL.Combinators.Memoisation: type MemoRef a = IORef MemoTable a
- GLL.Combinators.Memoisation: type MemoTable a = IntMap (IntMap a)
+ GLL.Combinators.Memoisation: type MemoTable a = IntMap IntMap a
- GLL.Parser: type EdgeMap t = Map (SPPFNode t) (Set (SPPFNode t))
+ GLL.Parser: type EdgeMap t = Map SPPFNode t Set SPPFNode t
- GLL.Parser: type ImdMap t = IntMap (IntMap (Set (Slot t)))
+ GLL.Parser: type ImdMap t = IntMap IntMap Set Slot t
- GLL.Parser: type PackMap t = IntMap (IntMap (IntMap (Map (Prod t) IntSet)))
+ GLL.Parser: type PackMap t = IntMap IntMap IntMap Map Prod t IntSet
- GLL.Parser: type SymbMap t = IntMap (IntMap (Set (Symbol t)))
+ GLL.Parser: type SymbMap t = IntMap IntMap Set Symbol t
- GLL.Types.Derivations: showD :: (Show a, Show a) => Map a [a] -> String
+ GLL.Types.Derivations: showD :: (Show a1, Show a2) => Map a1 [a2] -> String
- GLL.Types.Derivations: showG :: (Show a, Show a) => Map a [a] -> String
+ GLL.Types.Derivations: showG :: (Show a1, Show a2) => Map a1 [a2] -> String
- GLL.Types.Derivations: showP :: (Show a, Show a) => IntMap (IntMap (IntMap (Map a a))) -> String
+ GLL.Types.Derivations: showP :: (Show a1, Show a2) => IntMap (IntMap (IntMap (Map a1 a2))) -> String
- GLL.Types.Derivations: type EdgeMap t = Map (SPPFNode t) (Set (SPPFNode t))
+ GLL.Types.Derivations: type EdgeMap t = Map SPPFNode t Set SPPFNode t
- GLL.Types.Derivations: type FirstMap t = Map Nt (Set t)
+ GLL.Types.Derivations: type FirstMap t = Map Nt Set t
- GLL.Types.Derivations: type FollowMap t = Map Nt (Set t)
+ GLL.Types.Derivations: type FollowMap t = Map Nt Set t
- GLL.Types.Derivations: type ImdMap t = IntMap (IntMap (Set (Slot t)))
+ GLL.Types.Derivations: type ImdMap t = IntMap IntMap Set Slot t
- GLL.Types.Derivations: type PEdge t = Map (PNode t) (Set (SNode t))
+ GLL.Types.Derivations: type PEdge t = Map PNode t Set SNode t
- GLL.Types.Derivations: type PackMap t = IntMap (IntMap (IntMap (Map (Prod t) IntSet)))
+ GLL.Types.Derivations: type PackMap t = IntMap IntMap IntMap Map Prod t IntSet
- GLL.Types.Derivations: type SEdge t = Map (SNode t) (Set (PNode t))
+ GLL.Types.Derivations: type SEdge t = Map SNode t Set PNode t
- GLL.Types.Derivations: type SelectMap t = Map (Nt, [Symbol t]) (Set t)
+ GLL.Types.Derivations: type SelectMap t = Map (Nt, [Symbol t]) Set t
- GLL.Types.Derivations: type SymbMap t = IntMap (IntMap (Set (Symbol t)))
+ GLL.Types.Derivations: type SymbMap t = IntMap IntMap Set Symbol t
- GLL.Types.TypeCompose: OO :: f (a `j` b) -> OO f j a b
+ GLL.Types.TypeCompose: OO :: f (j a b) -> OO (f :: Type -> Type) (j :: Type -> Type -> Type) a b
- GLL.Types.TypeCompose: [unOO] :: OO f j a b -> f (a `j` b)
+ GLL.Types.TypeCompose: [unOO] :: OO (f :: Type -> Type) (j :: Type -> Type -> Type) a b -> f (j a b)
- GLL.Types.TypeCompose: newtype OO f j a b
+ GLL.Types.TypeCompose: newtype OO (f :: Type -> Type) (j :: Type -> Type -> Type) a b
Files
- gll.cabal +10/−10
- src/GLL/Combinators/BinaryInterface.hs +0/−18
- src/GLL/Combinators/Interface.hs +0/−1
- src/GLL/Combinators/Lexer.hs +5/−1
- src/GLL/Combinators/Test/BinaryInterface.hs +41/−16
- src/GLL/Combinators/Test/Interface.hs +35/−14
- src/GLL/Combinators/Visit/Join.hs +0/−1
- src/GLL/Combinators/Visit/Sem.hs +0/−1
- src/GLL/Parser.hs +4/−4
- src/GLL/Types/Grammar.hs +1/−1
- src/GLL/Types/TypeCompose.hs +1/−1
gll.cabal view
@@ -3,7 +3,7 @@ -- The name of the package. name: gll-version: 0.4.1.1+version: 0.4.1.2 synopsis: GLL parser with simple combinator interface license: BSD3 license-file: LICENSE@@ -12,8 +12,8 @@ category: Compilers build-type: Simple cabal-version: 1.22-tested-with: GHC >= 8.2.1 && <= 8.6, GHC == 8.8.3, GHC >= 9.2.5, GHC == 9.4.3-copyright: Copyright (C) 2015-2023 L. Thomas van Binsbergen+tested-with: GHC >= 8.2.1 && <= 8.6, GHC == 8.8.3, GHC >= 9.2.5, GHC == 9.4.3, GHC == 9.6.7+copyright: Copyright (C) 2015-2026 L. Thomas van Binsbergen stability: experimental homepage: https://github.com/ltbinsbe/gll-combinators bug-reports: https://github.com/ltbinsbe/gll-combinators/issues@@ -42,13 +42,13 @@ library hs-source-dirs : src- build-depends : base >=4.3.1.0 && <= 5 - , containers >= 0.4- , array- , pretty- , text- , regex-applicative >= 0.3- , time >= 1.8+ build-depends : base >=4.3.1.0 && < 6 + , containers >= 0.4 && < 0.9+ , array >= 0.5 && < 0.6+ , pretty >= 1.1 && < 1.2+ , text >= 2 && < 3+ , regex-applicative >= 0.3 && < 0.4+ , time >= 1.8 && < 2 exposed-modules : GLL.Combinators.Interface , GLL.Combinators.BinaryInterface , GLL.GrammarCombinators
src/GLL/Combinators/BinaryInterface.hs view
@@ -61,30 +61,12 @@ someSepBy, someSepBy1,someSepBy2, -- * Memoisation memo, newMemoTable, memClear, MemoTable, MemoRef, useMemoisation,- module GLL.Combinators.Interface ) where import GLL.Combinators.Interface hiding (within, (**>), (<**>), (<**), (<<<**>), (<<<**), (**>>>), (<**>>>), satisfy, (<||>), (<||), (||>), (<$$>), (<$$), (<:=>), (<:=),(<::=>), (<::=), mkNt, manySepBy, manySepBy1, manySepBy2, multiple, multipleSepBy, many, multipleSepBy1, multipleSepBy2, someSepBy, someSepBy1, someSepBy2, some, memo, some1, many1, multiple1, shortest_match, longest_match, (<**>>), (<<**>), angles, braces, brackets, parens, within, optional, optionalWithDef, preferably, reluctantly, chooses, chooses_prec) import qualified GLL.Combinators.Interface as IF import GLL.Combinators.Options-import GLL.Combinators.Visit.Join-import GLL.Combinators.Visit.Sem (emptyAncestors)-import GLL.Combinators.Memoisation-import GLL.Combinators.Lexer-import GLL.Types.Grammar import GLL.Parser hiding (parse, parseWithOptions)-import qualified GLL.Parser as GLL--import GLL.Types.TypeCompose (OO(..))-import Control.Arrow-import qualified Data.Array as A-import qualified Data.IntMap as IM-import qualified Data.Map as M-import Data.Text (pack)-import Data.IORef -import Data.Time.Clock-import System.IO.Unsafe- infixl 2 <:=> -- |
src/GLL/Combinators/Interface.hs view
@@ -254,7 +254,6 @@ import GLL.Types.TypeCompose (OO(..)) import Control.Arrow import qualified Data.Array as A-import qualified Data.IntMap as IM import qualified Data.Map as M import qualified Data.Set as S import Data.Text (pack)
src/GLL/Combinators/Lexer.hs view
@@ -90,16 +90,20 @@ <|> upcast . CharLit . Just <$> lCharLit <|> upcast . StringLit . Just <$> lStringLit <|> lMore- where lMore = foldr ((<|>) . uncurry lToken) empty (tokens lexsets)+ where lMore :: SubsumesToken t => RE Char t + lMore = foldr ((<|>) . uncurry lToken) empty (tokens lexsets) lChar c = upcast (Char c) <$ sym c+ lCharacters :: SubsumesToken t => RE Char t lCharacters = foldr ((<|>) . lChar) empty (keychars lexsets) lKeyword k = upcast (Keyword k) <$ string k+ lKeywords :: SubsumesToken t => RE Char t lKeywords = foldr ((<|>) . lKeyword) empty (keywords lexsets) lToken t re = upcast . Token t . Just <$> re +lStringLit :: RE Char String lStringLit = toString <$ sym '\"' <*> many strChar <* sym '\"' where strChar = sym '\\' *> sym '\"' <|> psym ((/=) '\"')
src/GLL/Combinators/Test/BinaryInterface.hs view
@@ -51,6 +51,7 @@ j <- readIORef subcount modifyIORef subcount succ let parse_res = parseWithParseOptions [noSelectTest] [useMemoisation] p str+ norm :: (Ord a, Eq a) => [a] -> [a] norm = take 100 . sort . nub norm_p_res = norm parse_res b = norm_p_res == norm res@@ -82,6 +83,7 @@ test Nothing "<::=>" pX [("ab",[97]),("a",[])] let pX = "X" <:=> flip (:) <$$> pY <**> char 'a'+ pY :: BNF Char String pY = "Y" <:=> (\x y -> [x,y]) <$$> char 'b' <**> char 'c' test Nothing "<::=> 2" pX [("bca", ["abc"]), ("cba", [])] @@ -91,7 +93,8 @@ test Nothing "<::=> <||>" pX [("ac", "a"), ("bc", "b")] -- (Right) Recursion- let pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 + let pX :: BNF Char Int+ pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 test Nothing "rec1" pX [("", [0]), ("aa",[2]), (replicate 42 'a', [42]), ("bbb", [])] -- EBNF@@ -102,21 +105,26 @@ test Nothing "<||> optional" (pX <** optional (char 'z')) [("az", "a"), ("bz", "b"), ("z", []), ("b", "b"), ("a", "a")] - let pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b'))+ let pX :: BNF Char Int+ pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b')) test Nothing "optional-ambig" (pX <** optional (char 'z')) [("az", [1]), ("bz", [2]), ("z", [1,2]), ("b", [2]), ("a", [1])] - let pX = "X" <::=> id <$$ char 'a' <**> (char 'b' <||> char 'c')+ let pX :: BNF Char Char + pX = "X" <::=> id <$$ char 'a' <**> (char 'b' <||> char 'c') test Nothing "inline choice (1)" pX [("ab", "b"), ("ac", "c"), ("a", []), ("b", [])] - let pX = "X" <::=> length <$$> multiple (char '1')+ let pX :: BNF Char Int+ pX = "X" <::=> length <$$> multiple (char '1') test Nothing "multiple" pX [("", [0]), ("11", [2]), (replicate 12 '1', [12])] - let pX = "X" <::=> length <$$> multiple1 (char '1')+ let pX :: BNF Char Int+ pX = "X" <::=> length <$$> multiple1 (char '1') test Nothing "multiple1" pX [("", []), ("11", [2]), (replicate 12 '1', [12])] - let pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b')+ let pX :: BNF Char Int+ pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b') test Nothing "(multiple <||> multiple) <**> optional" (pX <** optional (char 'z')) [("az", [1]), ("bz", [2]), ("z", [1,2]) ,("", [1,2]), ("b", [2]), ("a", [1])]@@ -130,7 +138,8 @@ ] -- multiple with nullable argument- let pX = 1 <$$ char '1' <||> satisfy 0+ let pX :: BNF Char Int+ pX = 1 <$$ char '1' <||> satisfy 0 test Nothing "multiple (nullable arg)" (multiple pX) [("11", [[1,1]]), ("",[[]]), ("e", [])] @@ -142,25 +151,29 @@ ,("aa", ["ab"])] let pX = (\x y -> [x,y]) <$$ char 'a' <**> pL <**> pL <** char 'e'+ pL :: BNF Char Int pL = 1 <$$ char 'b' <||> 2 <$$ char 'b' <** char 'c' <||> 3 <$$ char 'c' <** char 'd' <||> 4 <$$ char 'd' test Nothing "longambig" pX [("abcde", [[1,3],[2,4]]), ("abcdd", [])] - let pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))+ let pX :: BNF Char Int+ pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b')) pY = "Y" <::=> (+) <$$> pX <**> pY <||> satisfy 0 test Nothing "multiple1 & multiple & recursion + ambiguities" pY [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])] - let pX = "X" <::=> 1 <$$ char 'a' <||> satisfy 0+ let pX :: BNF Char Int+ pX = "X" <::=> 1 <$$ char 'a' <||> satisfy 0 pY = "Y" <::=> (+) <$$> pX <**> pY -- shouldn't this be 1 + infinite 0's? test Nothing "no parse infinite rec?" pY [("a", [])] - let pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0 + let pS :: BNF Char Int+ pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0 test Nothing "aho_S" pS [("", [0]), ("1", [1]), (replicate 5 '1', [5])] @@ -168,7 +181,8 @@ test Nothing "aho_S" pS [("", ["0"]), ("1", ["100"]), ("11", ["10100", "11000"]) ,(replicate 5 '1', aho_S_5)] - let pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE + let pE :: BNF Char Int+ pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE <||> 1 <$$ char '1' <||> satisfy 0 test Nothing "EEE" pE [("", [0]), ("1", [1]), ("11", [2])@@ -180,19 +194,23 @@ test Nothing "EEE ambig" pE [("", ["0"]), ("1", ["1"]) ,("11", ["110", "011", "101"]), ("111", _EEE_3)] - let pX = "X" <::=> maybe 0 (const 1) <$$> optional (char 'z') + let pX :: BNF Char Int+ pX = "X" <::=> maybe 0 (const 1) <$$> optional (char 'z') <||> (+1) <$$> pX <** char '1' test Nothing "simple left-recursion" pX [("", [0]), ("z11", [3]), ("z", [1]) ,(replicate 100 '1', [100])] - let pX = "X" <::=> satisfy 0 + let pX :: BNF Char Int+ pX = "X" <::=> satisfy 0 <||> (+1) <$$ pB <**> pX <** char '1'+ pB :: BNF Char Int pB = maybe 0 (const 0) <$$> optional (char 'z') test Nothing "hidden left-recursion" pX [("", [0]), ("zz11", [2]), ("z11", [2]), ("11", [2]) ,(replicate 100 '1', [100])] let pX = "X" <::=> (+) <$$> pY <**> pA+ pA :: BNF Char Int pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0 pY = "Y" <::=> satisfy 0 <||> pX test Nothing "hidden left-recursion + infinite derivations" pX@@ -201,6 +219,7 @@ putStrLn "Tests that use memoisation" let tab = newMemoTable+ pX :: BNF Char Int pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b')) pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY <||> satisfy 0)@@ -208,6 +227,7 @@ [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])] let tab = newMemoTable + pX :: BNF Char Int pX = "X" <::=> 1 <$$ char 'a' <||> satisfy 0 pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY) -- shouldn't this be 1 + infinite 0's?@@ -216,6 +236,7 @@ -- Higher ambiguities let tab = newMemoTable+ pE :: BNF Char Int pE = memo tab ("E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE <||> 1 <$$ char '1' <||> satisfy 0)@@ -224,6 +245,7 @@ let tab = newMemoTable pX = "X" <::=> (+) <$$> pY <**> pA+ pA :: BNF Char Int pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0 pY = memo tab ("Y" <::=> satisfy 0 <||> pX) test (Just tab) "hidden left-recursion + infinite derivations" pX@@ -241,12 +263,14 @@ test Nothing "A>A" pX [("aaa", ["abb"]),("aa", ["ab"])] let pX = "X" <:=> multiple pY- where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'+ where pY :: BNF Char Int+ pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1' test Nothing "multiple" pX [("", [[]]), ("1", [[1]]), ("11", [[1,1],[2]]), ("111", [[1,1,1], [2,1], [1,2]])] let pX = "X" <:=> some pY- where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'+ where pY :: BNF Char Int+ pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1' test Nothing "some" pX [("", [[]]), ("1", [[1]]), ("11", [[2]]), ("111", [[2,1]])] @@ -259,7 +283,8 @@ -} let pX = "X" <:=> many pY- where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'+ where pY :: BNF Char Int + pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1' test Nothing "many" pX [("", [[]]), ("1", [[1]]), ("11", [[1,1]]), ("111", [[1,1,1]])]
src/GLL/Combinators/Test/Interface.hs view
@@ -51,6 +51,7 @@ j <- readIORef subcount modifyIORef subcount succ let parse_res = parseWithParseOptions [noSelectTest] [useMemoisation] p str+ norm :: (Eq a, Ord a) => [a] -> [a] norm = take 100 . sort . nub norm_p_res = norm parse_res b = norm_p_res == norm res@@ -91,7 +92,8 @@ test Nothing "<::=> <||>" pX [("ac", "a"), ("bc", "b")] -- (Right) Recursion- let pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 + let pX :: BNF Char Int+ pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 test Nothing "rec1" pX [("", [0]), ("aa",[2]), (replicate 42 'a', [42]), ("bbb", [])] -- EBNF@@ -102,7 +104,8 @@ test Nothing "<||> optional" (pX <** optional (char 'z')) [("az", "a"), ("bz", "b"), ("z", []), ("b", "b"), ("a", "a")] - let pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b'))+ let pX :: BNF Char Int+ pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b')) test Nothing "optional-ambig" (pX <** optional (char 'z')) [("az", [1]), ("bz", [2]), ("z", [1,2]), ("b", [2]), ("a", [1])] @@ -116,7 +119,8 @@ let pX = "X" <::=> length <$$> multiple1 (char '1') test Nothing "multiple1" pX [("", []), ("11", [2]), (replicate 12 '1', [12])] - let pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b')+ let pX :: BNF Char Int+ pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b') test Nothing "(multiple <||> multiple) <**> optional" (pX <** optional (char 'z')) [("az", [1]), ("bz", [2]), ("z", [1,2]) ,("", [1,2]), ("b", [2]), ("a", [1])]@@ -130,7 +134,8 @@ ] -- multiple with nullable argument- let pX = 1 <$$ char '1' <||> satisfy 0+ let pX :: AltExprs Char Int+ pX = 1 <$$ char '1' <||> satisfy 0 test Nothing "multiple (nullable arg)" (multiple pX) [("11", [[1,1]]), ("",[[]]), ("e", [])] @@ -142,25 +147,29 @@ ,("aa", ["ab"])] let pX = (\x y -> [x,y]) <$$ char 'a' <**> pL <**> pL <** char 'e'- pL = 1 <$$ char 'b'+ pL :: AltExprs Char Int+ pL = 1 <$$ char 'b' <||> 2 <$$ char 'b' <** char 'c' <||> 3 <$$ char 'c' <** char 'd' <||> 4 <$$ char 'd' test Nothing "longambig" pX [("abcde", [[1,3],[2,4]]), ("abcdd", [])] - let pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))+ let pX :: BNF Char Int+ pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b')) pY = "Y" <::=> (+) <$$> pX <**> pY <||> satisfy 0 test Nothing "multiple1 & multiple & recursion + ambiguities" pY [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])] - let pX = "X" <::=> 1 <$$ char 'a' <||> satisfy 0+ let pX :: BNF Char Int+ pX = "X" <::=> 1 <$$ char 'a' <||> satisfy 0 pY = "Y" <::=> (+) <$$> pX <**> pY -- shouldn't this be 1 + infinite 0's? test Nothing "no parse infinite rec?" pY [("a", [])] - let pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0 + let pS :: BNF Char Int+ pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0 test Nothing "aho_S" pS [("", [0]), ("1", [1]), (replicate 5 '1', [5])] @@ -168,7 +177,8 @@ test Nothing "aho_S" pS [("", ["0"]), ("1", ["100"]), ("11", ["10100", "11000"]) ,(replicate 5 '1', aho_S_5)] - let pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE + let pE :: BNF Char Int+ pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE <||> 1 <$$ char '1' <||> satisfy 0 test Nothing "EEE" pE [("", [0]), ("1", [1]), ("11", [2])@@ -180,19 +190,23 @@ test Nothing "EEE ambig" pE [("", ["0"]), ("1", ["1"]) ,("11", ["110", "011", "101"]), ("111", _EEE_3)] - let pX = "X" <::=> maybe 0 (const 1) <$$> optional (char 'z') + let pX :: BNF Char Int+ pX = "X" <::=> maybe 0 (const 1) <$$> optional (char 'z') <||> (+1) <$$> pX <** char '1' test Nothing "simple left-recursion" pX [("", [0]), ("z11", [3]), ("z", [1]) ,(replicate 100 '1', [100])] - let pX = "X" <::=> satisfy 0 + let pX :: BNF Char Int+ pX = "X" <::=> satisfy 0 <||> (+1) <$$ pB <**> pX <** char '1'+ pB :: AltExpr Char Int pB = maybe 0 (const 0) <$$> optional (char 'z') test Nothing "hidden left-recursion" pX [("", [0]), ("zz11", [2]), ("z11", [2]), ("11", [2]) ,(replicate 100 '1', [100])] let pX = "X" <::=> (+) <$$> pY <**> pA+ pA :: AltExprs Char Int pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0 pY = "Y" <::=> satisfy 0 <||> pX test Nothing "hidden left-recursion + infinite derivations" pX@@ -201,6 +215,7 @@ putStrLn "Tests that use memoisation" let tab = newMemoTable+ pX :: BNF Char Int pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b')) pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY <||> satisfy 0)@@ -208,6 +223,7 @@ [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])] let tab = newMemoTable + pX :: BNF Char Int pX = "X" <::=> 1 <$$ char 'a' <||> satisfy 0 pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY) -- shouldn't this be 1 + infinite 0's?@@ -216,6 +232,7 @@ -- Higher ambiguities let tab = newMemoTable+ pE :: BNF Char Int pE = memo tab ("E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE <||> 1 <$$ char '1' <||> satisfy 0)@@ -224,6 +241,7 @@ let tab = newMemoTable pX = "X" <::=> (+) <$$> pY <**> pA+ pA :: AltExprs Char Int pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0 pY = memo tab ("Y" <::=> satisfy 0 <||> pX) test (Just tab) "hidden left-recursion + infinite derivations" pX@@ -241,12 +259,14 @@ test Nothing "A>A" pX [("aaa", ["abb"]),("aa", ["ab"])] let pX = "X" <:=> multiple pY- where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'+ where pY :: AltExprs Char Int+ pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1' test Nothing "multiple" pX [("", [[]]), ("1", [[1]]), ("11", [[1,1],[2]]), ("111", [[1,1,1], [2,1], [1,2]])] let pX = "X" <:=> some pY- where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'+ where pY :: AltExprs Char Int+ pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1' test Nothing "some" pX [("", [[]]), ("1", [[1]]), ("11", [[2]]), ("111", [[2,1]])] @@ -259,7 +279,8 @@ -} let pX = "X" <:=> many pY- where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'+ where pY :: AltExprs Char Int+ pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1' test Nothing "many" pX [("", [[]]), ("1", [[1]]), ("11", [[1,1]]), ("111", [[1,1,1]])]
src/GLL/Combinators/Visit/Join.hs view
@@ -2,7 +2,6 @@ module GLL.Combinators.Visit.Join where -import GLL.Types.Derivations import GLL.Types.Grammar import GLL.Combinators.Visit.Sem import GLL.Combinators.Visit.Grammar
src/GLL/Combinators/Visit/Sem.hs view
@@ -7,7 +7,6 @@ import Control.Monad (forM) import qualified Data.Array as A-import qualified Data.IntMap as IM import qualified Data.Set as S type Sem_Symb t a = PCOptions -> Ancestors t
src/GLL/Parser.hs view
@@ -177,7 +177,6 @@ import Data.Foldable hiding (forM_, toList, sum) import Prelude hiding (lookup, foldr, fmap, foldl, elem, any, concatMap)-import Control.Applicative import Control.Monad import qualified Data.IntMap as IM import qualified Data.Map as M@@ -325,11 +324,10 @@ instance Applicative (GLL t) where (<*>) = ap- pure = return+ pure v = GLL $ \_ p -> (v, p) instance Functor (GLL t) where fmap = liftM instance Monad (GLL t) where- return a = GLL $ \_ p -> (a, p) (GLL m) >>= f = GLL $ \o p -> let (a, p') = m o p (GLL m') = f a in m' o p'@@ -372,6 +370,7 @@ gll flags m debug (start, prods) input = (runGLL (pLhs (start, 0)) flags context, selects, follows) where + context :: (Ord t) => Mutable t context = Mutable emptySPPF [] IM.empty IM.empty IM.empty IM.empty counters counters = Counters 0 0 @@ -452,7 +451,8 @@ | otherwise = True altsOf x = prodMap M.! x merge m1 m2 = IM.unionWith inner m1 m2- where inner = IM.unionWith S.union + where inner :: (Ord t) => IM.IntMap (S.Set t) -> IM.IntMap (S.Set t) -> IM.IntMap (S.Set t)+ inner = IM.unionWith S.union count_pnode :: GLL t () count_pnode = GLL $ \flags mut ->
src/GLL/Types/Grammar.hs view
@@ -4,7 +4,7 @@ -- UUAGC 0.9.52.1 (src/GLL/Types/Abstract.ag) module GLL.Types.Grammar where -import Data.Text+import Data.Text hiding (show) -- | Identifier for nonterminals. type Nt = Text
src/GLL/Types/TypeCompose.hs view
@@ -6,7 +6,7 @@ import Control.Arrow (Arrow(..)) import Control.Category (Category(..))-import Control.Applicative (liftA, liftA2)+import Control.Applicative (liftA) -- | Composition of type constructors: unary with binary. Called -- "StaticArrow" in [1].