Consider this code:
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE RecursiveDo #-}
import Text.Earley
import Control.Applicative
data L = A | B | C deriving (Eq, Show)
lang :: Grammar r (Prod r () L ())
lang = mdo {
r1 <- rule $ (pure () <* token A) <|> r1;
return r1;
}
main :: IO ()
main = do {
putStrLn $ show $ fullParses (parser lang) [A];
}
This program crashes with stack overflow if I run it in ghci. And freezes if I compile and run it. I cannot even test whether list of parses is null, i. e. null $ fst $ fullParses (parser lang) [A] crashes in ghci.
I want some function, which can test whether given token list has multiple parses. I. e. I don't want list of parses or even count of parses. I simply want one of 3 results: 0 parses, 1 parse, more than 1 parse. And this function should terminate in case of infinitely ambiguous grammar.
I use Earley 0.13.0.1
Consider this code:
{-# LANGUAGE Haskell2010 #-} {-# LANGUAGE RecursiveDo #-} import Text.Earley import Control.Applicative data L = A | B | C deriving (Eq, Show) lang :: Grammar r (Prod r () L ()) lang = mdo { r1 <- rule $ (pure () <* token A) <|> r1; return r1; } main :: IO () main = do { putStrLn $ show $ fullParses (parser lang) [A]; }This program crashes with stack overflow if I run it in ghci. And freezes if I compile and run it. I cannot even test whether list of parses is null, i. e.
null $ fst $ fullParses (parser lang) [A]crashes in ghci.I want some function, which can test whether given token list has multiple parses. I. e. I don't want list of parses or even count of parses. I simply want one of 3 results: 0 parses, 1 parse, more than 1 parse. And this function should terminate in case of infinitely ambiguous grammar.
I use Earley 0.13.0.1