{- A simpleminded parser for a subset of formulas not containing | (or) Does not allow spaces in formulas. -} module FormParser1 (form) where import Form import Parser form :: Parser Char Form form = form1 *** optional (item '&' *** form >>> snd) >>> andF where andF(f1, Just f2) = f1 :&: f2 andF(f1, Nothing) = f1 -- form1 does not allow & form1 :: Parser Char Form form1 = item '~' *** form1 >>> (Not . snd) ||| item 'T' >>> const T ||| item 'F' >>> const F ||| identifier >>> Var ||| enclose '(' ')' form test = form "(x1&~T)&~a&~((F&d2)&~d2&d1)"