fix case insensitivity for keyword parsing, add some notes
This commit is contained in:
parent
5eb48efb36
commit
86ba354e26
|
@ -649,10 +649,14 @@ access them via these functions, if you follow?
|
||||||
> symbol_ :: String -> P ()
|
> symbol_ :: String -> P ()
|
||||||
> symbol_ s = symbol s *> return ()
|
> symbol_ s = symbol s *> return ()
|
||||||
|
|
||||||
|
TODO: now that keyword has try in it, a lot of the trys above can be
|
||||||
|
removed
|
||||||
|
|
||||||
> keyword :: String -> P String
|
> keyword :: String -> P String
|
||||||
> keyword s = (map toLower <$> string s)
|
> keyword s = try $ do
|
||||||
> <* notFollowedBy (char '_' <|> alphaNum)
|
> i <- identifierRaw
|
||||||
> <* whiteSpace
|
> guard (map toLower i == map toLower s)
|
||||||
|
> return i
|
||||||
|
|
||||||
> keyword_ :: String -> P ()
|
> keyword_ :: String -> P ()
|
||||||
> keyword_ s = keyword s *> return ()
|
> keyword_ s = keyword s *> return ()
|
||||||
|
@ -662,16 +666,22 @@ underscore, and continue with letter, underscore or digit. It doesn't
|
||||||
support quoting other other sorts of identifiers yet. There is a
|
support quoting other other sorts of identifiers yet. There is a
|
||||||
blacklist of keywords which aren't supported as identifiers.
|
blacklist of keywords which aren't supported as identifiers.
|
||||||
|
|
||||||
> identifierString :: P String
|
the identifier raw doesn't check the blacklist since it is used by the
|
||||||
> identifierString = do
|
keyword parser also
|
||||||
> s <- (:) <$> letterOrUnderscore
|
|
||||||
|
> identifierRaw :: P String
|
||||||
|
> identifierRaw = (:) <$> letterOrUnderscore
|
||||||
> <*> many letterDigitOrUnderscore <* whiteSpace
|
> <*> many letterDigitOrUnderscore <* whiteSpace
|
||||||
> guard (s `notElem` blacklist)
|
|
||||||
> return s
|
|
||||||
> where
|
> where
|
||||||
> letterOrUnderscore = char '_' <|> letter
|
> letterOrUnderscore = char '_' <|> letter
|
||||||
> letterDigitOrUnderscore = char '_' <|> alphaNum
|
> letterDigitOrUnderscore = char '_' <|> alphaNum
|
||||||
|
|
||||||
|
> identifierString :: P String
|
||||||
|
> identifierString = do
|
||||||
|
> s <- identifierRaw
|
||||||
|
> guard (map toLower s `notElem` blacklist)
|
||||||
|
> return s
|
||||||
|
|
||||||
> blacklist :: [String]
|
> blacklist :: [String]
|
||||||
> blacklist =
|
> blacklist =
|
||||||
> ["select", "as", "from", "where", "having", "group", "order"
|
> ["select", "as", "from", "where", "having", "group", "order"
|
||||||
|
|
36
TODO
36
TODO
|
@ -1,7 +1,35 @@
|
||||||
|
|
||||||
first release:
|
next release:
|
||||||
|
quoted identifiers: implement as a dot operator
|
||||||
add automated tests to cabal
|
review tests to copy from hssqlppp
|
||||||
|
window frames and named windows
|
||||||
|
dialect framework
|
||||||
|
try to implement fixity without the hse hack
|
||||||
|
position annotation?
|
||||||
|
row ctor
|
||||||
|
more symbolic operators, array access a[5]?
|
||||||
|
review abstract syntax (e.g. combine App with SpecialOp?)
|
||||||
|
more dots
|
||||||
|
order by nulls first/last
|
||||||
|
extend case
|
||||||
|
group by extensions
|
||||||
|
table, values
|
||||||
|
collate? -> postfix operator which binds very tightly:
|
||||||
|
a < 'foo' collate 'C'
|
||||||
|
->
|
||||||
|
Op "<" [Iden "a", SpecialOp "collate" [StringLit 'foo', StringLit
|
||||||
|
'C']]
|
||||||
|
also postfix in order by:
|
||||||
|
select a from t order by a collate 'C': add to order by syntax
|
||||||
|
function table reference
|
||||||
|
much more table reference tests
|
||||||
|
ansi standard versions of limit and offset
|
||||||
|
sql server top
|
||||||
|
add to website: pretty printed tpch, maybe other queries as
|
||||||
|
demonstration
|
||||||
|
demo: convert tpch to sql server syntax
|
||||||
|
review internal sql collection for more syntax/tests
|
||||||
|
run through postgres docs and add example sql as tests
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -20,6 +48,8 @@ reimplement the fixity thing natively
|
||||||
|
|
||||||
position annotation?
|
position annotation?
|
||||||
|
|
||||||
|
quasi quotes?
|
||||||
|
|
||||||
= sql support
|
= sql support
|
||||||
|
|
||||||
scalar function syntax:
|
scalar function syntax:
|
||||||
|
|
|
@ -1,4 +1,39 @@
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
|
||||||
|
split into multiple files:
|
||||||
|
scalar expressions
|
||||||
|
tablerefs
|
||||||
|
other queryexpr parts: not enough to split into multiple files
|
||||||
|
full queries
|
||||||
|
tpch tests
|
||||||
|
|
||||||
|
postgres queries - take all the examples from the postgres docs which
|
||||||
|
aren't too postgres specific and create tests from them
|
||||||
|
|
||||||
|
postgres queries:
|
||||||
|
SELECT 'foo'
|
||||||
|
'bar'; -> if there is a newline, this parses to select 'foobar'
|
||||||
|
|
||||||
|
SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)
|
||||||
|
FROM states;
|
||||||
|
|
||||||
|
SELECT ROW(1,2.5,'this is a test');
|
||||||
|
|
||||||
|
SELECT ROW(t.*, 42) FROM t;
|
||||||
|
SELECT ROW(t.f1, t.f2, 42) FROM t;
|
||||||
|
Note: Before PostgreSQL 8.2, the .* syntax was not expanded
|
||||||
|
SELECT getf1(CAST(ROW(11,'this is a test',2.5) AS myrowtype));
|
||||||
|
|
||||||
|
SELECT ROW(1,2.5,'this is a test') = ROW(1, 3, 'not the same');
|
||||||
|
|
||||||
|
SELECT ROW(table.*) IS NULL FROM table;
|
||||||
|
|
||||||
|
SELECT true OR somefunc();
|
||||||
|
|
||||||
|
SELECT somefunc() OR true;
|
||||||
|
|
||||||
|
|
||||||
> module Language.SQL.SimpleSQL.Tests
|
> module Language.SQL.SimpleSQL.Tests
|
||||||
> (testData
|
> (testData
|
||||||
> ,tests
|
> ,tests
|
||||||
|
|
Loading…
Reference in a new issue