X-Git-Url: https://git.rmz.io/my-scheme.git/blobdiff_plain/081ba0cc6439a82a508100a59d6fa5dba80609d9..aeb011a6698da3d7842fd5fd998eac54a0cf135a:/app/Main.hs diff --git a/app/Main.hs b/app/Main.hs index 6fcf667..58017c5 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,4 +1,5 @@ module Main where +import Control.Monad import Text.ParserCombinators.Parsec hiding (spaces) import System.Environment @@ -32,8 +33,16 @@ parseAtom = do "#f" -> Bool False _ -> Atom atom +parseNumber :: Parser LispVal +parseNumber = liftM (Number . read) $ many1 digit + +parseExpr :: Parser LispVal +parseExpr = parseString + <|> parseAtom + <|> parseNumber + readExpr :: String -> String -readExpr input = case parse (spaces >> symbol) "lisp" input of +readExpr input = case parse parseExpr "lisp" input of Left err -> "No match: " ++ show err Right val -> "Found value"