Ancient Haskell version of jq. Might be useful someday. Maybe.

This commit is contained in:
Stephen Dolan committed 2012-09-18 17:29:56 +01:00
1 parent eca89acee0
commit 3622810ea7
7 files changed
+269 -46

No files matched your search

+4 -3
View File
@@ -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)
Right program -> mapM_ (putStrLn . show . renderJSON) (runJQ program json)