X-Git-Url: https://git.rmz.io/my-scheme.git/blobdiff_plain/b95d19b43830747d76eab4c01805ef531e897795..10ec228b216032b4d61216414aef8b1e36cf151f:/app/Main.hs diff --git a/app/Main.hs b/app/Main.hs index a94dc2c..22de748 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,12 +1,29 @@ module Main where -import Text.ParserCombinators.Parsec +import Text.ParserCombinators.Parsec hiding (spaces) import System.Environment +data LispVal = Atom String + | List [LispVal] + | DottedList [LispVal] LispVal + | Number Integer + | String String + | Bool Bool + symbol :: Parser Char symbol = oneOf "!#$%&|*+-/:<=>?@^_~" +spaces :: Parser () +spaces = skipMany space + +parseString :: Parser LispVal +parseString = do + char '"' + x <- many (noneOf "\"") + char '"' + return $ String x + readExpr :: String -> String -readExpr input = case parse symbol "lisp" input of +readExpr input = case parse (spaces >> symbol) "lisp" input of Left err -> "No match: " ++ show err Right val -> "Found value"