sqruff_lib_core/dialects/
syntax.rs

1use std::iter::FromIterator;
2
3#[derive(
4    Debug,
5    PartialEq,
6    Eq,
7    Clone,
8    Copy,
9    strum_macros::IntoStaticStr,
10    strum_macros::EnumString,
11    Hash,
12    PartialOrd,
13    Ord,
14    Default,
15)]
16#[strum(serialize_all = "snake_case")]
17pub enum SyntaxKind {
18    Unparsable,
19    File,
20    ColumnReference,
21    ObjectReference,
22    Expression,
23    WildcardIdentifier,
24    Function,
25    FunctionContents,
26    HavingClause,
27    PathSegment,
28    LimitClause,
29    CubeRollupClause,
30    GroupingSetsClause,
31    GroupingExpressionList,
32    SetClause,
33    FetchClause,
34    FunctionDefinition,
35    AlterSequenceOptionsSegment,
36    RoleReference,
37    TablespaceReference,
38    ExtensionReference,
39    TagReference,
40    ColumnDefinition,
41    ColumnConstraintSegment,
42    CommentClause,
43    TableEndClause,
44    MergeMatch,
45    MergeWhenNotMatchedClause,
46    MergeInsertClause,
47    MergeUpdateClause,
48    MergeDeleteClause,
49    MergeTreeOrderByClause,
50    SetClauseList,
51    TableReference,
52    GroupbyClause,
53    FrameClause,
54    WithCompoundStatement,
55    CommonTableExpression,
56    CTEColumnList,
57    TriggerReference,
58    TableConstraint,
59    JoinOnCondition,
60    DatabaseReference,
61    CollationReference,
62    OverClause,
63    NamedWindow,
64    WindowSpecification,
65    PartitionbyClause,
66    JoinClause,
67    DropTriggerStatement,
68    SampleExpression,
69    TableExpression,
70    CreateTriggerStatement,
71    DropModelStatement,
72    DescribeStatement,
73    UseStatement,
74    ExplainStatement,
75    CreateSequenceStatement,
76    CreateSequenceOptionsSegment,
77    AlterSequenceStatement,
78    DropSequenceStatement,
79    DropCastStatement,
80    CreateFunctionStatement,
81    DropFunctionStatement,
82    CreateModelStatement,
83    CreateViewStatement,
84    DeleteStatement,
85    UpdateStatement,
86    CreateCastStatement,
87    CreateRoleStatement,
88    DropRoleStatement,
89    AlterTableStatement,
90    CreateSchemaStatement,
91    SetSchemaStatement,
92    DropSchemaStatement,
93    DropTypeStatement,
94    CreateDatabaseStatement,
95    DropDatabaseStatement,
96    FunctionParameterList,
97    CreateIndexStatement,
98    DropIndexStatement,
99    CreateTableStatement,
100    AccessStatement,
101    InsertStatement,
102    TransactionStatement,
103    DropTableStatement,
104    DropViewStatement,
105    CreateUserStatement,
106    DropUserStatement,
107    ArrayExpression,
108    LocalAlias,
109    MergeStatement,
110    IndexColumnDefinition,
111    AggregateOrderByClause,
112    FunctionName,
113    CaseExpression,
114    WhenClause,
115    ElseClause,
116    PreWhereClause,
117    WhereClause,
118    SetOperator,
119    ValuesClause,
120    EmptyStructLiteral,
121    ObjectLiteral,
122    ObjectLiteralElement,
123    TimeZoneGrammar,
124    BracketedArguments,
125    DataType,
126    AliasExpression,
127    ArrayAccessor,
128    ArrayLiteral,
129    TypedArrayLiteral,
130    StructType,
131    StructLiteral,
132    TypedStructLiteral,
133    IntervalExpression,
134    ArrayType,
135    SizedArrayType,
136    SelectStatement,
137    OverlapsClause,
138    SelectClause,
139    Statement,
140    WithNoSchemaBindingClause,
141    WithDataClause,
142    SetExpression,
143    FromClause,
144    EmptyStructLiteralBrackets,
145    WildcardExpression,
146    OrderbyClause,
147    TruncateStatement,
148    FromExpression,
149    FromExpressionElement,
150    SelectClauseModifier,
151    NamedWindowExpression,
152    SelectClauseElement,
153    QualifyClause,
154    MultiStatementSegment,
155    AssertStatement,
156    ForInStatements,
157    ForInStatement,
158    RepeatStatements,
159    RepeatStatement,
160    IfStatements,
161    IfStatement,
162    LoopStatements,
163    LoopStatement,
164    WhileStatements,
165    WhileStatement,
166    DatePartWeek,
167    SelectExceptClause,
168    SelectReplaceClause,
169    StructTypeSchema,
170    Tuple,
171    NamedArgument,
172    DeclareSegment,
173    SetSegment,
174    PartitionBySegment,
175    ClusterBySegment,
176    OptionsSegment,
177    CreateExternalTableStatement,
178    AlterViewStatement,
179    CreateMaterializedViewStatement,
180    AlterMaterializedViewSetOptionsStatement,
181    DropMaterializedViewStatement,
182    ParameterizedExpression,
183    PivotForClause,
184    FromPivotExpression,
185    UnpivotClause,
186    FromUnpivotExpression,
187    NotMatchedByTargetClause,
188    MergeWhenMatchedClause,
189    ProcedureName,
190    ExportStatement,
191    ProcedureParameterList,
192    ProcedureStatements,
193    CallStatement,
194    ReturnStatement,
195    BreakStatement,
196    LeaveStatement,
197    ContinueStatement,
198    RaiseStatement,
199    PsqlVariable,
200    ComparisonOperator,
201    DatetimeTypeIdentifier,
202    DatetimeLiteral,
203    IndexAccessMethod,
204    OperatorClassReference,
205    DefinitionParameter,
206    DefinitionParameters,
207    RelationOption,
208    RelationOptions,
209    AlterFunctionActionSegment,
210    AlterProcedureActionSegment,
211    AlterProcedureStatement,
212    DropProcedureStatement,
213    WktGeometryType,
214    IntoClause,
215    ForClause,
216    AlterRoleStatement,
217    ExplainOption,
218    CreateTableAsStatement,
219    AlterPublicationStatement,
220    CreatePublicationStatement,
221    PublicationObjects,
222    PublicationTable,
223    PublicationReference,
224    DropExtensionStatement,
225    CreateExtensionStatement,
226    VersionIdentifier,
227    AlterTableActionSegment,
228    DropPublicationStatement,
229    AlterMaterializedViewStatement,
230    AlterMaterializedViewActionSegment,
231    RefreshMaterializedViewStatement,
232    WithCheckOption,
233    AlterPolicyStatement,
234    AlterDatabaseStatement,
235    VacuumStatement,
236    LikeOptionSegment,
237    PartitionBoundSpec,
238    IndexParameters,
239    ReferentialActionSegment,
240    IndexElement,
241    ExclusionConstraintElement,
242    AlterDefaultPrivilegesStatement,
243    AlterDefaultPrivilegesObjectPrivilege,
244    AlterDefaultPrivilegesSchemaObject,
245    AlterDefaultPrivilegesToFromRoles,
246    AlterDefaultPrivilegesGrant,
247    DropOwnedStatement,
248    ReassignOwnedStatement,
249    IndexElementOptions,
250    AlterDefaultPrivilegesRevoke,
251    AlterIndexStatement,
252    ReindexStatementSegment,
253    AnalyzeStatement,
254    AlterTrigger,
255    OperationClassReference,
256    ConflictAction,
257    ConflictTarget,
258    SetStatement,
259    CreatePolicyStatement,
260    CreateDomainStatement,
261    AlterDomainStatement,
262    DropDomainStatement,
263    DropPolicyStatement,
264    LoadStatement,
265    ResetStatement,
266    ListenStatement,
267    NotifyStatement,
268    UnlistenStatement,
269    ClusterStatement,
270    LanguageClause,
271    DoStatement,
272    CreateUserMappingStatement,
273    ImportForeignSchemaStatement,
274    CreateServerStatement,
275    CreateCollationStatement,
276    AlterTypeStatement,
277    CreateTypeStatement,
278    LockTableStatement,
279    CopyStatement,
280    DiscardStatement,
281    AlterSchemaStatement,
282    ServerReference,
283    ArrayJoinClause,
284    TableEngineFunction,
285    OnClusterClause,
286    Engine,
287    EngineFunction,
288    DatabaseEngine,
289    ColumnTtlSegment,
290    TableTtlSegment,
291    DropDictionaryStatement,
292    DropQuotaStatement,
293    DropSettingProfileStatement,
294    SystemMergesSegment,
295    SystemTtlMergesSegment,
296    SystemMovesSegment,
297    SystemReplicaSegment,
298    SystemFilesystemSegment,
299    SystemReplicatedSegment,
300    SystemReplicationSegment,
301    SystemFetchesSegment,
302    SystemDistributedSegment,
303    SystemModelSegment,
304    SystemFileSegment,
305    SystemUnfreezeSegment,
306    SystemStatement,
307    ConnectbyClause,
308    CallSegment,
309    WithingroupClause,
310    PatternExpression,
311    MatchRecognizeClause,
312    ChangesClause,
313    MatchConditionClause,
314    FromAtExpression,
315    FromBeforeExpression,
316    SnowflakeKeywordExpression,
317    SemiStructuredExpression,
318    SelectExcludeClause,
319    SelectRenameClause,
320    AlterTableTableColumnAction,
321    AlterTableClusteringAction,
322    AlterTableConstraintAction,
323    AlterWarehouseStatement,
324    AlterShareStatement,
325    AlterStorageIntegrationStatement,
326    AlterExternalTableStatement,
327    CommentEqualsClause,
328    TagBracketedEquals,
329    TagEquals,
330    CreateCloneStatement,
331    CreateDatabaseFromShareStatement,
332    CreateProcedureStatement,
333    ScriptingBlockStatement,
334    ScriptingLetStatement,
335    AlterFunctionStatement,
336    CreateExternalFunctionStatement,
337    WarehouseObjectProperties,
338    ConstraintPropertiesSegment,
339    CopyOptions,
340    SchemaObjectProperties,
341    CreateTaskStatement,
342    SnowflakeTaskExpressionSegment,
343    CreateStatement,
344    CreateFileFormatSegment,
345    AlterFileFormatSegment,
346    CsvFileFormatTypeParameters,
347    JsonFileFormatTypeParameters,
348    AvroFileFormatTypeParameters,
349    OrcFileFormatTypeParameters,
350    ParquetFileFormatTypeParameters,
351    XmlFileFormatTypeParameters,
352    AlterPipeSegment,
353    FileFormatSegment,
354    FormatTypeOptions,
355    CopyIntoLocationStatement,
356    CopyIntoTableStatement,
357    StorageLocation,
358    StageParameters,
359    S3ExternalStageParameters,
360    GcsExternalStageParameters,
361    AzureBlobStorageExternalStageParameters,
362    CreateStageStatement,
363    AlterStageStatement,
364    CreateStreamStatement,
365    AlterStreamStatement,
366    ShowStatement,
367    AlterUserStatement,
368    AlterSessionStatement,
369    AlterSessionSetStatement,
370    AlterSessionUnsetClause,
371    AlterTaskStatement,
372    AlterTaskSpecialSetClause,
373    AlterTaskSetClause,
374    AlterTaskUnsetClause,
375    ExecuteTaskClause,
376    UndropStatement,
377    CommentStatement,
378    DropExternalTableStatement,
379    ListStatement,
380    GetStatement,
381    PutStatement,
382    RemoveStatement,
383    CastExpression,
384    DropObjectStatement,
385    UnsetStatement,
386    SqlConfOption,
387    BinaryOperator,
388    PrimitiveType,
389    CreateWidgetStatement,
390    ReplaceTableStatement,
391    RemoveWidgetStatement,
392    UseDatabaseStatement,
393    InsertOverwriteDirectoryStatement,
394    InsertOverwriteDirectoryHiveFmtStatement,
395    LoadDataStatement,
396    ClusterByClause,
397    DistributeByClause,
398    HintFunction,
399    SelectHint,
400    WithCubeRollupClause,
401    SortByClause,
402    LateralViewClause,
403    PivotClause,
404    TransformClause,
405    AddFileStatement,
406    AddJarStatement,
407    AnalyzeTableStatement,
408    CacheTable,
409    ClearCache,
410    ListFileStatement,
411    ListJarStatement,
412    RefreshStatement,
413    UncacheTable,
414    FileReference,
415    PropertyNameIdentifier,
416    GeneratedColumnDefinition,
417    IntervalLiteral,
418    DescribeHistoryStatement,
419    DescribeDetailStatement,
420    GenerateManifestFileStatement,
421    ConvertToDeltaStatement,
422    RestoreTableStatement,
423    ConstraintStatement,
424    ApplyChangesIntoStatement,
425    UsingClause,
426    DataSourceFormat,
427    IcebergTransformation,
428    MsckRepairTableStatement,
429    RowFormatClause,
430    SkewedByClause,
431    Bracketed,
432    NumericLiteral,
433    Keyword,
434    EndOfFile,
435    Whitespace,
436    Newline,
437    NakedIdentifier,
438    Unlexable,
439    StartBracket,
440    EndBracket,
441    InlineComment,
442    Identifier,
443    Raw,
444    QuotedIdentifier,
445    Star,
446    Dot,
447    Comma,
448    Comment,
449    EmitsSegment,
450    Literal,
451    BareFunction,
452    NullLiteral,
453    BooleanLiteral,
454    BlockComment,
455    QuotedLiteral,
456    DoubleDivide,
457    Meta,
458    #[default]
459    Colon,
460    StatementTerminator,
461    StartSquareBracket,
462    EndSquareBracket,
463    StartCurlyBracket,
464    Tilde,
465    CastingOperator,
466    RawComparisonOperator,
467    DatePart,
468    Pipe,
469    SignIndicator,
470    LikeOperator,
471    Word,
472    DoubleQuote,
473    SingleQuote,
474    Dash,
475    Semicolon,
476    BackQuote,
477    DollarQuote,
478    Not,
479    Ampersand,
480    Question,
481    Percent,
482    Divide,
483    Minus,
484    Plus,
485    Caret,
486    VerticalBar,
487    EndCurlyBracket,
488    FunctionNameIdentifier,
489    Dedent,
490    Indent,
491    Implicit,
492    AtSignLiteral,
493    TsqlVariable,
494    QuestionMark,
495    RightArrow,
496    UdfBody,
497    StartAngleBracket,
498    EndAngleBracket,
499    Lambda,
500    NakedIdentifierAll,
501    ProcedureNameIdentifier,
502    Parameter,
503    DateConstructorLiteral,
504    ProcedureOption,
505    ExportOption,
506    PropertiesNakedIdentifier,
507    Symbol,
508    DataTypeIdentifier,
509    Placeholder,
510    ExecuteScriptStatement,
511    AssignmentOperator,
512    Batch,
513    PivotColumnReference,
514    IntoTableClause,
515    PasswordAuth,
516    ExecuteAsClause,
517    ExecuteImmediateClause,
518    UnicodeSingleQuote,
519    EscapedSingleQuote,
520    UnicodeDoubleQuote,
521    JsonOperator,
522    At,
523    BitStringLiteral,
524    DollarNumericLiteral,
525    WidgetNameIdentifier,
526    FileKeyword,
527    SemiStructuredElement,
528    BytesDoubleQuote,
529    BytesSingleQuote,
530    FileFormat,
531    FileType,
532    StartHint,
533    EndHint,
534    FunctionAssigner,
535    UnquotedFilePath,
536    Dollar,
537    SystemFunctionName,
538    IntegerLiteral,
539    StageEncryptionOption,
540    BucketPath,
541    QuotedStar,
542    StagePath,
543    FileLiteral,
544    BytesQuotedLiteral,
545    SignedQuotedLiteral,
546    ParameterAssigner,
547    ColumnSelector,
548    DollarLiteral,
549    ExcludeBracketClose,
550    WalrusOperator,
551    WarehouseSize,
552    Variable,
553    ExcludeBracketOpen,
554    SymlinkFormatManifest,
555    StartExcludeBracket,
556    CompressionType,
557    CopyOnErrorOption,
558    ColumnIndexIdentifierSegment,
559    ScalingPolicy,
560    ValidationModeOption,
561    EndExcludeBracket,
562    IdentifierList,
563    TemplateLoop,
564    ColonDelimiter,
565    SqlcmdOperator,
566    Slice,
567    TableEndClauseSegment,
568    PragmaStatement,
569    PragmaReference,
570    Slash,
571    DataFormatSegment,
572    AuthorizationSegment,
573    ColumnAttributeSegment,
574    ShowModelStatement,
575    CreateExternalSchemaStatement,
576    CreateLibraryStatement,
577    UnloadStatement,
578    DeclareStatement,
579    FetchStatement,
580    CloseStatement,
581    CreateDatashareStatement,
582    DescDatashareStatement,
583    DropDatashareStatement,
584    ShowDatasharesStatement,
585    GrantDatashareStatement,
586    CreateRlsPolicyStatement,
587    ManageRlsPolicyStatement,
588    DropRlsPolicyStatement,
589    AnalyzeCompressionStatement,
590    PartitionedBySegment,
591    RowFormatDelimitedSegment,
592    ObjectUnpivoting,
593    ArrayUnnesting,
594    AlterGroup,
595    CreateGroup,
596    ListaggOverflowClauseSegment,
597    UnorderedSelectStatementSegment,
598    MapType,
599    MapTypeSchema,
600    PrepareStatement,
601    ExecuteStatement,
602    RenameTableStatement,
603    ActionParameter,
604    AggregateClause,
605    AggregateOrderBy,
606    AliasOperator,
607    AllowConnections,
608    AlterAccountStatement,
609    AlterAggregateStatement,
610    AlterBiCapacityStatement,
611    AlterCapacityStatement,
612    AlterCatalogStatement,
613    AlterDynamicTableStatement,
614    AlterEventStatement,
615    AlterExtensionStatement,
616    AlterExternalVolumeStatement,
617    AlterForeignTableActionSegment,
618    AlterForeignTableStatement,
619    AlterMaskingPolicy,
620    AlterMasterKeyStatement,
621    AlterNetworkPolicyStatement,
622    AlterOptionSegment,
623    AlterOrganizationStatement,
624    AlterPartitionFunctionStatement,
625    AlterPartitionSchemeStatement,
626    AlterPasswordPolicyStatement,
627    AlterProjectStatement,
628    AlterReservationStatement,
629    AlterResourceMonitorStatement,
630    AlterRowAccessPolicyStatement,
631    AlterSecurityPolicyStatement,
632    AlterStatisticsStatement,
633    AlterStreamlitStatement,
634    AlterSubscription,
635    AlterTableSwitchStatement,
636    AlterTagStatement,
637    AlterTextSearchConfigurationStatement,
638    AlterVolumeStatement,
639    ArnCatalogSchemaSegment,
640    ArrayTypeSchema,
641    AtSign,
642    AtomicBeginEndBlock,
643    Atsign,
644    AutoOption,
645    BackupStorageRedundancy,
646    BeginEndBlock,
647    BeginStatement,
648    BinaryLiteral,
649    BindVariable,
650    BitValueLiteral,
651    BracketedIndexColumnListGrammar,
652    BulkInsertStatement,
653    BulkInsertWithSegment,
654    ByteLengthLiteral,
655    CallOperator,
656    CatalogReference,
657    CharacteristicStatement,
658    CheckConstraintGrammar,
659    CheckTableStatement,
660    ChecksumTableStatement,
661    CloseCursorStatement,
662    ClusterbyClause,
663    Code,
664    CollationClause,
665    ColonLiteral,
666    ColonPrefix,
667    ColumnPathOperator,
668    ColumnPropertiesSegment,
669    ColumnTypeReference,
670    ColumnsExpression,
671    Command,
672    CompatibilityLevel,
673    CompositeValueExpansion,
674    ComputedColumnDefinition,
675    ConflictClause,
676    ConnectionConstraintGrammar,
677    ConnectionLimitSegment,
678    CopyFilesIntoLocationStatement,
679    CreateAggregateStatement,
680    CreateAssignmentStatement,
681    CreateAuthenticationPolicySegment,
682    CreateCapacityStatement,
683    CreateCatalogStatement,
684    CreateColumnstoreIndexStatement,
685    CreateCortexSearchServiceStatement,
686    CreateDatabaseRoleStatement,
687    CreateDatabaseScopedCredentialStatement,
688    CreateDatabaseWithOptions,
689    CreateEventStatement,
690    CreateEventTableStatement,
691    CreateExternalDataSourceStatement,
692    CreateExternalFileFormat,
693    CreateExternalVolumeStatement,
694    CreateForeignDataWrapper,
695    CreateForeignTableStatement,
696    CreateFulltextCatalogStatement,
697    CreateFulltextIndexStatement,
698    CreateLoginStatement,
699    CreateMasterKeyStatement,
700    CreateMaterializedViewAsReplicaOfStatement,
701    CreateOperatorStatement,
702    CreateOptionSegment,
703    CreatePartitionFunctionStatement,
704    CreatePartitionSchemeStatement,
705    CreatePasswordPolicyStatement,
706    CreateReservationStatement,
707    CreateResourceMonitorStatement,
708    CreateRowAccessPolicyStatement,
709    CreateSearchIndexStatement,
710    CreateSecurityPolicyStatement,
711    CreateServerRoleStatement,
712    CreateSnapshotTableStatement,
713    CreateSqlFunctionStatement,
714    CreateStatisticsStatement,
715    CreateStreamlitStatement,
716    CreateSubscription,
717    CreateSynonymStatement,
718    CreateTableAsSelectStatement,
719    CreateTableFunctionStatement,
720    CreateTableGraphStatement,
721    CreateTableUsingStatement,
722    CreateTextSearchConfigurationStatement,
723    CreateTrigger,
724    CreateVectorIndexStatement,
725    CreateVirtualTableStatement,
726    CreateVolumeStatement,
727    CursorDefinition,
728    CursorFetchSegment,
729    CursorOpenCloseSegment,
730    DataGovernancePolicyTagActionSegment,
731    DatabaseRoleReference,
732    DateFormat,
733    DeallocateCursorStatement,
734    DeallocateSegment,
735    DeallocateStatement,
736    DeclareOrReplaceVariableStatement,
737    DefaultCollate,
738    DefinerSegment,
739    DeleteTargetTable,
740    DelimiterStatement,
741    DisableTrigger,
742    DistributebyClause,
743    DoubleAmpersand,
744    DoubleAtSignLiteral,
745    DoubleVerticalBar,
746    DropAggregateStatement,
747    DropAssignmentStatement,
748    DropCapacityStatement,
749    DropCatalogStatement,
750    DropCollationStatement,
751    DropColumnClause,
752    DropDynamicTableSegment,
753    DropEventStatement,
754    DropExternalVolumeStatement,
755    DropForeignTableStatement,
756    DropIcebergTableStatement,
757    DropMasterKeyStatement,
758    DropModelstatement,
759    DropPasswordPolicyStatement,
760    DropReservationStatement,
761    DropResourceMonitorStatement,
762    DropRowAccessPolicyStatement,
763    DropSearchIndexStatement,
764    DropSecurityPolicy,
765    DropStatement,
766    DropStatisticsStatement,
767    DropSubscription,
768    DropSynonymStatement,
769    DropTableFunctionStatement,
770    DropTextSearchConfigurationStatement,
771    DropTrigger,
772    DropVectorIndexStatement,
773    DropVolumeStatement,
774    DynamicTableLagIntervalSegment,
775    DynamicTableOptions,
776    Edition,
777    EncryptedWithGrammar,
778    ExceptionBlockStatement,
779    ExceptionCode,
780    ExecuteArrow,
781    ExecuteImmediate,
782    ExecuteOption,
783    ExecuteSegment,
784    ExtendClause,
785    ExternalAccessIntegrationEquals,
786    ExternalFileDelimitedTextClause,
787    ExternalFileDelimitedTextFormatOptionsClause,
788    ExternalFileDeltaClause,
789    ExternalFileJsonClause,
790    ExternalFileOrcClause,
791    ExternalFileParquetClause,
792    ExternalFileRcClause,
793    ExternalLocation,
794    ExternalVolumeReference,
795    FatRightArrow,
796    FetchCursorStatement,
797    FileCompression,
798    FileEncoding,
799    FileSpec,
800    FileSpecFileGrowth,
801    FileSpecFileName,
802    FileSpecMaxSize,
803    FileSpecNewName,
804    FileSpecSize,
805    FileSpecWithoutBracket,
806    FilegroupClause,
807    FilegroupName,
808    FilestreamOnOptionStatement,
809    FlushStatement,
810    ForSystemTimeAsOfSegment,
811    FormatClause,
812    FromDatashareClause,
813    FromIntegrationClause,
814    FullTextSearchOperator,
815    FunctionOptionSegment,
816    FunctionParameterListWithComments,
817    GetDiagnosticsSegment,
818    GlobOperator,
819    GoStatement,
820    GotoStatement,
821    GrantToSegment,
822    GraphTableConstraint,
823    GroupAndOrderbyClause,
824    HashIdentifier,
825    HashPrefix,
826    HelpStatement,
827    HexadecimalLiteral,
828    IamRoleClause,
829    IcebergTableOptions,
830    IdentifierClauseSegment,
831    IdentityGrammar,
832    IfClause,
833    IfThenStatement,
834    IndexHintClause,
835    IndexOption,
836    IndexReference,
837    IndexType,
838    InitializeType,
839    InlineDollarSign,
840    InlinePathOperator,
841    InsertRowAlias,
842    IntoOutfileClause,
843    IsolationLevelClause,
844    IterateStatement,
845    JsonPath,
846    LabelSegment,
847    LambdaArrow,
848    LambdaFunction,
849    LeadingDot,
850    LimitClauseComponent,
851    ListComprehension,
852    ListaggOverflowClause,
853    LocalAliasSegment,
854    LogLevelEquals,
855    LogicalFileName,
856    LoginUserSegment,
857    MagicCellSegment,
858    MagicLine,
859    MagicSingleLine,
860    MagicStart,
861    MaskStatement,
862    MasterKeyEncryptionOption,
863    MatchCondition,
864    MaxDuration,
865    MaxLiteral,
866    MetaCommand,
867    MetaCommandQueryBuffer,
868    MetaCommandStatement,
869    MlTableExpression,
870    MsckTableStatement,
871    NotOperator,
872    NotebookStart,
873    ObevoAnnotation,
874    OffsetClause,
875    OnPartitionOrFilegroupStatement,
876    OnPartitionsClause,
877    OpenCursorStatement,
878    OpenSymmetricKeyStatement,
879    OpenjsonSegment,
880    OpenjsonWithClause,
881    OpenquerySegment,
882    OpenrowsetSegment,
883    OpenrowsetWithClause,
884    OpenxmlSegment,
885    Operator,
886    OptimizeTableStatement,
887    Option,
888    OptionClause,
889    OptionIndicator,
890    OutputClause,
891    ParameterDirection,
892    PartitionClause,
893    PartitionSchemeClause,
894    PartitionSchemeName,
895    PasswordPolicyOptions,
896    PasswordPolicyReference,
897    PeriodSegment,
898    PgTrgmOperator,
899    PgvectorOperator,
900    PipeOperator,
901    PipeOperatorClause,
902    PipeStatement,
903    PivotOperator,
904    PostTableExpression,
905    PostgisOperator,
906    PrepareSegment,
907    PrewhereClause,
908    PrintStatement,
909    ProcedureStatement,
910    PurgeBinaryLogsStatement,
911    QualifiedOperator,
912    QueryHintSegment,
913    QuestionLiteral,
914    RaiserrorStatement,
915    RawDoubleQuote,
916    RawQuotedLiteral,
917    RawSingleQuote,
918    ReconfigureStatement,
919    ReferencesConstraintGrammar,
920    RelationalIndexOptions,
921    RenameColumnClause,
922    RenameStatement,
923    RepairTableStatement,
924    ReplaceStatement,
925    ResetMasterStatement,
926    ResetSessionAuthorizationStatement,
927    ResignalSegment,
928    ResourceConstraint,
929    ResourceMonitorOptions,
930    ReturnSegment,
931    ReturningClause,
932    SchemaReference,
933    ScriptingDeclareStatement,
934    ScriptingIfStatement,
935    ScriptingRaiseStatement,
936    SearchOptimizationAction,
937    SecurityLabelStatement,
938    SelectVariableAssignment,
939    SequenceNextValue,
940    SequenceReference,
941    SerdeMethod,
942    ServiceObjective,
943    SetConstraintStatement,
944    SetContextInfoStatement,
945    SetLanguageStatement,
946    SetLocalVariableSegment,
947    SetNamesStatement,
948    SetOperatorClause,
949    SetSessionAuthorizationStatement,
950    SetSessionStatement,
951    SetTimezoneStatement,
952    SetTransactionStatement,
953    SetVariableStatement,
954    SettingsClause,
955    SimplifiedPivot,
956    SimplifiedUnpivot,
957    SingleQuoteWithN,
958    SizeLiteral,
959    SortbyClause,
960    SqlcmdCommandSegment,
961    SquareQuote,
962    StatisticsReference,
963    StoringSegment,
964    SubscriptionReference,
965    SynonymReference,
966    SystemVariable,
967    TableClausesSegment,
968    TableClusterByClause,
969    TableColumnCommentAction,
970    TableDistributionClause,
971    TableDistributionIndexClause,
972    TableIndexClause,
973    TableIndexSegment,
974    TableLocationClause,
975    TableOptionStatement,
976    TableSpecificationSegment,
977    TagStatement,
978    TemporalQuery,
979    TextimageOnOptionStatement,
980    ThrowStatement,
981    TraceLevelEquals,
982    TruncateTable,
983    TryCatch,
984    TupleTypeSchema,
985    UndropSchemaStatement,
986    UnpivotMultiColumn,
987    UnpivotOperator,
988    UnpivotSingleColumn,
989    UnquotedRelativeSqlFilePath,
990    UpdateStatisticsStatement,
991    UpsertClause,
992    UpsertClauseList,
993    UseCatalogStatement,
994    VolumeReference,
995    WaitforStatement,
996    WildcardExclude,
997    WildcardPatternMatching,
998    WildcardRename,
999    WildcardReplace,
1000    WithCheckOptions,
1001    WithFill,
1002    WithRollupClause,
1003    WithinGroupClause,
1004    WithordinalityClause,
1005}
1006
1007impl SyntaxKind {
1008    pub fn indent_val(self) -> i8 {
1009        match self {
1010            SyntaxKind::Indent | SyntaxKind::Implicit => 1,
1011            SyntaxKind::Dedent => -1,
1012            _ => 0,
1013        }
1014    }
1015}
1016
1017impl SyntaxKind {
1018    pub fn as_str(&self) -> &'static str {
1019        self.into()
1020    }
1021}
1022
1023#[derive(Clone, PartialEq, Eq, Default)]
1024pub struct SyntaxSet([u64; 16]);
1025
1026impl std::fmt::Debug for SyntaxSet {
1027    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1028        f.debug_list().entries(self.iter()).finish()
1029    }
1030}
1031
1032impl SyntaxSet {
1033    pub const EMPTY: SyntaxSet = Self([0; 16]);
1034    const SLICE_BITS: u16 = u64::BITS as u16;
1035
1036    pub const fn new(kinds: &[SyntaxKind]) -> Self {
1037        let mut set = SyntaxSet::EMPTY;
1038
1039        let mut index = 0;
1040        while index < kinds.len() {
1041            set = set.union(&Self::single(kinds[index]));
1042            index += 1;
1043        }
1044
1045        set
1046    }
1047
1048    pub const fn single(kind: SyntaxKind) -> Self {
1049        let kind = kind as u16;
1050
1051        let index = (kind / Self::SLICE_BITS) as usize;
1052
1053        debug_assert!(
1054            index < Self::EMPTY.0.len(),
1055            "Index out of bounds. Increase the size of the bitset array."
1056        );
1057
1058        let shift = kind % Self::SLICE_BITS;
1059        let mask = 1 << shift;
1060
1061        let mut bits = Self::EMPTY.0;
1062        bits[index] = mask;
1063
1064        Self(bits)
1065    }
1066
1067    pub fn is_empty(&self) -> bool {
1068        self == &SyntaxSet::EMPTY
1069    }
1070
1071    pub fn insert(&mut self, value: SyntaxKind) {
1072        let set = std::mem::take(self);
1073        *self = set.union(&SyntaxSet::single(value));
1074    }
1075
1076    pub const fn intersection(mut self, other: &Self) -> Self {
1077        let mut index = 0;
1078
1079        while index < self.0.len() {
1080            self.0[index] &= other.0[index];
1081            index += 1;
1082        }
1083
1084        self
1085    }
1086
1087    pub const fn union(mut self, other: &Self) -> Self {
1088        let mut i = 0;
1089
1090        while i < self.0.len() {
1091            self.0[i] |= other.0[i];
1092            i += 1;
1093        }
1094
1095        self
1096    }
1097
1098    pub const fn intersects(&self, other: &Self) -> bool {
1099        let mut i = 0;
1100
1101        while i < self.0.len() {
1102            if self.0[i] & other.0[i] != 0 {
1103                return true;
1104            }
1105            i += 1;
1106        }
1107
1108        false
1109    }
1110
1111    pub const fn contains(&self, kind: SyntaxKind) -> bool {
1112        let kind = kind as u16;
1113        let index = kind as usize / Self::SLICE_BITS as usize;
1114        let shift = kind % Self::SLICE_BITS;
1115        let mask = 1 << shift;
1116
1117        self.0[index] & mask != 0
1118    }
1119
1120    pub const fn len(&self) -> usize {
1121        let mut len: u32 = 0;
1122
1123        let mut index = 0;
1124        while index < self.0.len() {
1125            len += self.0[index].count_ones();
1126            index += 1;
1127        }
1128
1129        len as usize
1130    }
1131
1132    pub fn iter(&self) -> SyntaxSetIter {
1133        SyntaxSetIter {
1134            set: self.clone(),
1135            index: 0,
1136        }
1137    }
1138}
1139
1140impl Extend<SyntaxKind> for SyntaxSet {
1141    fn extend<T: IntoIterator<Item = SyntaxKind>>(&mut self, iter: T) {
1142        let set = std::mem::take(self);
1143        *self = set.union(&SyntaxSet::from_iter(iter));
1144    }
1145}
1146
1147impl IntoIterator for SyntaxSet {
1148    type Item = SyntaxKind;
1149    type IntoIter = SyntaxSetIter;
1150
1151    fn into_iter(self) -> Self::IntoIter {
1152        self.iter()
1153    }
1154}
1155
1156impl IntoIterator for &SyntaxSet {
1157    type Item = SyntaxKind;
1158    type IntoIter = SyntaxSetIter;
1159
1160    fn into_iter(self) -> Self::IntoIter {
1161        self.iter()
1162    }
1163}
1164
1165impl FromIterator<SyntaxKind> for SyntaxSet {
1166    fn from_iter<T: IntoIterator<Item = SyntaxKind>>(iter: T) -> Self {
1167        let mut set = SyntaxSet::EMPTY;
1168
1169        for kind in iter {
1170            set.insert(kind);
1171        }
1172
1173        set
1174    }
1175}
1176
1177pub struct SyntaxSetIter {
1178    set: SyntaxSet,
1179    index: u16,
1180}
1181
1182impl Iterator for SyntaxSetIter {
1183    type Item = SyntaxKind;
1184
1185    fn next(&mut self) -> Option<Self::Item> {
1186        loop {
1187            let slice = self.set.0.get_mut(self.index as usize)?;
1188            let bit = slice.trailing_zeros() as u16;
1189
1190            if bit < SyntaxSet::SLICE_BITS {
1191                *slice ^= 1 << bit;
1192                let value = self.index * SyntaxSet::SLICE_BITS + bit;
1193                return Some(unsafe { std::mem::transmute::<u16, SyntaxKind>(value) });
1194            }
1195
1196            self.index += 1;
1197        }
1198    }
1199
1200    fn size_hint(&self) -> (usize, Option<usize>) {
1201        let len = self.set.len();
1202
1203        (len, Some(len))
1204    }
1205}