diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-09-18 17:29:56 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-09-18 17:29:56 +0100 |
commit | 3622810ea7ca5d42694313810b9f0c2557711475 (patch) | |
tree | a8708ea4aa4bc153d115281d508765c0d817012a /Main.hs | |
parent | eca89acee00faf6e9ef55d84780e6eeddf225e5c (diff) |
Ancient Haskell version of jq. Might be useful someday. Maybe.haskell-version
Diffstat (limited to 'Main.hs')
-rw-r--r-- | Main.hs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -3,11 +3,11 @@ import Lexer import JQ import Text.JSON import Text.JSON.String +import PrettyJSON import System.Environment import Control.Monad import System.IO - parseJS :: String -> JSValue parseJS s = case runGetJSON readJSValue s of Left err -> error err @@ -16,7 +16,8 @@ parseJS s = case runGetJSON readJSValue s of main = do [program] <- getArgs + stdlib <- openFile "stdlib.jq" ReadMode >>= hGetContents json <- liftM parseJS $ hGetContents stdin - case runLexer program >>= runParser of + case runLexer (stdlib ++ program) >>= runParser of Left err -> putStrLn err - Right program -> mapM_ (putStrLn . encode) (runJQ program json)
\ No newline at end of file + Right program -> mapM_ (putStrLn . show . renderJSON) (runJQ program json)
\ No newline at end of file |