From: Ramakrishnan Muthukrishnan Date: Sun, 28 Dec 2014 08:19:34 +0000 (+0530) Subject: hw11: exercise 2 - spaces and ident X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=2e594c0ef1af839a4e85139357c751f3140c1a8e;p=yorgey.git hw11: exercise 2 - spaces and ident --- diff --git a/hw11/SExpr.hs b/hw11/SExpr.hs index c3f7d70..b70683a 100644 --- a/hw11/SExpr.hs +++ b/hw11/SExpr.hs @@ -6,6 +6,7 @@ module SExpr where import AParser import Control.Applicative +import Data.Char(isSpace, isAlpha, isAlphaNum) ------------------------------------------------------------ -- 1. Parsing repetitions @@ -29,10 +30,10 @@ oneOrMore p = liftA2 (:) p (zeroOrMore p) ------------------------------------------------------------ spaces :: Parser String -spaces = undefined +spaces = zeroOrMore (satisfy isSpace) ident :: Parser String -ident = undefined +ident = liftA2 (:) (satisfy isAlpha) (zeroOrMore (satisfy isAlphaNum)) ------------------------------------------------------------ -- 3. Parsing S-expressions