X-Git-Url: https://git.rmz.io/my-scheme.git/blobdiff_plain/081ba0cc6439a82a508100a59d6fa5dba80609d9..dc35484a906c23592e0170f051d74265ed2e8b46:/app/Main.hs diff --git a/app/Main.hs b/app/Main.hs index 6fcf667..87b94aa 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,19 @@ parseAtom = do "#f" -> Bool False _ -> Atom atom +parseNumber :: Parser LispVal +parseNumber = do + ds <- many1 digit + let a = read ds + return $ Number a + +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"