X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=hw11%2FSExpr.hs;fp=hw11%2FSExpr.hs;h=b70683a583a4275278ab6d416eee9b78f7d12795;hb=2e594c0ef1af839a4e85139357c751f3140c1a8e;hp=c3f7d70f757a8cc7e00ac31f33b882974d6df8e7;hpb=2829f5999e1f58bd8f2f7bc1d020bfdb8b9429c0;p=yorgey.git 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