Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created December 29, 2011 15:08
Show Gist options
  • Select an option

  • Save hughfdjackson/1534483 to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/1534483 to your computer and use it in GitHub Desktop.
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
shell returned 1
:!ghc -o hello --make main.hs
[1 of 1] Compiling Main ( main.hs, main.o )
main.hs:31:4: parse error on input `x'
shell returned 1
module Main where
import System.Environment
import Text.ParserCombinators.Parsec hiding (spaces)
main :: IO()
main = do
args <- getArgs
putStrLn (readExpr (args !! 0))
symbol :: Parser Char
symbol = oneOf "!#$%&|*+-/:<=>?@^_~"
data LispVal = Atom String
| List [LispVal]
| DottedList [LispVal] LispVal
| Number Integer
| String String
| Bool Bool
readExpr :: String -> String
readExpr input = case parse (space >> symbol) "lisp" input of
Left err -> "no match: " ++ show err
Right val -> "Found Val"
spaces :: Parser ()
spaces = skipMany1 space
parseString :: Parser LispVal
parseString = do char '"'
x <- many (noneOf "\"")
char '"'
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment