Vorlesung: Praxis der Funktionalen Programmierung | Index

Die elementaren Parser

Da gibt es nur zwei (weil der Eingabetyp - eine String - d. h. Liste) genau zwei Konstruktoren hat.
module Parser_Basic where

import Parser_Type

item :: Parser Char
item = Parser $ \ input -> case input of
     (c : cs) -> [ (c, cs) ]
     ""	      -> []

eof :: Parser ()
eof = Parser $ \ input -> case input of
    "" -> [ ((), "") ]
    _  -> []




best viewed with any browser


http://www.informatik.uni-leipzig.de/~joe/ mailto:joe@informatik.uni-leipzig.de