overhaul website
This commit is contained in:
parent
45669ed7d3
commit
681cbfc416
19 changed files with 1008 additions and 1584 deletions
|
@ -1,35 +0,0 @@
|
|||
|
||||
import System.IO
|
||||
import System.Environment
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
[a] <- getArgs
|
||||
r <- readFile a
|
||||
let ls = lines r
|
||||
a = noAdjacentBlankLines ls
|
||||
b = concat $ combineGroups $ group [] a
|
||||
putStrLn $ unlines b
|
||||
|
||||
noAdjacentBlankLines [] = []
|
||||
noAdjacentBlankLines [a] = [a]
|
||||
noAdjacentBlankLines ("":xs@("":_)) = noAdjacentBlankLines xs
|
||||
noAdjacentBlankLines (x:xs) = x:noAdjacentBlankLines xs
|
||||
|
||||
group :: [String] -> [String] -> [[String]]
|
||||
group acc [] = [acc]
|
||||
group acc ("":xs) = reverse ("":acc) : group [] xs
|
||||
group acc (x:xs) = group (x : acc) xs
|
||||
|
||||
combineGroups :: [[String]] -> [[String]]
|
||||
combineGroups [] = []
|
||||
combineGroups (x@(('<':_):_):xs) | gs <- map trim x
|
||||
, ns <- trim $ unwords gs
|
||||
, length ns < 80 = [ns ++ "\n"] : combineGroups xs
|
||||
combineGroups (x:xs) = x:combineGroups xs
|
||||
|
||||
trim :: String -> String
|
||||
trim = x . x
|
||||
where
|
||||
x = dropWhile (==' ') . reverse
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
--import System.IO
|
||||
import System.Environment
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
[a] <- getArgs
|
||||
r <- readFile a
|
||||
let ls = lines r
|
||||
putStrLn $ unlines $ map dedupeSpaces ls
|
||||
|
||||
|
||||
dedupeSpaces :: String -> String
|
||||
dedupeSpaces [] = []
|
||||
-- don't start until after the leading spaces
|
||||
-- including literate haskell source lines
|
||||
dedupeSpaces xs@(x:_) | x `notElem` " >" = dedupeSpaces' xs
|
||||
dedupeSpaces (x:xs) = x : dedupeSpaces xs
|
||||
|
||||
dedupeSpaces' :: String -> String
|
||||
dedupeSpaces' (' ':xs@(' ':_)) = dedupeSpaces' xs
|
||||
dedupeSpaces' (x:xs) = x : dedupeSpaces' xs
|
||||
dedupeSpaces' [] = []
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
|
||||
import Language.SQL.SimpleSQL.ErrorMessages
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn $ pExprs valueExpressions queryExpressions
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
-- Simple example to show parsing some SQL then pretty printing the AST
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
import System.Environment
|
||||
import Text.Show.Pretty
|
||||
import System.IO
|
||||
|
||||
import Language.SQL.SimpleSQL.Parse
|
||||
(parseStatements
|
||||
,ParseError
|
||||
,prettyError
|
||||
,ansi2011)
|
||||
|
||||
import Language.SQL.SimpleSQL.Syntax (Statement)
|
||||
import qualified Data.Text as T
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
case args of
|
||||
[] -> do
|
||||
-- read from stdin
|
||||
c <- getContents
|
||||
doIt c
|
||||
["-s", sql] -> do
|
||||
-- parse arg given
|
||||
doIt sql
|
||||
[f] ->
|
||||
-- read file
|
||||
withFile f ReadMode (\h -> do
|
||||
x <- hGetContents h
|
||||
doIt x)
|
||||
_ -> do
|
||||
putStrLn "use no arguments to stream sql from stdin, e.g.:\n\
|
||||
\ cat some.sql | SimpleSQLParserExample\n\
|
||||
\n\
|
||||
\use -s to parse sql on command line, e.g.:\n\
|
||||
\ SimpleSQLParserExample -s \"select * from t\"\n\
|
||||
\use a single arg to parse a file, e.g.\n\
|
||||
\ SimpleSQLParserExample some.sql"
|
||||
|
||||
doIt :: String -> IO ()
|
||||
doIt src = do
|
||||
let parsed :: Either ParseError [Statement]
|
||||
parsed = parseStatements ansi2011 "" Nothing (T.pack src)
|
||||
either (error . T.unpack . prettyError)
|
||||
(putStrLn . ppShow)
|
||||
parsed
|
Loading…
Add table
Add a link
Reference in a new issue