
27 Jan
2016
27 Jan
'16
7:48 a.m.
On Wed, Jan 27, 2016 at 01:34:29PM +0100, Ulrik Rasmussen wrote:
The language is recognized by a relatively simple DFA (attached), so the simplest solution (I think) is to just encode that:
module Main where
import Text.Parsec import Text.Parsec.String
p :: Parser () p = char 'A' >> ((char 'A' >> sA) <|> (char 'B' >> sB)) where sA = (char 'A' >> sA) <|> (char 'B' >> sB) <|> return () sB = (char 'B' >> sB) <|> return ()
I am probably missing something: say we have an "AAB" string, how does this check that it is `compatible` with [x,y] or [x,x,y] or [x,y,y] (or not compatible with [x,x,x], etc.)?