h*YK      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~0.7.0 Safe-Inferred"7\simple-sql-parserUsed to set the dialect used for parsing and pretty printing, very unfinished at the moment.&The keyword handling works as follows:There is a list of reserved keywords. These will never parse as anything other than as a keyword, unless they are in one of the other lists.There is a list of 'identifier' keywords. These are reserved keywords, with an exception that they will parse as an identifier in a scalar expression. They won't parse as identifiers in other places, e.g. column names or aliases.There is a list of 'app' keywords. These are reserved keywords, with an exception that they will also parse in an 'app-like' construct - a regular function call, or any of the aggregate and window variations.There is a list of special type names. This list serves two purposes - it is a list of the reserved keywords which are also type names, and it is a list of all the multi word type names.Every keyword should appear in the keywords lists, and then you can add them to the other lists if you want exceptions. Most things that refer to functions, types or variables that are keywords in the ansi standard, can be removed from the keywords lists completely with little effect. With most of the actual SQL keywords, removing them from the keyword list will result in lots of valid syntax no longer parsing (and probably bad parse error messages too).In the code, all special syntax which looks identical to regular identifiers or function calls (apart from the name), is treated like a regular identifier or function call.It's easy to break the parser by removing the wrong words from the keywords list or adding the wrong words to the other lists.simple-sql-parserreserved keywordssimple-sql-parser"keywords with identifier exceptionsimple-sql-parserkeywords with app exceptionsimple-sql-parserkeywords with type exception plus all the type names which are multiple wordssimple-sql-parserallow ansi fetch first syntaxsimple-sql-parser+allow limit keyword (mysql, postgres, ...)simple-sql-parserallow parsing ODBC syntax simple-sql-parser+allow quoting identifiers with `backquotes` simple-sql-parser0allow quoting identifiers with [square brackets] simple-sql-parser,allow identifiers with a leading at @example simple-sql-parser+allow identifiers with a leading # #example simple-sql-parser+allow positional identifiers like this: $1 simple-sql-parser#allow postgres style dollar stringssimple-sql-parser$allow strings with an e - e"example"simple-sql-parserallow postgres style symbolssimple-sql-parserallow sql server style symbolssimple-sql-parserallow sql server style for CONVERT function in format CONVERT(data_type(length), expression, style)simple-sql-parser$allow creating autoincrement columnssimple-sql-parser3allow omitting the comma between constraint clausessimple-sql-parseransi sql 2011 dialectsimple-sql-parser mysql dialectsimple-sql-parserpostgresql dialectsimple-sql-parseroracle dialectsimple-sql-parsermicrosoft sql server dialect   Safe-Inferred"%&#simple-sql-parserWrapper to allow using the lexer as input to a megaparsec parser."simple-sql-parserPositional information added to tokens to preserve source positions for the parser)simple-sql-parserRepresents a lexed token*simple-sql-parser2A symbol (in ansi dialect) is one of the following!multi char symbols <> <= >= != ||single char symbols: * + -   ^ / % ~ & | ? ( ) [ ] , ; ( )+simple-sql-parserThis is an identifier or keyword. The first field is the quotes used, or nothing if no quotes were used. The quotes can be " or u& or something dialect specific like [],simple-sql-parserThis is a prefixed variable symbol, such as :var, @var or #var (only :var is used in ansi dialect)-simple-sql-parser+This is a positional arg identifier e.g. $1.simple-sql-parserThis is a string literal. The first two fields are the -- start and end quotes, which are usually both ', but can be the character set (one of nNbBxX, or u&, U&), or a dialect specific string quoting (such as $$ in postgres)/simple-sql-parserA number literal (integral or otherwise), stored in original format unchanged0simple-sql-parser1Whitespace, one or more of space, tab or newline.1simple-sql-parserA commented line using --, contains every character starting with the '--' and including the terminating newline character if there is one - this will be missing if the last line in the source is a line comment with no trailing newline2simple-sql-parser=A block comment, /* stuff */, includes the comment delimiters3simple-sql-parser!Lex some SQL to a list of tokens.4simple-sql-parser!Lex some SQL to a list of tokens.6simple-sql-parserPretty printing, if you lex a bunch of tokens, then pretty print them, should should get back exactly the same stringsimple-sql-parserparser for a sql token8simple-sql-parserUtility function to tell you if a list of tokens will pretty print then lex back to the same set of tokens. Used internally, might be useful for generating SQL via lexical tokens.3simple-sql-parserdialect of SQL to usesimple-sql-parser!filename to use in error messagessimple-sql-parserline number and column number of the first character in the source to use in error messagessimple-sql-parserthe SQL source to lex4simple-sql-parserdialect of SQL to usesimple-sql-parser!filename to use in error messagessimple-sql-parserline number and column number of the first character in the source to use in error messagessimple-sql-parserthe SQL source to lex)*+,-./012"#'$%&4367(58 !)*+,-./012"#'$%&4367(58 ! Safe-Inferred7?vMsimple-sql-parserComment. Useful when generating SQL code programmatically. The parser doesn't produce these.simple-sql-parserThe join condition.simple-sql-parseron exprsimple-sql-parserusing (column list)simple-sql-parserThe type of a join.simple-sql-parserRepresents an alias for a table valued expression, used in with queries and in from alias, e.g. select a from t u, select a from t u(b), with a(c) as select 1, select * from a.simple-sql-parser;Represents a entry in the csv of tables in the from clause.simple-sql-parserfrom t / from s.tsimple-sql-parser3from a join b, the bool is true if natural was usedsimple-sql-parserfrom (a)simple-sql-parserfrom a as b(c,d)simple-sql-parserfrom (query expr)simple-sql-parserfrom function(args)simple-sql-parserfrom lateral tsimple-sql-parser.ODBC {oj t1 left outer join t2 on expr} syntaxsimple-sql-parser(Represents an item in a group by clause.simple-sql-parser/Corresponding, an option for the set operators.simple-sql-parserQuery expression set operators.simple-sql-parser'The direction for a column in order by.simple-sql-parserRepresents the Distinct or All keywords, which can be used before a select list, in an aggregate/window function application, or in a query expression set operator.simple-sql-parser,Represents a query expression, which can be:a regular select;*a set operator (union, except, intersect);!a common table expression (with);2a table value constructor (values (1,2),(3,4)); oran explicit table (table t).simple-sql-parser&the expressions and the column aliasessimple-sql-parserthe type of an odbc literal (e.g. {d '2000-01-01'}), correpsonding to the letter after the opening {simple-sql-parser&represents the start or end of a framesimple-sql-parserRepresents whether a window frame clause is over rows or ranges.simple-sql-parserRepresents the frame clause of a window this can be [range | rows] frame_start or [range | rows] between frame_start and frame_endsimple-sql-parser?Represents 'nulls first' or 'nulls last' in an order by clause.simple-sql-parser)Represents one field in an order by list.simple-sql-parser"A subquery in a scalar expression.simple-sql-parserexists (query expr)simple-sql-parserunique (query expr)simple-sql-parsera scalar subquerysimple-sql-parserUsed for 'expr in (scalar expression list)', and 'expr in (subquery)' syntax.simple-sql-parser&Represents a type name, used in casts.simple-sql-parserRepresents an identifier name, which can be quoted or unquoted. examples:test -> Name Nothing "test"$"test" -> Name (Just """,""") "test" something$ -> Name (Just ("`","`") "something"![ms] -> Name (Just ("[","]") "ms"simple-sql-parserRepresents a value expression. This is used for the expressions in select lists. It is also used for expressions in where, group by, having, order by and so on.simple-sql-parsera numeric literal optional decimal point, e+- integral exponent, e.g1010..110.11e512.34e-6simple-sql-parser3string literal, with the start and end quote e.g. test -> TextLit "'" "'" "test"simple-sql-parsertext of interval literal, units of interval precision, e.g. interval 3 days (3)simple-sql-parser%prefix 'typed literal', e.g. int '42'simple-sql-parser'identifier with parts separated by dotssimple-sql-parser#star, as in select *, t.*, count(*)simple-sql-parser'Represents a ? in a parameterized querysimple-sql-parser.Represents an e.g. $1 in a parameterized querysimple-sql-parserrepresents a host parameter, e.g. :a. The Maybe Text is for the indicator, e.g. :var indicator :nlsimple-sql-parserInfix binary operators. This is used for symbol operators (a + b), keyword operators (a and b) and multiple keyword operators (a is similar to b)simple-sql-parserPrefix unary operators. This is used for symbol operators, keyword operators and multiple keyword operators.simple-sql-parserPostfix unary operators. This is used for symbol operators, keyword operators and multiple keyword operators.simple-sql-parserUsed for ternary, mixfix and other non orthodox operators. Currently used for row constructors, and for between.simple-sql-parserfunction application (anything that looks like c style function application syntactically)simple-sql-parseraggregate application, which adds distinct or all, and order by, to regular function applicationsimple-sql-parseraggregates with within groupsimple-sql-parserwindow application, which adds over (partition by a order by b) to regular function application. Explicit frames are not currently supportedsimple-sql-parserUsed for the operators which look like functions except the arguments are separated by keywords instead of commas. The maybe is for the first unnamed argument if it is present, and the list is for the keyword argument pairs.simple-sql-parsercast(a as typename)simple-sql-parser%convert expression to given datatype -CONVERT(data_type(length), expression, style)simple-sql-parser(case expression. both flavours supportedsimple-sql-parserin list literal and in subquery, if the bool is false it means not in was used ('a not in (1,2)')simple-sql-parser!exists, all, any, some subqueriessimple-sql-parserrepresents an array access expression, or an array ctor e.g. a[3]. The first scalarExpr is the array, the second is the subscripts/ctor argssimple-sql-parserthis is used for the query expression version of array constructors, e.g. array(select * from t)simple-sql-parser%an odbc literal e.g. {d '2000-01-01'}simple-sql-parser0an odbc function call e.g. {fn CHARACTER_LENGTH(test)}simple-sql-parserif + or - usedsimple-sql-parser literal textsimple-sql-parseraggregate function namesimple-sql-parserdistinctsimple-sql-parserargssimple-sql-parserorder bysimple-sql-parserfiltersimple-sql-parser within groupsimple-sql-parserwindow function namesimple-sql-parserargssimple-sql-parser partition bysimple-sql-parserorder bysimple-sql-parser frame clausesimple-sql-parser test valuesimple-sql-parser when branchessimple-sql-parser else valuesimple-sql-parserHelper/ 'default' value for query exprs to make creating query expr values a little easier. It is defined like this: makeSelect :: MakeSelect makeSelect = MakeSelect {msSetQuantifier = SQDefault ,msSelectList = [] ,msFrom = [] ,msWhere = Nothing ,msGroupBy = [] ,msHaving = Nothing ,msOrderBy = [] ,msOffset = Nothing ,msFetchFirst = Nothing} Example, to create a select query expression with a select list 'sl': toQueryExpr $ makeSelect {msSelectList = sl}tuvwxyz{|}~pqrsklmnohijefgYZ[\]^OPQRSTUVWXbcd_`aMNBCDEFGHIJKLtuvwxyz{|}~pqrsklmnohijefgYZ[\]^OPQRSTUVWXbcd_`aMNBCDEFGHIJKL Safe-Inferred"Esimple-sql-parser!Convert a query expr ast to Text.simple-sql-parser!Convert a value expr ast to Text.simple-sql-parserA terminating semicolon.simple-sql-parser Convert a statement ast to Text.simple-sql-parserConvert a list of statements to Text. A semicolon is inserted after each statement. Safe-Inferred"Klsimple-sql-parser1Parses a query expr, trailing semicolon optional.simple-sql-parser0Parses a statement, trailing semicolon optional.simple-sql-parserParses a list of statements, with semi colons between them. The final semicolon is optional.simple-sql-parserParses a scalar expression.simple-sql-parserdialect of SQL to usesimple-sql-parser!filename to use in error messagessimple-sql-parserline number and column number of the first character in the source to use in error messagessimple-sql-parserthe SQL source to parsesimple-sql-parserdialect of SQL to usesimple-sql-parser!filename to use in error messagessimple-sql-parserline number and column number of the first character in the source to use in error messagessimple-sql-parserthe SQL source to parsesimple-sql-parserdialect of SQL to usesimple-sql-parser!filename to use in error messagessimple-sql-parserline number and column number of the first character in the source to use in error messagessimple-sql-parserthe SQL source to parsesimple-sql-parserdialect of SQL to usesimple-sql-parser!filename to use in error messagessimple-sql-parserline number and column number of the first character in the source to use in error messagessimple-sql-parserthe SQL source to parse        !"#$$%&''()*+,-./0123456789:;<=>?@ABCDEFFGHIJKLMNOP6QRSTUVWXYZ[\]^_`aabccdefghijklmnopqrstuvwxyz{|}~1,,9.simple-sql-parser-0.7.0-2bIclWxoajr3IixAA0BfY6Language.SQL.SimpleSQL.DialectLanguage.SQL.SimpleSQL.LexLanguage.SQL.SimpleSQL.SyntaxLanguage.SQL.SimpleSQL.PrettyLanguage.SQL.SimpleSQL.Parsesimple-sql-parserDialect diKeywordsdiIdentifierKeywords diAppKeywordsdiSpecialTypeNames diFetchFirstdiLimitdiOdbcdiBackquotedIdendiSquareBracketQuotedIdendiAtIdentifierdiHashIdentifierdiPositionalArgdiDollarString diEStringdiPostgresSymbolsdiSqlServerSymbolsdiConvertFunctiondiAutoincrementdiNonCommaSeparatedConstraintsansi2011mysqlpostgresoracle sqlserver $fEqDialect $fShowDialect $fReadDialect $fDataDialect SQLStreamsqlStreamInput unSQLStreamWithPosstartPosendPos tokenLengthtokenVal ParseErrorTokenSymbol IdentifierPrefixedVariable PositionalArg SqlString SqlNumber Whitespace LineComment BlockCommentlexSQLWithPositionslexSQL prettyError prettyToken prettyTokenstokenListWillPrintAndLex$fTraversableStreamSQLStream$fVisualStreamSQLStream$fStreamSQLStream $fEqWithPos $fOrdWithPos $fShowWithPos $fEqToken $fShowToken $fOrdToken MakeSelectmsSetQuantifier msSelectListmsFrommsWhere msGroupBymsHaving msOrderBymsOffset msFetchFirstCommentPrivilegeActionPrivAll PrivSelect PrivDelete PrivInsert PrivUpdatePrivReferences PrivUsage PrivTrigger PrivExecutePrivilegeObject PrivTable PrivDomainPrivType PrivSequence PrivFunctionGrantOptionForNoGrantOptionForAdminOptionForNoAdminOptionFor GrantOptionWithGrantOptionWithoutGrantOption AdminOptionWithAdminOptionWithoutAdminOptionAlterDomainAction ADSetDefault ADDropDefaultADAddConstraintADDropConstraint CheckOptionDefaultCheckOptionCascadedCheckOptionLocalCheckOptionSequenceGeneratorOption SGODataType SGOStartWith SGORestartSGOIncrementBy SGOMaxValue SGONoMaxValue SGOMinValue SGONoMinValueSGOCycle SGONoCycle IdentityWhenGeneratedAlwaysGeneratedByDefault DefaultClauseIdentityColumnSpecGenerationClauseAlterTableAction AddColumnDefAlterColumnSetDefaultAlterColumnDropDefaultAlterColumnSetNotNullAlterColumnDropNotNullAlterColumnSetDataType DropColumnAddTableConstraintDefDropTableConstraintDefReferentialActionDefaultReferentialAction RefCascade RefSetNull RefSetDefault RefRestrict RefNoActionReferenceMatchDefaultReferenceMatch MatchFull MatchPartial MatchSimpleTableConstraintTableUniqueConstraintTablePrimaryKeyConstraintTableReferencesConstraintTableCheckConstraint ColConstraintColNullableConstraintColNotNullConstraintColUniqueConstraintColPrimaryKeyConstraintColReferencesConstraintColCheckConstraintAutoincrementClauseColConstraintDef ColumnDef TableElementTableColumnDefTableConstraintDef SetClauseSet SetMultiple InsertSource InsertQueryDefaultInsertValuesIdentityRestartContinueIdentityRestartIdentityDefaultIdentityRestart DropBehaviourRestrictCascadeDefaultDropBehaviour Statement CreateSchema DropSchema CreateTable AlterTable DropTable CreateIndex CreateViewDropView CreateDomain AlterDomain DropDomainCreateAssertion DropAssertionCreateSequence AlterSequence DropSequenceSelectStatementDeleteTruncateInsertUpdateGrantPrivilege GrantRole CreateRoleDropRoleRevokePrivilege RevokeRoleStartTransaction SavepointReleaseSavepointCommitRollbackStatementCommentEmptyStatement JoinConditionJoinOn JoinUsingJoinTypeJInnerJLeftJRightJFullJCrossAliasTableRefTRSimpleTRJoinTRParensTRAlias TRQueryExpr TRFunction TRLateralTROdbc GroupingExprGroupingParensCubeRollup GroupingSets SimpleGroup Corresponding RespectivelySetOperatorNameUnionExcept Intersect Direction DirDefaultAscDesc SetQuantifier SQDefaultDistinctAll QueryExprSelectQueryExprSetOpWithValuesTable QECommentqeSetQuantifier qeSelectListqeFromqeWhere qeGroupByqeHaving qeOrderByqeOffset qeFetchFirstqe0qeCombOpqeCorrespondingqe1qeWithRecursiveqeViewsqeQueryExpressionOdbcLiteralTypeOLDateOLTime OLTimestampFramePosUnboundedPreceding PrecedingCurrent FollowingUnboundedFollowing FrameRows FrameRangeFrame FrameFrom FrameBetween NullsOrderNullsOrderDefault NullsFirst NullsLastSortSpecCompPredQuantifierCPAnyCPSomeCPAllSubQueryExprTypeSqExistsSqUniqueSqSq InPredValueInList InQueryExpr PrecUnitsPrecCharacters PrecOctetsPrecMultiplierPrecKPrecMPrecGPrecTPrecPSignPlusMinusIntervalTypeFieldItfTypeName PrecTypeNamePrecScaleTypeNamePrecLengthTypeName CharTypeName TimeTypeName RowTypeNameIntervalTypeName ArrayTypeNameMultisetTypeNameName ScalarExprNumLit StringLit IntervalLitTypedLitIdenStar Parameter HostParameterBinOpPrefixOp PostfixOp SpecialOpApp AggregateAppAggregateAppGroup WindowApp SpecialOpKCastConvertCaseParensIn SubQueryExprQuantifiedComparisonMatchArray ArrayCtorCollate MultisetBinOp MultisetCtorMultisetQueryCtor NextValueFor VEComment OdbcLiteralOdbcFuncilSign ilLiteralilFromilToaggName aggDistinctaggArgs aggOrderBy aggFilteraggGroupwnNamewnArgs wnPartition wnOrderBywnFramecaseTest caseWhenscaseElse makeSelect toQueryExpr $fEqStatement$fShowStatement$fReadStatement$fDataStatement$fEqInsertSource$fShowInsertSource$fReadInsertSource$fDataInsertSource $fEqSetClause$fShowSetClause$fReadSetClause$fDataSetClause$fEqTableElement$fShowTableElement$fReadTableElement$fDataTableElement$fEqAlterTableAction$fShowAlterTableAction$fReadAlterTableAction$fDataAlterTableAction $fEqColumnDef$fShowColumnDef$fReadColumnDef$fDataColumnDef$fEqColConstraintDef$fShowColConstraintDef$fReadColConstraintDef$fDataColConstraintDef$fEqColConstraint$fShowColConstraint$fReadColConstraint$fDataColConstraint$fEqTableConstraint$fShowTableConstraint$fReadTableConstraint$fDataTableConstraint$fEqDefaultClause$fShowDefaultClause$fReadDefaultClause$fDataDefaultClause$fEqAlterDomainAction$fShowAlterDomainAction$fReadAlterDomainAction$fDataAlterDomainAction$fEqScalarExpr$fShowScalarExpr$fReadScalarExpr$fDataScalarExpr $fEqQueryExpr$fShowQueryExpr$fReadQueryExpr$fDataQueryExpr $fEqTableRef$fShowTableRef$fReadTableRef$fDataTableRef$fEqJoinCondition$fShowJoinCondition$fReadJoinCondition$fDataJoinCondition$fEqGroupingExpr$fShowGroupingExpr$fReadGroupingExpr$fDataGroupingExpr $fEqSortSpec$fShowSortSpec$fReadSortSpec$fDataSortSpec $fEqFrame $fShowFrame $fReadFrame $fDataFrame $fEqFramePos$fShowFramePos$fReadFramePos$fDataFramePos$fEqInPredValue$fShowInPredValue$fReadInPredValue$fDataInPredValue $fEqComment $fShowComment $fReadComment $fDataComment$fEqPrivilegeAction$fShowPrivilegeAction$fReadPrivilegeAction$fDataPrivilegeAction$fEqPrivilegeObject$fShowPrivilegeObject$fReadPrivilegeObject$fDataPrivilegeObject$fEqGrantOptionFor$fShowGrantOptionFor$fReadGrantOptionFor$fDataGrantOptionFor$fEqAdminOptionFor$fShowAdminOptionFor$fReadAdminOptionFor$fDataAdminOptionFor$fEqGrantOption$fShowGrantOption$fReadGrantOption$fDataGrantOption$fEqAdminOption$fShowAdminOption$fReadAdminOption$fDataAdminOption$fEqCheckOption$fShowCheckOption$fReadCheckOption$fDataCheckOption$fEqSequenceGeneratorOption$fShowSequenceGeneratorOption$fReadSequenceGeneratorOption$fDataSequenceGeneratorOption$fEqIdentityWhen$fShowIdentityWhen$fReadIdentityWhen$fDataIdentityWhen$fEqReferentialAction$fShowReferentialAction$fReadReferentialAction$fDataReferentialAction$fEqReferenceMatch$fShowReferenceMatch$fReadReferenceMatch$fDataReferenceMatch$fEqIdentityRestart$fShowIdentityRestart$fReadIdentityRestart$fDataIdentityRestart$fEqDropBehaviour$fShowDropBehaviour$fReadDropBehaviour$fDataDropBehaviour $fEqJoinType$fShowJoinType$fReadJoinType$fDataJoinType $fEqAlias $fShowAlias $fReadAlias $fDataAlias$fEqCorresponding$fShowCorresponding$fReadCorresponding$fDataCorresponding$fEqSetOperatorName$fShowSetOperatorName$fReadSetOperatorName$fDataSetOperatorName $fEqDirection$fShowDirection$fReadDirection$fDataDirection$fEqSetQuantifier$fShowSetQuantifier$fReadSetQuantifier$fDataSetQuantifier$fEqOdbcLiteralType$fShowOdbcLiteralType$fReadOdbcLiteralType$fDataOdbcLiteralType $fEqFrameRows$fShowFrameRows$fReadFrameRows$fDataFrameRows$fEqNullsOrder$fShowNullsOrder$fReadNullsOrder$fDataNullsOrder$fEqCompPredQuantifier$fShowCompPredQuantifier$fReadCompPredQuantifier$fDataCompPredQuantifier$fEqSubQueryExprType$fShowSubQueryExprType$fReadSubQueryExprType$fDataSubQueryExprType $fEqTypeName$fShowTypeName$fReadTypeName$fDataTypeName $fEqPrecUnits$fShowPrecUnits$fReadPrecUnits$fDataPrecUnits$fEqPrecMultiplier$fShowPrecMultiplier$fReadPrecMultiplier$fDataPrecMultiplier$fEqSign $fShowSign $fReadSign $fDataSign$fEqIntervalTypeField$fShowIntervalTypeField$fReadIntervalTypeField$fDataIntervalTypeField$fEqName $fShowName $fReadName $fDataNameprettyQueryExprprettyScalarExprprettyStatementprettyStatementsLexErrorparseQueryExprparseStatementparseStatementsparseScalarExprsqlToken terminator