{-# LANGUAGE OverloadedStrings #-} module Hydra.Sources.Tier4.Langs.Sql.Ansi where import Hydra.Sources.Tier3.All import Hydra.Dsl.Grammars import Hydra.Tools.GrammarToModule import qualified Hydra.Dsl.Annotations as Ann import qualified Hydra.Grammar as G import qualified Data.List as L sqlModule :: Module Kv sqlModule = grammarToModule ns sqlGrammar $ Just ("A subset of ANSI SQL:2003, capturing selected productions of the BNF grammar provided at " ++ "https://ronsavage.github.io/SQL/sql-2003-2.bnf.html, which is based on " ++ "the Final Committee Draft (FCD) of ISO/IEC 9075-2:2003") where ns = Namespace "hydra/langs/sql/ansi" sqlGrammar :: G.Grammar sqlGrammar = G.Grammar $ tokens ++ productions tokens :: [G.Production] tokens = [ -- ::= E define "ApproximateNumericLiteral" [regex $ mantissa ++ "E" ++ exponent], -- ::= -- X [ { }... ] -- [ { [ { }... ] }... ] -- [ ESCAPE ] define "BinaryStringLiteral" unsupported, -- ::= -- [ ] -- [ ... ] -- [ { [ ... ] }... ] define "CharacterStringLiteral" [regex $ opt(introducer ++ characterSetSpecification) ++ quote ++ star(characterRepresentation) ++ quote ++ star(separator ++ quote ++ star(characterRepresentation) ++ quote)], -- ::= define "ColumnName" [regex identifier], -- ::= define "DateString" unsupported, -- ::= define "DomainName" [regex schemaQualifiedName], -- ::= -- [ [ ] ] -- | define "ExactNumericLiteral" [regex $ or [ unsignedInteger ++ opt (period ++ unsignedInteger), period ++ unsignedInteger]], -- ::= | define "LeftBracketOrTrigraph" [regex $ or [leftBracket, leftBracketTrigraph]], -- ::= | define "RightBracketOrTrigraph" [regex $ or [rightBracket, rightBracketTrigraph]], -- ::= -- N [ ... ] -- [ { [ ... ] }... ] define "NationalCharacterStringLiteral" unsupported, -- ::= define "PathResolvedUserDefinedTypeName" [regex userDefinedTypeName], -- ::= define "TableName" [regex localOrSchemaQualifiedName], --
define "InsertionTarget" [ "TableName"], -- ::= INTERVAL [ ] define "IntervalLiteral" unsupported, -- ::= INTERVAL define "IntervalType" unsupported, -- ::= -- -- | -- | -- | define "IntervalValueExpression" unsupported, -- ::= -- [ ] [ ] -- | [ ] define "LargeObjectLength" unsupported, -- ::= define "Length" [ "UnsignedInteger"], -- ::= LIKE
[ ] define "LikeClause" unsupported, -- ::= | define "MethodInvocation" unsupported, -- ::= -- ELEMENT define "MultisetElementReference" unsupported, -- ::= MULTISET define "MultisetType" [ list["DataType", multiset_]], -- ::= -- -- | -- |
define "MultisetValueConstructor" unsupported, -- ::= -- -- | MULTISET UNION [ ALL | DISTINCT ] -- | MULTISET EXCEPT [ ALL | DISTINCT ] define "MultisetValueExpression" unsupported, -- ::= -- NATIONAL CHARACTER [ ] -- | NATIONAL CHAR [ ] -- | NCHAR [ ] -- | NATIONAL CHARACTER VARYING -- | NATIONAL CHAR VARYING -- | NCHAR VARYING -- | NATIONAL CHARACTER LARGE OBJECT [ ] -- | NCHAR LARGE OBJECT [ ] -- | NCLOB [ ] define "NationalCharacterStringType" unsupported, -- ::= NEW define "NewSpecification" unsupported, -- ::= NEXT VALUE FOR define "NextValueExpression" unsupported, -- ::= | define "NumericType" [ "exact">: "ExactNumericType", "approximate">: "ApproximateNumericType"], -- ::= -- -- | -- | define "NumericValueExpression" unsupported, -- ::= OVERRIDING USER VALUE | OVERRIDING SYSTEM VALUE define "OverrideClause" [ overriding_user_value_, overriding_system_value], -- ::= define "ParenthesizedValueExpression" [ parens["ValueExpression"]], -- ::= define "Precision" [ "UnsignedInteger"], -- ::= -- [ CHARACTER SET ] [ ] -- | [ ] -- | -- | -- | -- | -- | define "PredefinedType" [ "string">: list[ "type">: "CharacterStringType", "characters">: opt(list[character_set_, "CharacterSetSpecification"]), "collate">: opt"CollateClause"], "nationalString">: list[ "type">: "NationalCharacterStringType", "collate">: opt"CollateClause"], "blob">: "BinaryLargeObjectStringType", "numeric">: "NumericType", "boolean">: "BooleanType", "datetime">: "DatetimeType", "interval">: "IntervalType"], -- ::= -- -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | define "Predicate" unsupported, -- ::= [ ] define "QueryExpression" unsupported, -- ::= REFERENCES ARE [ NOT ] CHECKED [ ON DELETE ] define "ReferenceScopeCheck" unsupported, -- ::= REF [ ] define "ReferenceType" unsupported, -- ::= ROW define "RowType" unsupported, -- ::= define "RowValueSpecialCase" [ "NonparenthesizedValueExpressionPrimary"], -- ::= -- -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | define "NonparenthesizedValueExpressionPrimary" [ "unsigned">: "UnsignedValueSpecification", "column">: "ColumnReference", "setFunction">: "SetFunctionSpecification", "windowFunction">: "WindowFunction", "scalarSubquery">: "ScalarSubquery", "cases">: "CaseExpression", "cast">: "CastSpecification", "field">: "FieldReference", "subtype">: "SubtypeTreatment", "method">: "MethodInvocation", "staticMethod">: "StaticMethodInvocation", "new">: "NewSpecification", "attributeOrMethod">: "AttributeOrMethodReference", "reference">: "ReferenceResolution", "collection">: "CollectionValueConstructor", "arrayElement">: "ArrayElementReference", "multisetElement">: "MultisetElementReference", "routine">: "RoutineInvocation", "next">: "NextValueExpression"], -- ::= DEREF define "ReferenceResolution" unsupported, -- ::= define "ReferenceValueExpression" [ "ValueExpressionPrimary"], -- ::= -- -- | define "RowValueExpression" unsupported, -- ::= define "RoutineInvocation" unsupported, -- ::= define "ScalarSubquery" [ "Subquery"], -- ::= define "Scale" [ "UnsignedInteger"], -- ::= REF IS define "SelfReferencingColumnSpecification" unsupported, -- ::= | define "SetFunctionSpecification" unsupported, -- ::= -- [ ] define "StaticMethodInvocation" unsupported, -- ::= | define "StringValueExpression" unsupported, -- ::= define "Subquery" [ parens["QueryExpression"]], -- ::= UNDER define "SubtableClause" unsupported, -- ::= -- TREAT AS define "SubtypeTreatment" unsupported, --
::= PRESERVE | DELETE define "TableCommitAction" [ "preserve">: preserve_, "delete">: delete_], --
::= [ ]
[ ] define "TableConstraintDefinition" unsupported, --
::= --
-- | OF [ ] [
] -- | define "TableContentsSource" [ "list">: "TableElementList", "subtable">: list [ of_, "type">: "PathResolvedUserDefinedTypeName", "subtable">: opt"SubtableClause", "elements">: opt"TableElementList"], "subquery">: "AsSubqueryClause"], --
::= -- CREATE [
] TABLE
-- [ ON COMMIT
ROWS ] define "TableDefinition" [ list[ create_, "scope">: opt"TableScope", table_, "name">: "TableName", "source">: "TableContentsSource", "commitActions">: opt(list[on_commit_, "TableCommitAction", rows_])]], --
::= -- -- |
-- | -- | -- | define "TableElement" [ "column">: "ColumnDefinition", "tableConstraint">: "TableConstraintDefinition", "like">: "LikeClause", "selfReferencingColumn">: "SelfReferencingColumnSpecification", "columOptions">: "ColumnOptions"], --
::=
[ {
}... ] define "TableElementList" [ parens[commaList "TableElement"]], --
::= TEMPORARY define "TableScope" [ list["GlobalOrLocal", temporary_]], --