]> git.rmz.io Git - my-scheme.git/blobdiff - app/Main.hs
Handle boolean constants
[my-scheme.git] / app / Main.hs
index c64fd18d83b0cdf0575889388df8cfa6344619c8..6fcf6675f175374d22b749097dc06142312b8400 100644 (file)
@@ -15,6 +15,23 @@ symbol = oneOf "!#$%&|*+-/:<=>?@^_~"
 spaces :: Parser ()
 spaces = skipMany space
 
 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)
+    let atom = a:b
+    return $ case atom of
+                "#t" -> Bool True
+                "#f" -> Bool False
+                _    -> Atom atom
+
 readExpr :: String -> String
 readExpr input = case parse (spaces >> symbol) "lisp" input of
     Left err -> "No match: " ++ show err
 readExpr :: String -> String
 readExpr input = case parse (spaces >> symbol) "lisp" input of
     Left err -> "No match: " ++ show err