1
Fork 0

a few documentation and website tweaks

This commit is contained in:
Jake Wheat 2016-02-22 23:16:36 +02:00
parent 10a38657b5
commit 3f7e0123a2
6 changed files with 48 additions and 33 deletions

View file

@ -545,6 +545,9 @@ a good sanity test for this function is to change it to always return
true, then check that the automated tests return the same number of
successes. I don't think it succeeds this test at the moment
> -- | Utility function to tell you if a list of tokens
> -- will pretty print then lex back to the same set of tokens.
> -- Used internally, might be useful for generating SQL via lexical tokens.
> tokenListWillPrintAndLex :: Dialect -> [Token] -> Bool
> tokenListWillPrintAndLex _ [] = True
> tokenListWillPrintAndLex _ [_] = True

View file

@ -32,7 +32,7 @@ which have been changed to try to improve the layout of the output.
> prettyStatement :: Dialect -> Statement -> String
> prettyStatement d = render . statement d
> -- | Convert a list of statements to concrete syntax. A semi colon
> -- | Convert a list of statements to concrete syntax. A semicolon
> -- is inserted after each statement.
> prettyStatements :: Dialect -> [Statement] -> String
> prettyStatements d = render . vcat . map ((<> text ";\n") . statement d)

4
TODO
View file

@ -8,10 +8,14 @@ syntax from hssqlppp:
rename combinequeryexpr
add comment to statements?
review simple enums to make sure they have default
use enum in sign in interval literal
work on better dialect design: more basic customizability and rule /
callback driven
review/fix documentation and website
fix the groups for generated tests
medium tasks next release + 1
add annotation

View file

@ -125,28 +125,6 @@ assurance.
> ++ map (\s -> (s,[Symbol s])) [">=","<=","!=","<>","||", "::","..",":="]
> -- generic symbols
An operator name is a sequence of up to NAMEDATALEN-1 (63 by default) characters from the following list:
+ - * / < > = ~ ! @ # % ^ & | ` ?
There are a few restrictions on operator names, however:
-- and /* cannot appear anywhere in an operator name, since they will be taken as the start of a comment.
A multiple-character operator name cannot end in + or -, unless the name also contains at least one of these characters:
~ ! @ # % ^ & | ` ?
todo: 'negative' tests
symbol then --
symbol then /*
operators without one of the exception chars
followed by + or - without whitespace
also: do the testing for the ansi compatibility special cases
> ++ [ (x, [Symbol x]) | x <- someValidPostgresOperators 2]
> ++ (let idens = ["a", "_a", "test", "table", "Stuff", "STUFF"]
> -- simple identifiers
> in map (\i -> (i, [Identifier Nothing i])) idens
@ -200,6 +178,30 @@ also: do the testing for the ansi compatibility special cases
> ,"/* this *is/ a comment */"
> ]
An operator name is a sequence of up to NAMEDATALEN-1 (63 by default) characters from the following list:
+ - * / < > = ~ ! @ # % ^ & | ` ?
There are a few restrictions on operator names, however:
-- and /* cannot appear anywhere in an operator name, since they will be taken as the start of a comment.
A multiple-character operator name cannot end in + or -, unless the name also contains at least one of these characters:
~ ! @ # % ^ & | ` ?
todo: 'negative' tests
symbol then --
symbol then /*
operators without one of the exception chars
followed by + or - without whitespace
also: do the testing for the ansi compatibility special cases
> postgresShortOperatorTable :: [(String,[Token])]
> postgresShortOperatorTable =
> [ (x, [Symbol x]) | x <- someValidPostgresOperators 2]
> postgresExtraOperatorTable :: [(String,[Token])]
> postgresExtraOperatorTable =
> [ (x, [Symbol x]) | x <- someValidPostgresOperators 4]
@ -232,20 +234,23 @@ the + or -.
> postgresLexerTests :: TestItem
> postgresLexerTests = Group "postgresLexerTests" $
> [Group "postgres lexer token tests" $
> [LexTest postgres s t | (s,t) <- postgresLexerTable ++ postgresExtraOperatorTable]
> [LexTest postgres s t | (s,t) <- postgresLexerTable]
> ,Group "postgres generated lexer token tests" $
> [LexTest postgres s t | (s,t) <- postgresShortOperatorTable ++ postgresExtraOperatorTable]
> ,Group "postgres generated combination lexer tests" $
> [ LexTest postgres (s ++ s1) (t ++ t1)
> | (s,t) <- postgresLexerTable
> , (s1,t1) <- postgresLexerTable
> | (s,t) <- postgresLexerTable ++ postgresShortOperatorTable
> , (s1,t1) <- postgresLexerTable ++ postgresShortOperatorTable
> , tokenListWillPrintAndLex postgres $ t ++ t1
> ]
> ,Group "adhoc postgres lexertests" $
> ,Group "generated postgres edgecase lexertests" $
> [LexTest postgres s t
> | (s,t) <- edgeCaseCommentOps
> ++ edgeCasePlusMinusOps
> ++ edgeCasePlusMinusComments]
> ++
> ,Group "adhoc postgres lexertests" $
> -- need more tests for */ to make sure it is caught if it is in the middle of a
> -- sequence of symbol letters
> [LexFails postgres "*/"

View file

@ -4,8 +4,8 @@ Converts the test data to asciidoc
> import Language.SQL.SimpleSQL.Tests
> import Text.Show.Pretty
> import Control.Monad.State
> import Language.SQL.SimpleSQL.Parser
> import Language.SQL.SimpleSQL.Lexer
> import Language.SQL.SimpleSQL.Parse
> import Language.SQL.SimpleSQL.Lex
> import Data.List
> data TableItem = Heading Int String
@ -32,7 +32,10 @@ Converts the test data to asciidoc
> doc _ (ParseValueExprFails d str) =
> [Row str (ppShow $ parseValueExpr d "" Nothing str)]
> doc _ (LexerTest d str t) =
> doc _ (LexTest d str t) =
> [Row str (ppShow $ lexSQL d "" Nothing str)]
> doc _ (LexFails d str) =
> [Row str (ppShow $ lexSQL d "" Nothing str)]
TODO: should put the dialect in the html output

View file

@ -22,7 +22,7 @@ asciidoctor website/supported_sql.asciidoc -o - | runhaskell website/AddLinks.lh
# tpch sql file
# pandoc src/tpch.sql -s --highlight-style kate -o tpch.sql.html
# rendered test cases
runhaskell -package-db=.cabal-sandbox/x86_64-linux-ghc-7.10.2-packages.conf.d -i:tools website/RenderTestCases.lhs > build/test_cases.asciidoc
runhaskell -package-db=.cabal-sandbox/x86_64-linux-ghc-7.10.3-packages.conf.d -i:tools website/RenderTestCases.lhs > build/test_cases.asciidoc
#pandoc --from=markdown --to=html build/test_cases.asciidoc -o build/test_cases.html -c main.css '--title=simple-sql-parser examples/test cases' --toc
asciidoctor build/test_cases.asciidoc -o - | \