1
Fork 0

move special type names to the dialect

This commit is contained in:
Jake Wheat 2019-09-01 09:45:26 +01:00
parent 86f5e203af
commit df8a8e8df3
2 changed files with 59 additions and 48 deletions

View file

@ -18,15 +18,18 @@ Data types to represent different dialect options
> -- | Used to set the dialect used for parsing and pretty printing, > -- | Used to set the dialect used for parsing and pretty printing,
> -- very unfinished at the moment. > -- very unfinished at the moment.
> data Dialect = Dialect > data Dialect = Dialect
> { -- | The list of reserved keywords > { -- | the list of reserved keywords
> diKeywords :: [String] > diKeywords :: [String]
> -- | The list of reserved keywords, which can also be used as > -- | the list of reserved keywords, which can also be used as
> -- | an identifier > -- | an identifier
> ,diIdentifierKeywords :: [String] > ,diIdentifierKeywords :: [String]
> -- | The list of reserved keywords, which can also be used as > -- | the list of reserved keywords, which can also be used as
> -- | a function name (including aggregates and window > -- | a function name (including aggregates and window
> -- | functions) > -- | functions)
> ,diAppKeywords :: [String] > ,diAppKeywords :: [String]
> -- | all the type names which are also reserved keywords, and
> -- | all the type names which are multiple words
> ,diSpecialTypeNames :: [String]
> -- | does the dialect support ansi fetch first syntax > -- | does the dialect support ansi fetch first syntax
> ,diFetchFirst :: Bool > ,diFetchFirst :: Bool
> -- | does the dialect support limit keyword (mysql, postgres, > -- | does the dialect support limit keyword (mysql, postgres,
@ -60,6 +63,7 @@ Data types to represent different dialect options
> ansi2011 = Dialect {diKeywords = ansi2011ReservedKeywords > ansi2011 = Dialect {diKeywords = ansi2011ReservedKeywords
> ,diIdentifierKeywords = [] > ,diIdentifierKeywords = []
> ,diAppKeywords = ["set"] > ,diAppKeywords = ["set"]
> ,diSpecialTypeNames = ansi2011TypeNames
> ,diFetchFirst = True > ,diFetchFirst = True
> ,diLimit = False > ,diLimit = False
> ,diOdbc = False > ,diOdbc = False
@ -463,3 +467,48 @@ some rationale for having quite string reserved keywords:
> ,"without" > ,"without"
> --,"year" > --,"year"
> ] > ]
> ansi2011TypeNames :: [String]
> ansi2011TypeNames =
> ["double precision"
> ,"character varying"
> ,"char varying"
> ,"character large object"
> ,"char large object"
> ,"national character"
> ,"national char"
> ,"national character varying"
> ,"national char varying"
> ,"national character large object"
> ,"nchar large object"
> ,"nchar varying"
> ,"bit varying"
> ,"binary large object"
> ,"binary varying"
> -- reserved keyword typenames:
> ,"array"
> ,"bigint"
> ,"binary"
> ,"blob"
> ,"boolean"
> ,"char"
> ,"character"
> ,"clob"
> ,"date"
> ,"dec"
> ,"decimal"
> ,"double"
> ,"float"
> ,"int"
> ,"integer"
> ,"nchar"
> ,"nclob"
> ,"numeric"
> ,"real"
> ,"smallint"
> ,"time"
> ,"timestamp"
> ,"varchar"
> ,"varbinary"
> ]

View file

@ -508,48 +508,10 @@ factoring in this function, and it is a little dense.
> -- this parser handles the fixed set of multi word > -- this parser handles the fixed set of multi word
> -- type names, plus all the type names which are > -- type names, plus all the type names which are
> -- reserved words > -- reserved words
> reservedTypeNames = (:[]) . Name Nothing . unwords <$> makeKeywordTree > reservedTypeNames = do
> ["double precision" > d <- getState
> ,"character varying" > (:[]) . Name Nothing . unwords <$> makeKeywordTree (diSpecialTypeNames d)
> ,"char varying" >
> ,"character large object"
> ,"char large object"
> ,"national character"
> ,"national char"
> ,"national character varying"
> ,"national char varying"
> ,"national character large object"
> ,"nchar large object"
> ,"nchar varying"
> ,"bit varying"
> ,"binary large object"
> ,"binary varying"
> -- reserved keyword typenames:
> ,"array"
> ,"bigint"
> ,"binary"
> ,"blob"
> ,"boolean"
> ,"char"
> ,"character"
> ,"clob"
> ,"date"
> ,"dec"
> ,"decimal"
> ,"double"
> ,"float"
> ,"int"
> ,"integer"
> ,"nchar"
> ,"nclob"
> ,"numeric"
> ,"real"
> ,"smallint"
> ,"time"
> ,"timestamp"
> ,"varchar"
> ,"varbinary"
> ]
= Scalar expressions = Scalar expressions