Elementare Parser (II)

satisfy :: ( c -> Bool ) -> Parser c c
satisfy p = do 
    x <- next 
    if p x then return x else reject

expect :: Eq c => c -> Parser c c
expect c = satisfy ( == c )

ziffer :: Parser Char Integer
ziffer = do 
    c <- satisfy Data.Char.isDigit
    return $ fromIntegral 
           $ fromEnum c - fromEnum '0'



Johannes Waldmann 2012-01-30