From ccd0e6708f4efcf2afac334749c0712edb694042 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Sun, 20 Apr 2014 16:13:14 +0300 Subject: [PATCH] start new file for the sql 2011 tests based on the grammar from the draft standard --- TODO | 2 + simple-sql-parser.cabal | 7 +- tools/Filter.lhs | 35 + tools/FilterSpaces.lhs | 24 + tools/Language/SQL/SimpleSQL/SQL2011.lhs | 4802 ++++++++++++---------- tools/Language/SQL/SimpleSQL/Tests.lhs | 2 + 6 files changed, 2627 insertions(+), 2245 deletions(-) create mode 100644 tools/Filter.lhs create mode 100644 tools/FilterSpaces.lhs diff --git a/TODO b/TODO index 4b520f2..468201e 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,8 @@ continue 2003 review and tests - base of error messages but add some more variations 3. start thinking about tests for invalid syntax +review names in the syntax for correspondence with sql standard, avoid + gratuitous differences touch up the expr hack as best as can diff --git a/simple-sql-parser.cabal b/simple-sql-parser.cabal index 03b3eb3..b13095b 100644 --- a/simple-sql-parser.cabal +++ b/simple-sql-parser.cabal @@ -53,16 +53,19 @@ Test-Suite Tests Language.SQL.SimpleSQL.Parser, Language.SQL.SimpleSQL.Syntax, + Language.SQL.SimpleSQL.ErrorMessages, Language.SQL.SimpleSQL.FullQueries, Language.SQL.SimpleSQL.GroupBy, Language.SQL.SimpleSQL.Postgres, Language.SQL.SimpleSQL.QueryExprComponents, Language.SQL.SimpleSQL.QueryExprs, - Language.SQL.SimpleSQL.ValueExprs, + Language.SQL.SimpleSQL.SQL2003, + Language.SQL.SimpleSQL.SQL2011, Language.SQL.SimpleSQL.TableRefs, Language.SQL.SimpleSQL.TestTypes, Language.SQL.SimpleSQL.Tests, - Language.SQL.SimpleSQL.Tpch + Language.SQL.SimpleSQL.Tpch, + Language.SQL.SimpleSQL.ValueExprs other-extensions: TupleSections,OverloadedStrings,DeriveDataTypeable default-language: Haskell2010 diff --git a/tools/Filter.lhs b/tools/Filter.lhs new file mode 100644 index 0000000..a179c03 --- /dev/null +++ b/tools/Filter.lhs @@ -0,0 +1,35 @@ + +> 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 diff --git a/tools/FilterSpaces.lhs b/tools/FilterSpaces.lhs new file mode 100644 index 0000000..d43b113 --- /dev/null +++ b/tools/FilterSpaces.lhs @@ -0,0 +1,24 @@ + +> --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' [] = [] + diff --git a/tools/Language/SQL/SimpleSQL/SQL2011.lhs b/tools/Language/SQL/SimpleSQL/SQL2011.lhs index 2d108d8..2e8931d 100644 --- a/tools/Language/SQL/SimpleSQL/SQL2011.lhs +++ b/tools/Language/SQL/SimpleSQL/SQL2011.lhs @@ -7,202 +7,155 @@ The goal is to create some example tests for each bit of grammar, with some areas getting more comprehensive coverage tests, and also to note which parts aren't currently supported. - -> module Language.SQL.SimpleSQL.SQL2003 (sql2011Tests) where - +> module Language.SQL.SimpleSQL.SQL2011 (sql2011Tests) where > import Language.SQL.SimpleSQL.TestTypes > import Language.SQL.SimpleSQL.Syntax > sql2011Tests :: TestItem -> sql2011Tests = Group "sql2011 tests" +> sql2011Tests = Group "sql 2011 tests" > [literals -> ,Group "value expressions" -> [typeNameTests -> ,parenthesizedValueExpression -> ,someGeneralValues -> ,targetSpecification -> ,contextuallyTypeValueSpec -> ,moduleColumnRef -> ,groupingOperation -> --,windowFunction -> --,caseExpression -> --,castSpecification -> ,nextValueExpression -> -- subtype treatment, method invoc, static m i, new spec, attrib/method ref, deref, method ref, ref res -> ,arrayElementReference -> ,multisetElementReference -> ,numericValueExpression -> --,numericValueFunction -> --,stringValueExpression -> --,stringValueFunction -> --,datetimeValueExpression -> --,datetimeValueFunction -> --,intervalValueExpression -> --,intervalValueFunction -> --,booleanValueExpression -> --arrayValueExpression -> ,arrayValueConstructor -> ,multisetValueExpression -> ,multisetValueFunction -> ,multisetValueConstructor -> ],Group "query expressions" -> [ -> -- rowValueConstructor -> --,rowValueExpression -> --,tableValueConstructor -> --,fromClause -> --,joinedTable -> --,whereClause -> groupbyClause -> --,havingClause -> --,windowClause -> --,querySpecification -> --,querySpecifications -> --,setOperations -> --,withExpressions -> ],Group "predicates" -> [--comparisonPredicate -> --,betweenPredicate -> --,inPredicate -> --,likePredicate -> --,similarPredicae -> --,nullPredicate -> quantifiedComparisonPredicate -> --,existsPredicate -> ,uniquePredicate -> --,normalizedPredicate -> ,matchPredicate -> --,overlapsPredicate -> --,distinctPredicate -> --,memberPredicate -> --,submultisetPredicate -> --,setPredicate +> ,identifiers +> ,typeNames +> ,valueExpressions +> ,queryExpressions +> ,scalarSubquery +> ,predicates +> ,intervalQualifier > ,collateClause -> ,aggregateFunctions +> ,aggregateFunction > ,sortSpecificationList > ] -> ] -= 5 Lexical Elements += 5 Lexical elements -Basic definitions of characters used, tokens, symbols, etc. Most of this section would normally be handled within the lexical analyzer rather than in the grammar proper. Further, the original document does not quote the various single characters, which makes it hard to process automatically. +The tests don't make direct use of these definitions. -[There seems to be a lot of unused stuff here, so skip this section -and only do bits which are needed by other bits] +== 5.1 -5.1 +Function - ::= +Define the terminal symbols of the SQL language and the elements of +strings. - ::= | | + ::= - ::= | + ::= + + | + | - ::= - A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z + ::= + + | - ::= - a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z + ::= + A | B | C | D | E | F | G | H | I | J | K | L | M | N | O + | P | Q | R | S | T | U | V | W | X | Y | Z - ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 + ::= + a | b | c | d | e | f | g | h | i | j | k | l | m | n | o + | p | q | r | s | t | u | v | w | x | y | z - ::= - - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | + ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - ::= !! See the Syntax Rules. + ::= + + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | - ::= " + ::= !! See the Syntax Rules. - ::= % + ::= " - ::= & + ::= % - ::= ' + ::= & - ::= ( + ::= ' - ::= ) + ::= ( - ::= * + ::= ) - ::= + + ::= * - ::= , + ::= + - ::= - + ::= , - ::= . + ::= - - ::= / + ::= . - ::= \ + ::= / - ::= : + ::= \ - ::= ; + ::= : - ::= < + ::= ; - ::= = + ::= < - ::= > + ::= = - ::= ? + ::= > - ::= | + ::= ? - ::= | + ::= | - ::= [ + ::= | - ::= ??( + ::= [ - ::= ] + ::= ??( - ::= ??) + ::= ] - ::= ^ + ::= ??) - ::= _ + ::= ^ - ::= /* Nothing */ | + ::= _ - ::= { + ::= | - ::= } + ::= { + ::= } +== 5.2 and -5.2 and +Function -Specifying lexical units (tokens and separators) that participate in SQL language. +Specify lexical units (tokens and separators) that participate in SQL +language. - ::= | + ::= | ::= @@ -215,13 +168,11 @@ Specifying lexical units (tokens and separators) that participate in SQL languag | | - ::= + ::= [ ... ] - ::= - - | + ::= | ::= !! See the Syntax Rules. @@ -231,40 +182,48 @@ Specifying lexical units (tokens and separators) that participate in SQL languag ::= K | M | G | T | P + ::= + - ::= + ::= ... - ::= ... + ::= + + | - ::= | + ::= + U + - ::= - U - + ::= + [ UESCAPE ] - ::= [ UESCAPE ] + ::= ... - ::= ... + ::= + + | - ::= | + ::= + + | + | - ::= - - | - | + ::= + - ::= + ::= + + - ::= - + ::= + - ::= + ::= !! See the Syntax Rules. - ::= !! See the Syntax Rules + ::= !! See the Syntax Rules. - ::= !! See the Syntax Rules. - - ::= + ::= ""!! two consecutive double quote characters ::= @@ -285,2912 +244,3269 @@ Specifying lexical units (tokens and separators) that participate in SQL languag | | - ::= + ::= <> - ::= + ::= >= - ::= + ::= <= - ::= + ::= || - ::= + ::= -> - ::= + ::= :: - ::= + ::= .. - ::= { | }... + ::= => - ::= | + ::= { | }... - ::= [ ... ] + ::= !! See the Syntax Rules. - ::= [ ... ] + ::= | - ::= - + ::= + [ ... ] - ::= + ::= - ::= + ::= + + + - ::= [ { | }... ] + ::= /* - ::= | + ::= */ - ::= !! See the Syntax Rules. + ::= + [ { | }... ]!! See the Syntax Rules. - ::= | + ::= | + + ::= !! See the Syntax Rules. + + ::= | ::= A | ABSOLUTE | ACTION | ADA | ADD | ADMIN | AFTER | ALWAYS | ASC | ASSERTION | ASSIGNMENT | ATTRIBUTE | ATTRIBUTES + | BEFORE | BERNOULLI | BREADTH - | C | CASCADE | CATALOG | CATALOG_NAME | CHAIN | CHARACTER_SET_CATALOG - | CHARACTER_SET_NAME | CHARACTER_SET_SCHEMA | CHARACTERISTICS | CHARACTERS - | CLASS_ORIGIN | COBOL | COLLATION | COLLATION_CATALOG | COLLATION_NAME | COLLATION_SCHEMA - | COLUMN_NAME | COMMAND_FUNCTION | COMMAND_FUNCTION_CODE | COMMITTED - | CONDITION_NUMBER | CONNECTION | CONNECTION_NAME | CONSTRAINT_CATALOG | CONSTRAINT_NAME - | CONSTRAINT_SCHEMA | CONSTRAINTS | CONSTRUCTOR | CONTINUE | CURSOR_NAME + + | C | CASCADE | CATALOG | CATALOG_NAME | CHAIN | CHARACTER_SET_CATALOG + | CHARACTER_SET_NAME | CHARACTER_SET_SCHEMA | CHARACTERISTICS | CHARACTERS + | CLASS_ORIGIN | COBOL | COLLATION | COLLATION_CATALOG | COLLATION_NAME | COLLATION_SCHEMA + | COLUMN_NAME | COMMAND_FUNCTION | COMMAND_FUNCTION_CODE | COMMITTED + | CONDITION_NUMBER | CONNECTION | CONNECTION_NAME | CONSTRAINT_CATALOG | CONSTRAINT_NAME + | CONSTRAINT_SCHEMA | CONSTRAINTS | CONSTRUCTOR | CONTINUE | CURSOR_NAME + | DATA | DATETIME_INTERVAL_CODE | DATETIME_INTERVAL_PRECISION | DEFAULTS | DEFERRABLE | DEFERRED | DEFINED | DEFINER | DEGREE | DEPTH | DERIVED | DESC | DESCRIPTOR | DIAGNOSTICS | DISPATCH | DOMAIN | DYNAMIC_FUNCTION | DYNAMIC_FUNCTION_CODE + | ENFORCED | EXCLUDE | EXCLUDING | EXPRESSION + | FINAL | FIRST | FLAG | FOLLOWING | FORTRAN | FOUND + | G | GENERAL | GENERATED | GO | GOTO | GRANTED + | HIERARCHY + | IGNORE | IMMEDIATE | IMMEDIATELY | IMPLEMENTATION | INCLUDING | INCREMENT | INITIALLY | INPUT | INSTANCE | INSTANTIABLE | INSTEAD | INVOKER | ISOLATION + | K | KEY | KEY_MEMBER | KEY_TYPE + | LAST | LENGTH | LEVEL | LOCATOR + | M | MAP | MATCHED | MAXVALUE | MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH | MESSAGE_TEXT | MINVALUE | MORE | MUMPS + | NAME | NAMES | NESTING | NEXT | NFC | NFD | NFKC | NFKD | NORMALIZED | NULLABLE | NULLS | NUMBER + | OBJECT | OCTETS | OPTION | OPTIONS | ORDERING | ORDINALITY | OTHERS | OUTPUT | OVERRIDING - | P | PAD | PARAMETER_MODE | PARAMETER_NAME | PARAMETER_ORDINAL_POSITION - | PARAMETER_SPECIFIC_CATALOG | PARAMETER_SPECIFIC_NAME | PARAMETER_SPECIFIC_SCHEMA - | PARTIAL | PASCAL | PATH | PLACING | PLI | PRECEDING | PRESERVE | PRIOR - | PRIVILEGES | PUBLIC + + | P | PAD | PARAMETER_MODE | PARAMETER_NAME | PARAMETER_ORDINAL_POSITION + | PARAMETER_SPECIFIC_CATALOG | PARAMETER_SPECIFIC_NAME | PARAMETER_SPECIFIC_SCHEMA + | PARTIAL | PASCAL | PATH | PLACING | PLI | PRECEDING | PRESERVE | PRIOR + | PRIVILEGES | PUBLIC + | READ | RELATIVE | REPEATABLE | RESPECT | RESTART | RESTRICT | RETURNED_CARDINALITY | RETURNED_LENGTH | RETURNED_OCTET_LENGTH | RETURNED_SQLSTATE | ROLE | ROUTINE | ROUTINE_CATALOG | ROUTINE_NAME | ROUTINE_SCHEMA | ROW_COUNT - | SCALE | SCHEMA | SCHEMA_NAME | SCOPE_CATALOG | SCOPE_NAME | SCOPE_SCHEMA - | SECTION | SECURITY | SELF | SEQUENCE | SERIALIZABLE | SERVER_NAME | SESSION - | SETS | SIMPLE | SIZE | SOURCE | SPACE | SPECIFIC_NAME | STATE | STATEMENT - | STRUCTURE | STYLE | SUBCLASS_ORIGIN + + | SCALE | SCHEMA | SCHEMA_NAME | SCOPE_CATALOG | SCOPE_NAME | SCOPE_SCHEMA + | SECTION | SECURITY | SELF | SEQUENCE | SERIALIZABLE | SERVER_NAME | SESSION + | SETS | SIMPLE | SIZE | SOURCE | SPACE | SPECIFIC_NAME | STATE | STATEMENT + | STRUCTURE | STYLE | SUBCLASS_ORIGIN + | T | TABLE_NAME | TEMPORARY | TIES | TOP_LEVEL_COUNT | TRANSACTION | TRANSACTION_ACTIVE | TRANSACTIONS_COMMITTED | TRANSACTIONS_ROLLED_BACK | TRANSFORM | TRANSFORMS | TRIGGER_CATALOG | TRIGGER_NAME | TRIGGER_SCHEMA | TYPE + | UNBOUNDED | UNCOMMITTED | UNDER | UNNAMED | USAGE | USER_DEFINED_TYPE_CATALOG | USER_DEFINED_TYPE_CODE | USER_DEFINED_TYPE_NAME | USER_DEFINED_TYPE_SCHEMA + | VIEW + | WORK | WRITE + | ZONE + ::= ABS | ALL | ALLOCATE | ALTER | AND | ANY | ARE | ARRAY | ARRAY_AGG | ARRAY_MAX_CARDINALITY | AS | ASENSITIVE | ASYMMETRIC | AT | ATOMIC | AUTHORIZATION | AVG + | BEGIN | BEGIN_FRAME | BEGIN_PARTITION | BETWEEN | BIGINT | BINARY | BLOB | BOOLEAN | BOTH | BY - | CALL | CALLED | CARDINALITY | CASCADED | CASE | CAST | CEIL | CEILING - | CHAR | CHAR_LENGTH | CHARACTER | CHARACTER_LENGTH | CHECK | CLOB | CLOSE - | COALESCE | COLLATE | COLLECT | COLUMN | COMMIT | CONDITION | CONNECT - | CONSTRAINT | CONTAINS | CONVERT | CORR | CORRESPONDING | COUNT | COVAR_POP - | COVAR_SAMP | CREATE | CROSS | CUBE | CUME_DIST | CURRENT | CURRENT_CATALOG - | CURRENT_DATE | CURRENT_DEFAULT_TRANSFORM_GROUP | CURRENT_PATH | CURRENT_ROLE - | CURRENT_ROW | CURRENT_SCHEMA | CURRENT_TIME | CURRENT_TIMESTAMP - | CURRENT_TRANSFORM_GROUP_FOR_TYPE | CURRENT_USER | CURSOR | CYCLE + + | CALL | CALLED | CARDINALITY | CASCADED | CASE | CAST | CEIL | CEILING + | CHAR | CHAR_LENGTH | CHARACTER | CHARACTER_LENGTH | CHECK | CLOB | CLOSE + | COALESCE | COLLATE | COLLECT | COLUMN | COMMIT | CONDITION | CONNECT + | CONSTRAINT | CONTAINS | CONVERT | CORR | CORRESPONDING | COUNT | COVAR_POP + | COVAR_SAMP | CREATE | CROSS | CUBE | CUME_DIST | CURRENT | CURRENT_CATALOG + | CURRENT_DATE | CURRENT_DEFAULT_TRANSFORM_GROUP | CURRENT_PATH | CURRENT_ROLE + | CURRENT_ROW | CURRENT_SCHEMA | CURRENT_TIME | CURRENT_TIMESTAMP + | CURRENT_TRANSFORM_GROUP_FOR_TYPE | CURRENT_USER | CURSOR | CYCLE + | DATE | DAY | DEALLOCATE | DEC | DECIMAL | DECLARE | DEFAULT | DELETE | DENSE_RANK | DEREF | DESCRIBE | DETERMINISTIC | DISCONNECT | DISTINCT | DOUBLE | DROP | DYNAMIC + | EACH | ELEMENT | ELSE | END | END_FRAME | END_PARTITION | END-EXEC | EQUALS | ESCAPE | EVERY | EXCEPT | EXEC | EXECUTE | EXISTS | EXP | EXTERNAL | EXTRACT + | FALSE | FETCH | FILTER | FIRST_VALUE | FLOAT | FLOOR | FOR | FOREIGN | FRAME_ROW | FREE | FROM | FULL | FUNCTION | FUSION + | GET | GLOBAL | GRANT | GROUP | GROUPING | GROUPS + | HAVING | HOLD | HOUR + | IDENTITY | IN | INDICATOR | INNER | INOUT | INSENSITIVE | INSERT | INT | INTEGER | INTERSECT | INTERSECTION | INTERVAL | INTO | IS + | JOIN + | LAG | LANGUAGE | LARGE | LAST_VALUE | LATERAL | LEAD | LEADING | LEFT | LIKE | LIKE_REGEX | LN | LOCAL | LOCALTIME | LOCALTIMESTAMP | LOWER + | MATCH | MAX | MEMBER | MERGE | METHOD | MIN | MINUTE | MOD | MODIFIES | MODULE | MONTH | MULTISET + | NATIONAL | NATURAL | NCHAR | NCLOB | NEW | NO | NONE | NORMALIZE | NOT | NTH_VALUE | NTILE | NULL | NULLIF | NUMERIC + | OCTET_LENGTH | OCCURRENCES_REGEX | OF | OFFSET | OLD | ON | ONLY | OPEN | OR | ORDER | OUT | OUTER | OVER | OVERLAPS | OVERLAY + | PARAMETER | PARTITION | PERCENT | PERCENT_RANK | PERCENTILE_CONT | PERCENTILE_DISC | PERIOD | PORTION | POSITION | POSITION_REGEX | POWER | PRECEDES | PRECISION | PREPARE | PRIMARY | PROCEDURE + | RANGE | RANK | READS | REAL | RECURSIVE | REF | REFERENCES | REFERENCING | REGR_AVGX | REGR_AVGY | REGR_COUNT | REGR_INTERCEPT | REGR_R2 | REGR_SLOPE | REGR_SXX | REGR_SXY | REGR_SYY | RELEASE | RESULT | RETURN | RETURNS | REVOKE | RIGHT | ROLLBACK | ROLLUP | ROW | ROW_NUMBER | ROWS + | SAVEPOINT | SCOPE | SCROLL | SEARCH | SECOND | SELECT | SENSITIVE | SESSION_USER | SET | SIMILAR | SMALLINT | SOME | SPECIFIC | SPECIFICTYPE | SQL | SQLEXCEPTION | SQLSTATE | SQLWARNING | SQRT | START | STATIC | STDDEV_POP | STDDEV_SAMP | SUBMULTISET | SUBSTRING | SUBSTRING_REGEX | SUCCEEDS | SUM | SYMMETRIC | SYSTEM | SYSTEM_TIME | SYSTEM_USER + | TABLE | TABLESAMPLE | THEN | TIME | TIMESTAMP | TIMEZONE_HOUR | TIMEZONE_MINUTE | TO | TRAILING | TRANSLATE | TRANSLATE_REGEX | TRANSLATION | TREAT | TRIGGER | TRUNCATE | TRIM | TRIM_ARRAY | TRUE - | UESCAPE | UNION | UNIQUE | UNKNOWN | UNNEST | UPDATE - | UPPER | USER | USING + + | UESCAPE | UNION | UNIQUE | UNKNOWN | UNNEST | UPDATE | UPPER | USER | USING + | VALUE | VALUES | VALUE_OF | VAR_POP | VAR_SAMP | VARBINARY | VARCHAR | VARYING | VERSIONING + | WHEN | WHENEVER | WHERE | WIDTH_BUCKET | WINDOW | WITH | WITHIN | WITHOUT + | YEAR +== 5.3 - -= 5.3 (p143) - - ::= | - - ::= | - - ::= - - | - | - | - | - | - | +Function +Specify a non-null value. > literals :: TestItem > literals = Group "literals" -> [numericLiterals -> ,stringLiterals +> [numericLiterals,generalLiterals] + + ::= | + + ::= | + + ::= + + | + | + | + | + | + | + +> generalLiterals :: TestItem +> generalLiterals = Group "general literals" +> [characterStringLiterals > ,nationalCharacterStringLiterals -> ,unicodeStringLiterals +> ,unicodeCharacterStringLiterals > ,binaryStringLiterals -> --,datetimeLiteral TODO +> ,dateTimeLiterals > ,intervalLiterals > ,booleanLiterals] + ::= + [ ] + [ ... ] + [ { [ ... ] }... ] -== Character string literals + ::= - ::= - [ ] - [ ... ] - [ { [ ... ] }... ] + ::= | - ::= + ::= !! See the Syntax Rules. - ::= | + ::= - ::= !! See the Syntax Rules. - - ::= - -> stringLiterals :: TestItem -> stringLiterals = Group "string literals" $ map (uncurry TestValueExpr) -> [("'a regular string literal'" -> ,StringLit "a regular string literal") -> ,("'something' ' some more' 'and more'" -> ,StringLit "something some moreand more") -> ,("'something' \n ' some more' \t 'and more'" -> ,StringLit "something some moreand more") -> ,("'something' -- a comment\n ' some more' /*another comment*/ 'and more'" -> ,StringLit "something some moreand more") -> ,("'a quote: '', stuff'" -> ,StringLit "a quote: ', stuff") -> ,("''" -> ,StringLit "") -> ,("_francais 'français'" -> ,TypedLit (TypeName [Name "_francais"]) "français") +> characterStringLiterals :: TestItem +> characterStringLiterals = Group "character string literals" +> [-- TODO: character string literals > ] -== other string literals - - ::= - N [ ... ] - [ { [ ... ] }... ] + ::= + N [ ... ] + [ { [ ... ] }... ] > nationalCharacterStringLiterals :: TestItem -> nationalCharacterStringLiterals = Group "national character string literals" $ map (uncurry TestValueExpr) -> [("N'something'", CSStringLit "N" "something") -> ,("n'something'", CSStringLit "n" "something") +> nationalCharacterStringLiterals = Group "national character string literals" +> [-- TODO: national character string literals > ] - ::= - [ ] - U [ ... ] - [ { [ ... ] }... ] - - ::= | + ::= + [ ] + U [ ... ] + [ { [ ... ] }... ] + -> unicodeStringLiterals :: TestItem -> unicodeStringLiterals = Group "unicode string literals" $ map (uncurry TestValueExpr) -> [("U&'something'", CSStringLit "U&" "something") -> ,("u&'something' escape =" -> ,Escape (CSStringLit "u&" "something") '=') -> ,("u&'something' uescape =" -> ,UEscape (CSStringLit "u&" "something") '=') + ::= + + | + +> unicodeCharacterStringLiterals :: TestItem +> unicodeCharacterStringLiterals = Group "unicode character string literals" +> [-- TODO: unicode character string literals > ] -== other string literals - ::= - X [ ... ] [ { [ ... ] [ ...[ { [ ... ] [ { [ ... ] - [ ... ] }... ] }... ] - ] }... ] + X [ ... ] [ { [ ... ] [ ... ] }... ] + [ { [ ... ] [ { [ ... ] + [ ... ] }... ] }... ] - ::= | A | B | C | D | E | F | a | b | c | d | e | f + ::= | A | B | C | D | E | F | a | b | c | d | e | f > binaryStringLiterals :: TestItem -> binaryStringLiterals = Group "bit and hex string literals" $ map (uncurry TestValueExpr) -> [("B'101010'", CSStringLit "B" "101010") -> ,("X'7f7f7f'", CSStringLit "X" "7f7f7f") -> ,("X'7f7f7f' escape z", Escape (CSStringLit "X" "7f7f7f") 'z') +> binaryStringLiterals = Group "binary string literals" +> [-- TODO: binary string literals > ] -== numeric literals + ::= [ ] - ::= [ ] + ::= + + | - ::= | + ::= + [ [ ] ] + | - ::= - [ [ ] ] - | + ::= | - ::= | + ::= E - ::= E + ::= - ::= + ::= - ::= + ::= [ ] - ::= [ ] - - ::= ... + ::= ... > numericLiterals :: TestItem -> numericLiterals = Group "numeric literals" $ map (uncurry TestValueExpr) -> [("11", NumLit "11") -> ,("11.11", NumLit "11.11") - -> ,("11E23", NumLit "11E23") -> ,("11E+23", NumLit "11E+23") -> ,("11E-23", NumLit "11E-23") - -> ,("11.11E23", NumLit "11.11E23") -> ,("11.11E+23", NumLit "11.11E+23") -> ,("11.11E-23", NumLit "11.11E-23") - -> ,("+11E23", PrefixOp [Name "+"] $ NumLit "11E23") -> ,("+11E+23", PrefixOp [Name "+"] $ NumLit "11E+23") -> ,("+11E-23", PrefixOp [Name "+"] $ NumLit "11E-23") -> ,("+11.11E23", PrefixOp [Name "+"] $ NumLit "11.11E23") -> ,("+11.11E+23", PrefixOp [Name "+"] $ NumLit "11.11E+23") -> ,("+11.11E-23", PrefixOp [Name "+"] $ NumLit "11.11E-23") - -> ,("-11E23", PrefixOp [Name "-"] $ NumLit "11E23") -> ,("-11E+23", PrefixOp [Name "-"] $ NumLit "11E+23") -> ,("-11E-23", PrefixOp [Name "-"] $ NumLit "11E-23") -> ,("-11.11E23", PrefixOp [Name "-"] $ NumLit "11.11E23") -> ,("-11.11E+23", PrefixOp [Name "-"] $ NumLit "11.11E+23") -> ,("-11.11E-23", PrefixOp [Name "-"] $ NumLit "11.11E-23") - -> ,("11.11e23", NumLit "11.11e23") - +> numericLiterals = Group "numeric literals" +> [-- TODO: numeric literals > ] -== date and time literals + ::= |