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_ 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 s = (map toLower <$> string s)
|
||||
> <* notFollowedBy (char '_' <|> alphaNum)
|
||||
> <* whiteSpace
|
||||
> keyword s = try $ do
|
||||
> i <- identifierRaw
|
||||
> guard (map toLower i == map toLower s)
|
||||
> return i
|
||||
|
||||
> keyword_ :: String -> P ()
|
||||
> 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
|
||||
blacklist of keywords which aren't supported as identifiers.
|
||||
|
||||
> identifierString :: P String
|
||||
> identifierString = do
|
||||
> s <- (:) <$> letterOrUnderscore
|
||||
> <*> many letterDigitOrUnderscore <* whiteSpace
|
||||
> guard (s `notElem` blacklist)
|
||||
> return s
|
||||
the identifier raw doesn't check the blacklist since it is used by the
|
||||
keyword parser also
|
||||
|
||||
> identifierRaw :: P String
|
||||
> identifierRaw = (:) <$> letterOrUnderscore
|
||||
> <*> many letterDigitOrUnderscore <* whiteSpace
|
||||
> where
|
||||
> letterOrUnderscore = char '_' <|> letter
|
||||
> letterDigitOrUnderscore = char '_' <|> alphaNum
|
||||
|
||||
> identifierString :: P String
|
||||
> identifierString = do
|
||||
> s <- identifierRaw
|
||||
> guard (map toLower s `notElem` blacklist)
|
||||
> return s
|
||||
|
||||
> blacklist :: [String]
|
||||
> blacklist =
|
||||
> ["select", "as", "from", "where", "having", "group", "order"
|
||||
|
|
36
TODO
36
TODO
|
@ -1,7 +1,35 @@
|
|||
|
||||
first release:
|
||||
|
||||
add automated tests to cabal
|
||||
next release:
|
||||
quoted identifiers: implement as a dot operator
|
||||
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?
|
||||
|
||||
quasi quotes?
|
||||
|
||||
= sql support
|
||||
|
||||
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
|
||||
> (testData
|
||||
> ,tests
|
||||
|
|
Loading…
Reference in a new issue