Paste: parser2

Author: inv
Mode: haskell
Date: Sat, 24 Jan 2009 08:21:10
Plain Text |
module Main {-Parser2-} where

data P = P Int | N
	deriving Show

data T =
	Tsym | Tsyms
	deriving Show

data S =
	Sc Char
	deriving Show

pp2 [] s i2 =
	P i2
pp2 (t:ts) s i2 =
	case p t s of
		P i3 -> pp2 ts (drop i3 s) $ (+) i2 i3
		N -> P 0

p Tsym [] = N
p Tsym (c:cs) =
	case elem c ['a'..'z'] of
	True -> P 1
	False -> N

p Tsyms s =
	pp2 [Tsym,Tsyms] s 0

res = p Tsyms $ take 100000 $ repeat 'z'

main = putStrLn $ show res

New Annotation

Summary:
Author:
Mode:
Body: