X-Git-Url: https://git.rmz.io/my-scheme.git/blobdiff_plain/dbed09e123cb19f347a74e8c6fb6edf7e4931b5c..d06e8ae01efc00ea0eb6f0bed346032b004aca57:/app/Main.hs diff --git a/app/Main.hs b/app/Main.hs index de1c1ab..7c987ce 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,39 @@ module Main where +import Text.ParserCombinators.Parsec hiding (spaces) +import System.Environment -import Lib +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 + +parseAtom :: Parser LispVal +parseAtom = do + a <- letter <|> symbol + b <- many (letter <|> digit <|> symbol) + return $ Atom (a:b) + +readExpr :: String -> String +readExpr input = case parse (spaces >> symbol) "lisp" input of + Left err -> "No match: " ++ show err + Right val -> "Found value" main :: IO () -main = someFunc +main = do + args <- getLine + putStrLn (readExpr args)