]> git.rmz.io Git - my-scheme.git/blobdiff - app/Main.hs
Add LispVal data type which can hold any Lisp value
[my-scheme.git] / app / Main.hs
index 015db3ad73adae9dec4ac67b281ac3e57c1d5fc0..c64fd18d83b0cdf0575889388df8cfa6344619c8 100644 (file)
@@ -1,11 +1,26 @@
 module Main where
 module Main where
-import Text.ParserCombinators.Parsec
+import Text.ParserCombinators.Parsec hiding (spaces)
 import System.Environment
 
 import System.Environment
 
+data LispVal = Atom String
+             | List [LispVal]
+             | DottedList [LispVal] LispVal
+             | Number Integer
+             | String String
+             | Bool Bool
+
 symbol :: Parser Char
 symbol = oneOf "!#$%&|*+-/:<=>?@^_~"
 
 symbol :: Parser Char
 symbol = oneOf "!#$%&|*+-/:<=>?@^_~"
 
+spaces :: Parser ()
+spaces = skipMany space
+
+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 = do
     args <- getLine
 main :: IO ()
 main = do
     args <- getLine
-    putStrLn (args)
+    putStrLn (readExpr args)