1use itertools::Itertools;
2use sqruff_lib_core::dialects::base::Dialect;
3use sqruff_lib_core::dialects::syntax::SyntaxKind;
4use sqruff_lib_core::helpers::{Config, ToMatchable};
5use sqruff_lib_core::parser::grammar::anyof::{AnyNumberOf, one_of, optionally_bracketed};
6use sqruff_lib_core::parser::grammar::base::{Anything, Nothing, Ref};
7use sqruff_lib_core::parser::grammar::conditional::Conditional;
8use sqruff_lib_core::parser::grammar::delimited::Delimited;
9use sqruff_lib_core::parser::grammar::sequence::{Bracketed, Sequence};
10use sqruff_lib_core::parser::lexer::{Cursor, Matcher, Pattern};
11use sqruff_lib_core::parser::matchable::{Matchable, MatchableTrait};
12use sqruff_lib_core::parser::node_matcher::NodeMatcher;
13use sqruff_lib_core::parser::parsers::{MultiStringParser, RegexParser, StringParser, TypedParser};
14use sqruff_lib_core::parser::segments::bracketed::BracketedSegmentMatcher;
15use sqruff_lib_core::parser::segments::generator::SegmentGenerator;
16use sqruff_lib_core::parser::segments::meta::MetaSegment;
17use sqruff_lib_core::parser::types::ParseMode;
18use sqruff_lib_core::vec_of_erased;
19
20use super::ansi_keywords::{ANSI_RESERVED_KEYWORDS, ANSI_UNRESERVED_KEYWORDS};
21
22pub fn dialect() -> Dialect {
23 raw_dialect().config(|this| this.expand())
24}
25
26pub fn raw_dialect() -> Dialect {
27 let mut ansi_dialect = Dialect::new();
28
29 ansi_dialect.set_lexer_matchers(lexer_matchers());
30
31 ansi_dialect.sets_mut("bare_functions").extend([
33 "current_timestamp",
34 "current_time",
35 "current_date",
36 ]);
37
38 ansi_dialect.sets_mut("datetime_units").extend([
40 "DAY",
41 "DAYOFYEAR",
42 "HOUR",
43 "MILLISECOND",
44 "MINUTE",
45 "MONTH",
46 "QUARTER",
47 "SECOND",
48 "WEEK",
49 "WEEKDAY",
50 "YEAR",
51 ]);
52
53 ansi_dialect
54 .sets_mut("date_part_function_name")
55 .extend(["DATEADD"]);
56
57 ansi_dialect
59 .update_keywords_set_from_multiline_string("unreserved_keywords", ANSI_UNRESERVED_KEYWORDS);
60 ansi_dialect
61 .update_keywords_set_from_multiline_string("reserved_keywords", ANSI_RESERVED_KEYWORDS);
62
63 ansi_dialect.update_bracket_sets(
70 "bracket_pairs",
71 vec![
72 ("round", "StartBracketSegment", "EndBracketSegment", true),
73 (
74 "square",
75 "StartSquareBracketSegment",
76 "EndSquareBracketSegment",
77 false,
78 ),
79 (
80 "curly",
81 "StartCurlyBracketSegment",
82 "EndCurlyBracketSegment",
83 false,
84 ),
85 ],
86 );
87
88 ansi_dialect.sets_mut("value_table_functions");
97
98 ansi_dialect.add([
99 (
100 "ArrayTypeSchemaSegment".into(),
101 NodeMatcher::new(SyntaxKind::ArrayType, Nothing::new().to_matchable())
102 .to_matchable()
103 .into(),
104 ),
105 (
106 "ObjectReferenceSegment".into(),
107 NodeMatcher::new(
108 SyntaxKind::ObjectReference,
109 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
110 .config(|this| {
111 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
112 this.disallow_gaps();
113 this.terminators =
114 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
115 })
116 .to_matchable(),
117 )
118 .to_matchable()
119 .into(),
120 ),
121 ]);
122
123 ansi_dialect.add([
124 (
126 "DelimiterGrammar".into(),
127 Ref::new("SemicolonSegment").to_matchable().into(),
128 ),
129 (
130 "SemicolonSegment".into(),
131 StringParser::new(";", SyntaxKind::StatementTerminator)
132 .to_matchable()
133 .into(),
134 ),
135 (
136 "ColonSegment".into(),
137 StringParser::new(":", SyntaxKind::Colon)
138 .to_matchable()
139 .into(),
140 ),
141 (
142 "SliceSegment".into(),
143 StringParser::new(":", SyntaxKind::Slice)
144 .to_matchable()
145 .into(),
146 ),
147 (
150 "ColonDelimiterSegment".into(),
151 StringParser::new(":", SyntaxKind::ColonDelimiter)
152 .to_matchable()
153 .into(),
154 ),
155 (
156 "StartBracketSegment".into(),
157 StringParser::new("(", SyntaxKind::StartBracket)
158 .to_matchable()
159 .into(),
160 ),
161 (
162 "EndBracketSegment".into(),
163 StringParser::new(")", SyntaxKind::EndBracket)
164 .to_matchable()
165 .into(),
166 ),
167 (
168 "StartSquareBracketSegment".into(),
169 StringParser::new("[", SyntaxKind::StartSquareBracket)
170 .to_matchable()
171 .into(),
172 ),
173 (
174 "EndSquareBracketSegment".into(),
175 StringParser::new("]", SyntaxKind::EndSquareBracket)
176 .to_matchable()
177 .into(),
178 ),
179 (
180 "StartCurlyBracketSegment".into(),
181 StringParser::new("{", SyntaxKind::StartCurlyBracket)
182 .to_matchable()
183 .into(),
184 ),
185 (
186 "EndCurlyBracketSegment".into(),
187 StringParser::new("}", SyntaxKind::EndCurlyBracket)
188 .to_matchable()
189 .into(),
190 ),
191 (
192 "CommaSegment".into(),
193 StringParser::new(",", SyntaxKind::Comma)
194 .to_matchable()
195 .into(),
196 ),
197 (
198 "DotSegment".into(),
199 StringParser::new(".", SyntaxKind::Dot)
200 .to_matchable()
201 .into(),
202 ),
203 (
204 "StarSegment".into(),
205 StringParser::new("*", SyntaxKind::Star)
206 .to_matchable()
207 .into(),
208 ),
209 (
210 "TildeSegment".into(),
211 StringParser::new("~", SyntaxKind::Tilde)
212 .to_matchable()
213 .into(),
214 ),
215 (
216 "ParameterSegment".into(),
217 StringParser::new("?", SyntaxKind::Parameter)
218 .to_matchable()
219 .into(),
220 ),
221 (
222 "CastOperatorSegment".into(),
223 StringParser::new("::", SyntaxKind::CastingOperator)
224 .to_matchable()
225 .into(),
226 ),
227 (
228 "PlusSegment".into(),
229 StringParser::new("+", SyntaxKind::BinaryOperator)
230 .to_matchable()
231 .into(),
232 ),
233 (
234 "MinusSegment".into(),
235 StringParser::new("-", SyntaxKind::BinaryOperator)
236 .to_matchable()
237 .into(),
238 ),
239 (
240 "PositiveSegment".into(),
241 StringParser::new("+", SyntaxKind::SignIndicator)
242 .to_matchable()
243 .into(),
244 ),
245 (
246 "NegativeSegment".into(),
247 StringParser::new("-", SyntaxKind::SignIndicator)
248 .to_matchable()
249 .into(),
250 ),
251 (
252 "DivideSegment".into(),
253 StringParser::new("/", SyntaxKind::BinaryOperator)
254 .to_matchable()
255 .into(),
256 ),
257 (
258 "MultiplySegment".into(),
259 StringParser::new("*", SyntaxKind::BinaryOperator)
260 .to_matchable()
261 .into(),
262 ),
263 (
264 "ModuloSegment".into(),
265 StringParser::new("%", SyntaxKind::BinaryOperator)
266 .to_matchable()
267 .into(),
268 ),
269 (
270 "SlashSegment".into(),
271 StringParser::new("/", SyntaxKind::Slash)
272 .to_matchable()
273 .into(),
274 ),
275 (
276 "AmpersandSegment".into(),
277 StringParser::new("&", SyntaxKind::Ampersand)
278 .to_matchable()
279 .into(),
280 ),
281 (
282 "PipeSegment".into(),
283 StringParser::new("|", SyntaxKind::Pipe)
284 .to_matchable()
285 .into(),
286 ),
287 (
288 "BitwiseXorSegment".into(),
289 StringParser::new("^", SyntaxKind::BinaryOperator)
290 .to_matchable()
291 .into(),
292 ),
293 (
294 "LikeOperatorSegment".into(),
295 TypedParser::new(SyntaxKind::LikeOperator, SyntaxKind::ComparisonOperator)
296 .to_matchable()
297 .into(),
298 ),
299 (
300 "RawNotSegment".into(),
301 StringParser::new("!", SyntaxKind::RawComparisonOperator)
302 .to_matchable()
303 .into(),
304 ),
305 (
306 "RawEqualsSegment".into(),
307 StringParser::new("=", SyntaxKind::RawComparisonOperator)
308 .to_matchable()
309 .into(),
310 ),
311 (
312 "RawGreaterThanSegment".into(),
313 StringParser::new(">", SyntaxKind::RawComparisonOperator)
314 .to_matchable()
315 .into(),
316 ),
317 (
318 "RawLessThanSegment".into(),
319 StringParser::new("<", SyntaxKind::RawComparisonOperator)
320 .to_matchable()
321 .into(),
322 ),
323 (
324 "BareFunctionSegment".into(),
326 SegmentGenerator::new(|dialect| {
327 MultiStringParser::new(
328 dialect
329 .sets("bare_functions")
330 .into_iter()
331 .map_into()
332 .collect_vec(),
333 SyntaxKind::BareFunction,
334 )
335 .to_matchable()
336 })
337 .into(),
338 ),
339 (
342 "NakedIdentifierSegment".into(),
343 SegmentGenerator::new(|dialect| {
344 let reserved_keywords = dialect.sets("reserved_keywords");
346 let pattern = reserved_keywords.iter().join("|");
347 let anti_template = format!("^({})$", pattern);
348
349 RegexParser::new("[A-Z0-9_]*[A-Z][A-Z0-9_]*", SyntaxKind::NakedIdentifier)
350 .anti_template(&anti_template)
351 .to_matchable()
352 })
353 .into(),
354 ),
355 (
356 "ParameterNameSegment".into(),
357 RegexParser::new(r#"\"?[A-Z][A-Z0-9_]*\"?"#, SyntaxKind::Parameter)
358 .to_matchable()
359 .into(),
360 ),
361 (
362 "FunctionNameIdentifierSegment".into(),
363 TypedParser::new(SyntaxKind::Word, SyntaxKind::FunctionNameIdentifier)
364 .to_matchable()
365 .into(),
366 ),
367 (
369 "DatatypeIdentifierSegment".into(),
370 SegmentGenerator::new(|_| {
371 let anti_template = format!("^({})$", "NOT");
374
375 one_of(vec![
376 RegexParser::new("[A-Z_][A-Z0-9_]*", SyntaxKind::DataTypeIdentifier)
377 .anti_template(&anti_template)
378 .to_matchable(),
379 Ref::new("SingleIdentifierGrammar")
380 .exclude(Ref::new("NakedIdentifierSegment"))
381 .to_matchable(),
382 ])
383 .to_matchable()
384 })
385 .into(),
386 ),
387 (
389 "DatetimeUnitSegment".into(),
390 SegmentGenerator::new(|dialect| {
391 MultiStringParser::new(
392 dialect
393 .sets("datetime_units")
394 .into_iter()
395 .map_into()
396 .collect_vec(),
397 SyntaxKind::DatePart,
398 )
399 .to_matchable()
400 })
401 .into(),
402 ),
403 (
404 "DatePartFunctionName".into(),
405 SegmentGenerator::new(|dialect| {
406 MultiStringParser::new(
407 dialect
408 .sets("date_part_function_name")
409 .into_iter()
410 .map_into()
411 .collect::<Vec<_>>(),
412 SyntaxKind::FunctionNameIdentifier,
413 )
414 .to_matchable()
415 })
416 .into(),
417 ),
418 (
419 "QuotedIdentifierSegment".into(),
420 TypedParser::new(SyntaxKind::DoubleQuote, SyntaxKind::QuotedIdentifier)
421 .to_matchable()
422 .into(),
423 ),
424 (
425 "QuotedLiteralSegment".into(),
426 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::QuotedLiteral)
427 .to_matchable()
428 .into(),
429 ),
430 (
431 "SingleQuotedIdentifierSegment".into(),
432 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::QuotedIdentifier)
433 .to_matchable()
434 .into(),
435 ),
436 (
437 "NumericLiteralSegment".into(),
438 TypedParser::new(SyntaxKind::NumericLiteral, SyntaxKind::NumericLiteral)
439 .to_matchable()
440 .into(),
441 ),
442 (
445 "NullLiteralSegment".into(),
446 StringParser::new("null", SyntaxKind::NullLiteral)
447 .to_matchable()
448 .into(),
449 ),
450 (
451 "NanLiteralSegment".into(),
452 StringParser::new("nan", SyntaxKind::NullLiteral)
453 .to_matchable()
454 .into(),
455 ),
456 (
457 "TrueSegment".into(),
458 StringParser::new("true", SyntaxKind::BooleanLiteral)
459 .to_matchable()
460 .into(),
461 ),
462 (
463 "FalseSegment".into(),
464 StringParser::new("false", SyntaxKind::BooleanLiteral)
465 .to_matchable()
466 .into(),
467 ),
468 (
470 "SingleIdentifierGrammar".into(),
471 one_of(vec_of_erased![
472 Ref::new("NakedIdentifierSegment"),
473 Ref::new("QuotedIdentifierSegment")
474 ])
475 .config(|this| this.terminators = vec_of_erased![Ref::new("DotSegment")])
476 .to_matchable()
477 .into(),
478 ),
479 (
480 "BooleanLiteralGrammar".into(),
481 one_of(vec_of_erased![
482 Ref::new("TrueSegment"),
483 Ref::new("FalseSegment")
484 ])
485 .to_matchable()
486 .into(),
487 ),
488 (
491 "ArithmeticBinaryOperatorGrammar".into(),
492 one_of(vec_of_erased![
493 Ref::new("PlusSegment"),
494 Ref::new("MinusSegment"),
495 Ref::new("DivideSegment"),
496 Ref::new("MultiplySegment"),
497 Ref::new("ModuloSegment"),
498 Ref::new("BitwiseAndSegment"),
499 Ref::new("BitwiseOrSegment"),
500 Ref::new("BitwiseXorSegment"),
501 Ref::new("BitwiseLShiftSegment"),
502 Ref::new("BitwiseRShiftSegment")
503 ])
504 .to_matchable()
505 .into(),
506 ),
507 (
508 "SignedSegmentGrammar".into(),
509 one_of(vec_of_erased![
510 Ref::new("PositiveSegment"),
511 Ref::new("NegativeSegment")
512 ])
513 .to_matchable()
514 .into(),
515 ),
516 (
517 "StringBinaryOperatorGrammar".into(),
518 one_of(vec![Ref::new("ConcatSegment").to_matchable()])
519 .to_matchable()
520 .into(),
521 ),
522 (
523 "BooleanBinaryOperatorGrammar".into(),
524 one_of(vec![
525 Ref::new("AndOperatorGrammar").to_matchable(),
526 Ref::new("OrOperatorGrammar").to_matchable(),
527 ])
528 .to_matchable()
529 .into(),
530 ),
531 (
532 "ComparisonOperatorGrammar".into(),
533 one_of(vec_of_erased![
534 Ref::new("EqualsSegment"),
535 Ref::new("GreaterThanSegment"),
536 Ref::new("LessThanSegment"),
537 Ref::new("GreaterThanOrEqualToSegment"),
538 Ref::new("LessThanOrEqualToSegment"),
539 Ref::new("NotEqualToSegment"),
540 Ref::new("LikeOperatorSegment"),
541 Sequence::new(vec_of_erased![
542 Ref::keyword("IS"),
543 Ref::keyword("DISTINCT"),
544 Ref::keyword("FROM")
545 ]),
546 Sequence::new(vec_of_erased![
547 Ref::keyword("IS"),
548 Ref::keyword("NOT"),
549 Ref::keyword("DISTINCT"),
550 Ref::keyword("FROM")
551 ])
552 ])
553 .to_matchable()
554 .into(),
555 ),
556 (
561 "DateTimeLiteralGrammar".into(),
562 Sequence::new(vec_of_erased![
563 one_of(vec_of_erased![
564 Ref::keyword("DATE"),
565 Ref::keyword("TIME"),
566 Ref::keyword("TIMESTAMP"),
567 Ref::keyword("INTERVAL")
568 ]),
569 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::DateConstructorLiteral,)
570 ])
571 .to_matchable()
572 .into(),
573 ),
574 (
577 "MergeIntoLiteralGrammar".into(),
578 Sequence::new(vec![
579 Ref::keyword("MERGE").to_matchable(),
580 Ref::keyword("INTO").to_matchable(),
581 ])
582 .to_matchable()
583 .into(),
584 ),
585 (
586 "LiteralGrammar".into(),
587 one_of(vec_of_erased![
588 Ref::new("QuotedLiteralSegment"),
589 Ref::new("NumericLiteralSegment"),
590 Ref::new("BooleanLiteralGrammar"),
591 Ref::new("QualifiedNumericLiteralSegment"),
592 Ref::new("NullLiteralSegment"),
595 Ref::new("DateTimeLiteralGrammar"),
596 Ref::new("ArrayLiteralSegment"),
597 Ref::new("TypedArrayLiteralSegment"),
598 Ref::new("ObjectLiteralSegment")
599 ])
600 .to_matchable()
601 .into(),
602 ),
603 (
604 "AndOperatorGrammar".into(),
605 StringParser::new("AND", SyntaxKind::BinaryOperator)
606 .to_matchable()
607 .into(),
608 ),
609 (
610 "OrOperatorGrammar".into(),
611 StringParser::new("OR", SyntaxKind::BinaryOperator)
612 .to_matchable()
613 .into(),
614 ),
615 (
616 "NotOperatorGrammar".into(),
617 StringParser::new("NOT", SyntaxKind::Keyword)
618 .to_matchable()
619 .into(),
620 ),
621 (
622 "PreTableFunctionKeywordsGrammar".into(),
624 Nothing::new().to_matchable().into(),
625 ),
626 (
627 "BinaryOperatorGrammar".into(),
628 one_of(vec_of_erased![
629 Ref::new("ArithmeticBinaryOperatorGrammar"),
630 Ref::new("StringBinaryOperatorGrammar"),
631 Ref::new("BooleanBinaryOperatorGrammar"),
632 Ref::new("ComparisonOperatorGrammar")
633 ])
634 .to_matchable()
635 .into(),
636 ),
637 (
640 "BracketedColumnReferenceListGrammar".into(),
641 Bracketed::new(vec![
642 Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
643 .to_matchable(),
644 ])
645 .to_matchable()
646 .into(),
647 ),
648 (
649 "OrReplaceGrammar".into(),
650 Sequence::new(vec![
651 Ref::keyword("OR").to_matchable(),
652 Ref::keyword("REPLACE").to_matchable(),
653 ])
654 .to_matchable()
655 .into(),
656 ),
657 (
658 "TemporaryTransientGrammar".into(),
659 one_of(vec![
660 Ref::keyword("TRANSIENT").to_matchable(),
661 Ref::new("TemporaryGrammar").to_matchable(),
662 ])
663 .to_matchable()
664 .into(),
665 ),
666 (
667 "TemporaryGrammar".into(),
668 one_of(vec![
669 Ref::keyword("TEMP").to_matchable(),
670 Ref::keyword("TEMPORARY").to_matchable(),
671 ])
672 .to_matchable()
673 .into(),
674 ),
675 (
676 "IfExistsGrammar".into(),
677 Sequence::new(vec![
678 Ref::keyword("IF").to_matchable(),
679 Ref::keyword("EXISTS").to_matchable(),
680 ])
681 .to_matchable()
682 .into(),
683 ),
684 (
685 "IfNotExistsGrammar".into(),
686 Sequence::new(vec_of_erased![
687 Ref::keyword("IF"),
688 Ref::keyword("NOT"),
689 Ref::keyword("EXISTS")
690 ])
691 .to_matchable()
692 .into(),
693 ),
694 (
695 "LikeGrammar".into(),
696 one_of(vec_of_erased![
697 Ref::keyword("LIKE"),
698 Ref::keyword("RLIKE"),
699 Ref::keyword("ILIKE")
700 ])
701 .to_matchable()
702 .into(),
703 ),
704 (
705 "UnionGrammar".into(),
706 Sequence::new(vec_of_erased![
707 Ref::keyword("UNION"),
708 one_of(vec_of_erased![
709 Ref::keyword("DISTINCT"),
710 Ref::keyword("ALL")
711 ])
712 .config(|this| this.optional())
713 ])
714 .to_matchable()
715 .into(),
716 ),
717 (
718 "IsClauseGrammar".into(),
719 one_of(vec![
720 Ref::new("NullLiteralSegment").to_matchable(),
721 Ref::new("NanLiteralSegment").to_matchable(),
722 Ref::new("BooleanLiteralGrammar").to_matchable(),
723 ])
724 .to_matchable()
725 .into(),
726 ),
727 (
728 "InOperatorGrammar".into(),
729 Sequence::new(vec_of_erased![
730 Ref::keyword("NOT").optional(),
731 Ref::keyword("IN"),
732 one_of(vec_of_erased![
733 Bracketed::new(vec_of_erased![one_of(vec_of_erased![
734 Delimited::new(vec_of_erased![Ref::new("Expression_A_Grammar"),]),
735 Ref::new("SelectableGrammar"),
736 ])])
737 .config(|this| this.parse_mode(ParseMode::Greedy)),
738 Ref::new("FunctionSegment"), ]),
740 ])
741 .to_matchable()
742 .into(),
743 ),
744 (
745 "SelectClauseTerminatorGrammar".into(),
746 one_of(select_clause_terminators()).to_matchable().into(),
747 ),
748 ("IsNullGrammar".into(), Nothing::new().to_matchable().into()),
751 (
752 "NotNullGrammar".into(),
753 Nothing::new().to_matchable().into(),
754 ),
755 (
756 "CollateGrammar".into(),
757 Nothing::new().to_matchable().into(),
758 ),
759 (
760 "FromClauseTerminatorGrammar".into(),
761 one_of(vec![
762 Ref::keyword("WHERE").to_matchable(),
763 Ref::keyword("LIMIT").to_matchable(),
764 Sequence::new(vec![
765 Ref::keyword("GROUP").to_matchable(),
766 Ref::keyword("BY").to_matchable(),
767 ])
768 .to_matchable(),
769 Sequence::new(vec![
770 Ref::keyword("ORDER").to_matchable(),
771 Ref::keyword("BY").to_matchable(),
772 ])
773 .to_matchable(),
774 Ref::keyword("HAVING").to_matchable(),
775 Ref::keyword("QUALIFY").to_matchable(),
776 Ref::keyword("WINDOW").to_matchable(),
777 Ref::new("SetOperatorSegment").to_matchable(),
778 Ref::new("WithNoSchemaBindingClauseSegment").to_matchable(),
779 Ref::new("WithDataClauseSegment").to_matchable(),
780 Ref::keyword("FETCH").to_matchable(),
781 ])
782 .to_matchable()
783 .into(),
784 ),
785 (
786 "WhereClauseTerminatorGrammar".into(),
787 one_of(vec![
788 Ref::keyword("LIMIT").to_matchable(),
789 Sequence::new(vec![
790 Ref::keyword("GROUP").to_matchable(),
791 Ref::keyword("BY").to_matchable(),
792 ])
793 .to_matchable(),
794 Sequence::new(vec![
795 Ref::keyword("ORDER").to_matchable(),
796 Ref::keyword("BY").to_matchable(),
797 ])
798 .to_matchable(),
799 Ref::keyword("HAVING").to_matchable(),
800 Ref::keyword("QUALIFY").to_matchable(),
801 Ref::keyword("WINDOW").to_matchable(),
802 Ref::keyword("OVERLAPS").to_matchable(),
803 Ref::keyword("FETCH").to_matchable(),
804 ])
805 .to_matchable()
806 .into(),
807 ),
808 (
809 "GroupByClauseTerminatorGrammar".into(),
810 one_of(vec![
811 Sequence::new(vec![
812 Ref::keyword("ORDER").to_matchable(),
813 Ref::keyword("BY").to_matchable(),
814 ])
815 .to_matchable(),
816 Ref::keyword("LIMIT").to_matchable(),
817 Ref::keyword("HAVING").to_matchable(),
818 Ref::keyword("QUALIFY").to_matchable(),
819 Ref::keyword("WINDOW").to_matchable(),
820 Ref::keyword("FETCH").to_matchable(),
821 ])
822 .to_matchable()
823 .into(),
824 ),
825 (
826 "HavingClauseTerminatorGrammar".into(),
827 one_of(vec![
828 Sequence::new(vec![
829 Ref::keyword("ORDER").to_matchable(),
830 Ref::keyword("BY").to_matchable(),
831 ])
832 .to_matchable(),
833 Ref::keyword("LIMIT").to_matchable(),
834 Ref::keyword("QUALIFY").to_matchable(),
835 Ref::keyword("WINDOW").to_matchable(),
836 Ref::keyword("FETCH").to_matchable(),
837 ])
838 .to_matchable()
839 .into(),
840 ),
841 (
842 "OrderByClauseTerminators".into(),
843 one_of(vec![
844 Ref::keyword("LIMIT").to_matchable(),
845 Ref::keyword("HAVING").to_matchable(),
846 Ref::keyword("QUALIFY").to_matchable(),
847 Ref::keyword("WINDOW").to_matchable(),
848 Ref::new("FrameClauseUnitGrammar").to_matchable(),
849 Ref::keyword("SEPARATOR").to_matchable(),
850 Ref::keyword("FETCH").to_matchable(),
851 ])
852 .to_matchable()
853 .into(),
854 ),
855 (
856 "PrimaryKeyGrammar".into(),
857 Sequence::new(vec![
858 Ref::keyword("PRIMARY").to_matchable(),
859 Ref::keyword("KEY").to_matchable(),
860 ])
861 .to_matchable()
862 .into(),
863 ),
864 (
865 "ForeignKeyGrammar".into(),
866 Sequence::new(vec![
867 Ref::keyword("FOREIGN").to_matchable(),
868 Ref::keyword("KEY").to_matchable(),
869 ])
870 .to_matchable()
871 .into(),
872 ),
873 (
874 "UniqueKeyGrammar".into(),
875 Sequence::new(vec![Ref::keyword("UNIQUE").to_matchable()])
876 .to_matchable()
877 .into(),
878 ),
879 (
881 "FunctionParameterGrammar".into(),
882 one_of(vec![
883 Sequence::new(vec![
884 Ref::new("ParameterNameSegment").optional().to_matchable(),
885 one_of(vec![
886 Sequence::new(vec![
887 Ref::keyword("ANY").to_matchable(),
888 Ref::keyword("TYPE").to_matchable(),
889 ])
890 .to_matchable(),
891 Ref::new("DatatypeSegment").to_matchable(),
892 ])
893 .to_matchable(),
894 ])
895 .to_matchable(),
896 one_of(vec![
897 Sequence::new(vec![
898 Ref::keyword("ANY").to_matchable(),
899 Ref::keyword("TYPE").to_matchable(),
900 ])
901 .to_matchable(),
902 Ref::new("DatatypeSegment").to_matchable(),
903 ])
904 .to_matchable(),
905 ])
906 .to_matchable()
907 .into(),
908 ),
909 (
910 "AutoIncrementGrammar".into(),
911 Sequence::new(vec![Ref::keyword("AUTO_INCREMENT").to_matchable()])
912 .to_matchable()
913 .into(),
914 ),
915 (
918 "BaseExpressionElementGrammar".into(),
919 one_of(vec![
920 Ref::new("LiteralGrammar").to_matchable(),
921 Ref::new("BareFunctionSegment").to_matchable(),
922 Ref::new("IntervalExpressionSegment").to_matchable(),
923 Ref::new("FunctionSegment").to_matchable(),
924 Ref::new("ColumnReferenceSegment").to_matchable(),
925 Ref::new("ExpressionSegment").to_matchable(),
926 Sequence::new(vec![
927 Ref::new("DatatypeSegment").to_matchable(),
928 Ref::new("LiteralGrammar").to_matchable(),
929 ])
930 .to_matchable(),
931 ])
932 .config(|this| {
933 this.terminators = vec_of_erased![
941 Ref::new("CommaSegment"),
942 Ref::keyword("AS"),
943 ];
945 })
946 .to_matchable()
947 .into(),
948 ),
949 (
950 "FilterClauseGrammar".into(),
951 Sequence::new(vec![
952 Ref::keyword("FILTER").to_matchable(),
953 Bracketed::new(vec![
954 Sequence::new(vec![
955 Ref::keyword("WHERE").to_matchable(),
956 Ref::new("ExpressionSegment").to_matchable(),
957 ])
958 .to_matchable(),
959 ])
960 .to_matchable(),
961 ])
962 .to_matchable()
963 .into(),
964 ),
965 (
966 "IgnoreRespectNullsGrammar".into(),
967 Sequence::new(vec![
968 one_of(vec![
969 Ref::keyword("IGNORE").to_matchable(),
970 Ref::keyword("RESPECT").to_matchable(),
971 ])
972 .to_matchable(),
973 Ref::keyword("NULLS").to_matchable(),
974 ])
975 .to_matchable()
976 .into(),
977 ),
978 (
979 "FrameClauseUnitGrammar".into(),
980 one_of(vec![
981 Ref::keyword("ROWS").to_matchable(),
982 Ref::keyword("RANGE").to_matchable(),
983 ])
984 .to_matchable()
985 .into(),
986 ),
987 (
988 "JoinTypeKeywordsGrammar".into(),
989 one_of(vec![
990 Ref::keyword("CROSS").to_matchable(),
991 Ref::keyword("INNER").to_matchable(),
992 Sequence::new(vec![
993 one_of(vec![
994 Ref::keyword("FULL").to_matchable(),
995 Ref::keyword("LEFT").to_matchable(),
996 Ref::keyword("RIGHT").to_matchable(),
997 ])
998 .to_matchable(),
999 Ref::keyword("OUTER").optional().to_matchable(),
1000 ])
1001 .to_matchable(),
1002 ])
1003 .config(|this| this.optional())
1004 .to_matchable()
1005 .into(),
1006 ),
1007 (
1008 "JoinKeywordsGrammar".into(),
1010 Sequence::new(vec![Ref::keyword("JOIN").to_matchable()])
1011 .to_matchable()
1012 .into(),
1013 ),
1014 (
1015 "NaturalJoinKeywordsGrammar".into(),
1018 Sequence::new(vec![
1019 Ref::keyword("NATURAL").to_matchable(),
1020 one_of(vec![
1021 Ref::keyword("INNER").to_matchable(),
1023 Sequence::new(vec![
1024 one_of(vec![
1025 Ref::keyword("LEFT").to_matchable(),
1026 Ref::keyword("RIGHT").to_matchable(),
1027 Ref::keyword("FULL").to_matchable(),
1028 ])
1029 .to_matchable(),
1030 Ref::keyword("OUTER").optional().to_matchable(),
1031 ])
1032 .config(|this| this.optional())
1033 .to_matchable(),
1034 ])
1035 .config(|this| this.optional())
1036 .to_matchable(),
1037 ])
1038 .to_matchable()
1039 .into(),
1040 ),
1041 (
1043 "ExtendedNaturalJoinKeywordsGrammar".into(),
1044 Nothing::new().to_matchable().into(),
1045 ),
1046 (
1047 "NestedJoinGrammar".into(),
1048 Nothing::new().to_matchable().into(),
1049 ),
1050 (
1051 "ReferentialActionGrammar".into(),
1052 one_of(vec![
1053 Ref::keyword("RESTRICT").to_matchable(),
1054 Ref::keyword("CASCADE").to_matchable(),
1055 Sequence::new(vec![
1056 Ref::keyword("SET").to_matchable(),
1057 Ref::keyword("NULL").to_matchable(),
1058 ])
1059 .to_matchable(),
1060 Sequence::new(vec![
1061 Ref::keyword("NO").to_matchable(),
1062 Ref::keyword("ACTION").to_matchable(),
1063 ])
1064 .to_matchable(),
1065 Sequence::new(vec![
1066 Ref::keyword("SET").to_matchable(),
1067 Ref::keyword("DEFAULT").to_matchable(),
1068 ])
1069 .to_matchable(),
1070 ])
1071 .to_matchable()
1072 .into(),
1073 ),
1074 (
1075 "DropBehaviorGrammar".into(),
1076 one_of(vec![
1077 Ref::keyword("RESTRICT").to_matchable(),
1078 Ref::keyword("CASCADE").to_matchable(),
1079 ])
1080 .config(|this| this.optional())
1081 .to_matchable()
1082 .into(),
1083 ),
1084 (
1085 "ColumnConstraintDefaultGrammar".into(),
1086 one_of(vec![
1087 Ref::new("ShorthandCastSegment").to_matchable(),
1088 Ref::new("LiteralGrammar").to_matchable(),
1089 Ref::new("FunctionSegment").to_matchable(),
1090 Ref::new("BareFunctionSegment").to_matchable(),
1091 ])
1092 .to_matchable()
1093 .into(),
1094 ),
1095 (
1096 "ReferenceDefinitionGrammar".into(),
1097 Sequence::new(vec_of_erased![
1098 Ref::keyword("REFERENCES"),
1099 Ref::new("TableReferenceSegment"),
1100 Ref::new("BracketedColumnReferenceListGrammar").optional(),
1102 Sequence::new(vec_of_erased![
1103 Ref::keyword("MATCH"),
1104 one_of(vec_of_erased![
1105 Ref::keyword("FULL"),
1106 Ref::keyword("PARTIAL"),
1107 Ref::keyword("SIMPLE")
1108 ])
1109 ])
1110 .config(|this| this.optional()),
1111 AnyNumberOf::new(vec_of_erased![
1112 Sequence::new(vec_of_erased![
1114 Ref::keyword("ON"),
1115 Ref::keyword("DELETE"),
1116 Ref::new("ReferentialActionGrammar")
1117 ]),
1118 Sequence::new(vec_of_erased![
1119 Ref::keyword("ON"),
1120 Ref::keyword("UPDATE"),
1121 Ref::new("ReferentialActionGrammar")
1122 ])
1123 ])
1124 ])
1125 .to_matchable()
1126 .into(),
1127 ),
1128 (
1129 "TrimParametersGrammar".into(),
1130 one_of(vec![
1131 Ref::keyword("BOTH").to_matchable(),
1132 Ref::keyword("LEADING").to_matchable(),
1133 Ref::keyword("TRAILING").to_matchable(),
1134 ])
1135 .to_matchable()
1136 .into(),
1137 ),
1138 (
1139 "DefaultValuesGrammar".into(),
1140 Sequence::new(vec![
1141 Ref::keyword("DEFAULT").to_matchable(),
1142 Ref::keyword("VALUES").to_matchable(),
1143 ])
1144 .to_matchable()
1145 .into(),
1146 ),
1147 (
1148 "ObjectReferenceDelimiterGrammar".into(),
1149 one_of(vec![
1150 Ref::new("DotSegment").to_matchable(),
1151 Sequence::new(vec![
1153 Ref::new("DotSegment").to_matchable(),
1154 Ref::new("DotSegment").to_matchable(),
1155 ])
1156 .to_matchable(),
1157 ])
1158 .to_matchable()
1159 .into(),
1160 ),
1161 (
1162 "ObjectReferenceTerminatorGrammar".into(),
1163 one_of(vec![
1164 Ref::keyword("ON").to_matchable(),
1165 Ref::keyword("AS").to_matchable(),
1166 Ref::keyword("USING").to_matchable(),
1167 Ref::new("CommaSegment").to_matchable(),
1168 Ref::new("CastOperatorSegment").to_matchable(),
1169 Ref::new("StartSquareBracketSegment").to_matchable(),
1170 Ref::new("StartBracketSegment").to_matchable(),
1171 Ref::new("BinaryOperatorGrammar").to_matchable(),
1172 Ref::new("ColonSegment").to_matchable(),
1173 Ref::new("DelimiterGrammar").to_matchable(),
1174 Ref::new("JoinLikeClauseGrammar").to_matchable(),
1175 Bracketed::new(vec![]).to_matchable(),
1176 ])
1177 .to_matchable()
1178 .into(),
1179 ),
1180 (
1181 "AlterTableDropColumnGrammar".into(),
1182 Sequence::new(vec_of_erased![
1183 Ref::keyword("DROP"),
1184 Ref::keyword("COLUMN").optional(),
1185 Ref::new("IfExistsGrammar").optional(),
1186 Ref::new("SingleIdentifierGrammar"),
1187 ])
1188 .to_matchable()
1189 .into(),
1190 ),
1191 (
1192 "AlterTableOptionsGrammar".into(),
1193 one_of(vec_of_erased![
1194 Sequence::new(vec_of_erased![
1196 Ref::new("ParameterNameSegment"),
1197 Ref::new("EqualsSegment").optional(),
1198 one_of(vec_of_erased![
1199 Ref::new("LiteralGrammar"),
1200 Ref::new("NakedIdentifierSegment")
1201 ])
1202 ]),
1203 Sequence::new(vec_of_erased![
1205 one_of(vec_of_erased![Ref::keyword("ADD"), Ref::keyword("MODIFY")]),
1206 Ref::keyword("COLUMN").optional(),
1207 Ref::new("ColumnDefinitionSegment"),
1208 one_of(vec_of_erased![Sequence::new(vec_of_erased![one_of(
1209 vec_of_erased![
1210 Ref::keyword("FIRST"),
1211 Ref::keyword("AFTER"),
1212 Ref::new("ColumnReferenceSegment"),
1213 Ref::new("BracketedColumnReferenceListGrammar")
1215 ]
1216 )])])
1217 .config(|this| this.optional())
1218 ]),
1219 Ref::new("AlterTableDropColumnGrammar"),
1221 Sequence::new(vec_of_erased![
1223 Ref::keyword("RENAME"),
1224 one_of(vec_of_erased![Ref::keyword("AS"), Ref::keyword("TO")])
1225 .config(|this| this.optional()),
1226 Ref::new("TableReferenceSegment")
1227 ])
1228 ])
1229 .to_matchable()
1230 .into(),
1231 ),
1232 ]);
1233
1234 ansi_dialect.add([
1235 (
1236 "FileSegment".into(),
1237 NodeMatcher::new(
1238 SyntaxKind::File,
1239 Delimited::new(vec![Ref::new("StatementSegment").to_matchable()])
1240 .config(|this| {
1241 this.allow_trailing();
1242 this.delimiter(
1243 AnyNumberOf::new(vec![Ref::new("DelimiterGrammar").to_matchable()])
1244 .config(|config| config.min_times(1)),
1245 );
1246 })
1247 .to_matchable(),
1248 )
1249 .to_matchable()
1250 .into(),
1251 ),
1252 (
1253 "ColumnReferenceSegment".into(),
1254 NodeMatcher::new(
1255 SyntaxKind::ColumnReference,
1256 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
1257 .config(|this| this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar")))
1258 .to_matchable(),
1259 )
1260 .to_matchable()
1261 .into(),
1262 ),
1263 (
1264 "ExpressionSegment".into(),
1265 NodeMatcher::new(
1266 SyntaxKind::Expression,
1267 Ref::new("Expression_A_Grammar").to_matchable(),
1268 )
1269 .to_matchable()
1270 .into(),
1271 ),
1272 (
1273 "WildcardIdentifierSegment".into(),
1274 NodeMatcher::new(
1275 SyntaxKind::WildcardIdentifier,
1276 Sequence::new(vec![
1277 AnyNumberOf::new(vec![
1278 Sequence::new(vec![
1279 Ref::new("SingleIdentifierGrammar").to_matchable(),
1280 Ref::new("ObjectReferenceDelimiterGrammar").to_matchable(),
1281 ])
1282 .to_matchable(),
1283 ])
1284 .to_matchable(),
1285 Ref::new("StarSegment").to_matchable(),
1286 ])
1287 .allow_gaps(false)
1288 .to_matchable(),
1289 )
1290 .to_matchable()
1291 .into(),
1292 ),
1293 (
1294 "NamedWindowExpressionSegment".into(),
1295 NodeMatcher::new(
1296 SyntaxKind::NamedWindowExpression,
1297 Sequence::new(vec_of_erased![
1298 Ref::new("SingleIdentifierGrammar"),
1299 Ref::keyword("AS"),
1300 one_of(vec_of_erased![
1301 Ref::new("SingleIdentifierGrammar"),
1302 Bracketed::new(vec_of_erased![Ref::new("WindowSpecificationSegment")])
1303 .config(|this| this.parse_mode(ParseMode::Greedy)),
1304 ]),
1305 ])
1306 .to_matchable(),
1307 )
1308 .to_matchable()
1309 .into(),
1310 ),
1311 (
1312 "FunctionSegment".into(),
1313 NodeMatcher::new(
1314 SyntaxKind::Function,
1315 one_of(vec_of_erased![
1316 Sequence::new(vec_of_erased![Sequence::new(vec_of_erased![
1317 Ref::new("DatePartFunctionNameSegment"),
1318 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1319 Ref::new("DatetimeUnitSegment"),
1320 Ref::new("FunctionContentsGrammar").optional()
1321 ])])
1322 .config(|this| this.parse_mode(ParseMode::Greedy))
1323 ])]),
1324 Sequence::new(vec_of_erased![
1325 Sequence::new(vec_of_erased![
1326 Ref::new("FunctionNameSegment").exclude(one_of(vec_of_erased![
1327 Ref::new("DatePartFunctionNameSegment"),
1328 Ref::new("ValuesClauseSegment")
1329 ])),
1330 Bracketed::new(vec_of_erased![
1331 Ref::new("FunctionContentsGrammar").optional()
1332 ])
1333 .config(|this| this.parse_mode(ParseMode::Greedy))
1334 ]),
1335 Ref::new("PostFunctionGrammar").optional()
1336 ])
1337 ])
1338 .to_matchable(),
1339 )
1340 .to_matchable()
1341 .into(),
1342 ),
1343 (
1344 "HavingClauseSegment".into(),
1345 NodeMatcher::new(
1346 SyntaxKind::HavingClause,
1347 Sequence::new(vec_of_erased![
1348 Ref::keyword("HAVING"),
1349 MetaSegment::implicit_indent(),
1350 optionally_bracketed(vec_of_erased![Ref::new("ExpressionSegment")]),
1351 MetaSegment::dedent()
1352 ])
1353 .to_matchable(),
1354 )
1355 .to_matchable()
1356 .into(),
1357 ),
1358 (
1359 "PathSegment".into(),
1360 NodeMatcher::new(
1361 SyntaxKind::PathSegment,
1362 one_of(vec_of_erased![
1363 Sequence::new(vec_of_erased![
1364 Ref::new("SlashSegment"),
1365 Delimited::new(vec_of_erased![TypedParser::new(
1366 SyntaxKind::Word,
1367 SyntaxKind::PathSegment,
1368 )])
1369 .config(|this| {
1370 this.allow_gaps = false;
1371 this.delimiter(Ref::new("SlashSegment"));
1372 }),
1373 ]),
1374 Ref::new("QuotedLiteralSegment"),
1375 ])
1376 .to_matchable(),
1377 )
1378 .to_matchable()
1379 .into(),
1380 ),
1381 (
1382 "LimitClauseSegment".into(),
1383 NodeMatcher::new(
1384 SyntaxKind::LimitClause,
1385 Sequence::new(vec_of_erased![
1386 Ref::keyword("LIMIT"),
1387 MetaSegment::indent(),
1388 optionally_bracketed(vec_of_erased![one_of(vec_of_erased![
1389 Ref::new("NumericLiteralSegment"),
1390 Ref::new("ExpressionSegment"),
1391 Ref::keyword("ALL"),
1392 ])]),
1393 one_of(vec_of_erased![
1394 Sequence::new(vec_of_erased![
1395 Ref::keyword("OFFSET"),
1396 one_of(vec_of_erased![
1397 Ref::new("NumericLiteralSegment"),
1398 Ref::new("ExpressionSegment"),
1399 ]),
1400 ]),
1401 Sequence::new(vec_of_erased![
1402 Ref::new("CommaSegment"),
1403 Ref::new("NumericLiteralSegment"),
1404 ]),
1405 ])
1406 .config(|this| this.optional()),
1407 MetaSegment::dedent()
1408 ])
1409 .to_matchable(),
1410 )
1411 .to_matchable()
1412 .into(),
1413 ),
1414 (
1415 "CubeRollupClauseSegment".into(),
1416 NodeMatcher::new(
1417 SyntaxKind::CubeRollupClause,
1418 Sequence::new(vec_of_erased![
1419 one_of(vec_of_erased![
1420 Ref::new("CubeFunctionNameSegment"),
1421 Ref::new("RollupFunctionNameSegment"),
1422 ]),
1423 Bracketed::new(vec_of_erased![Ref::new("GroupingExpressionList")]),
1424 ])
1425 .to_matchable(),
1426 )
1427 .to_matchable()
1428 .into(),
1429 ),
1430 (
1431 "RollupFunctionNameSegment".into(),
1432 NodeMatcher::new(
1433 SyntaxKind::FunctionName,
1434 StringParser::new("ROLLUP", SyntaxKind::FunctionNameIdentifier).to_matchable(),
1435 )
1436 .to_matchable()
1437 .into(),
1438 ),
1439 (
1440 "CubeFunctionNameSegment".into(),
1441 NodeMatcher::new(
1442 SyntaxKind::FunctionName,
1443 StringParser::new("CUBE", SyntaxKind::FunctionNameIdentifier).to_matchable(),
1444 )
1445 .to_matchable()
1446 .into(),
1447 ),
1448 (
1449 "GroupingSetsClauseSegment".into(),
1450 NodeMatcher::new(
1451 SyntaxKind::GroupingSetsClause,
1452 Sequence::new(vec_of_erased![
1453 Ref::keyword("GROUPING"),
1454 Ref::keyword("SETS"),
1455 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1456 Ref::new("CubeRollupClauseSegment"),
1457 Ref::new("GroupingExpressionList"),
1458 ])]),
1459 ])
1460 .to_matchable(),
1461 )
1462 .to_matchable()
1463 .into(),
1464 ),
1465 (
1466 "GroupingExpressionList".into(),
1467 NodeMatcher::new(
1468 SyntaxKind::GroupingExpressionList,
1469 Sequence::new(vec_of_erased![
1470 MetaSegment::indent(),
1471 Delimited::new(vec_of_erased![
1472 one_of(vec_of_erased![
1473 Ref::new("ColumnReferenceSegment"),
1474 Ref::new("NumericLiteralSegment"),
1475 Ref::new("ExpressionSegment"),
1476 Bracketed::new(vec_of_erased![]),
1477 ]),
1478 Ref::new("GroupByClauseTerminatorGrammar"),
1479 ]),
1480 MetaSegment::dedent(),
1481 ])
1482 .to_matchable(),
1483 )
1484 .to_matchable()
1485 .into(),
1486 ),
1487 (
1488 "SetClauseSegment".into(),
1489 NodeMatcher::new(
1490 SyntaxKind::SetClause,
1491 Sequence::new(vec_of_erased![
1492 Ref::new("ColumnReferenceSegment"),
1493 Ref::new("EqualsSegment"),
1494 one_of(vec_of_erased![
1495 Ref::new("LiteralGrammar"),
1496 Ref::new("BareFunctionSegment"),
1497 Ref::new("FunctionSegment"),
1498 Ref::new("ColumnReferenceSegment"),
1499 Ref::new("ExpressionSegment"),
1500 Ref::new("ValuesClauseSegment"),
1501 Ref::keyword("DEFAULT"),
1502 ]),
1503 ])
1504 .to_matchable(),
1505 )
1506 .to_matchable()
1507 .into(),
1508 ),
1509 (
1510 "FetchClauseSegment".into(),
1511 NodeMatcher::new(
1512 SyntaxKind::FetchClause,
1513 Sequence::new(vec_of_erased![
1514 Ref::keyword("FETCH"),
1515 one_of(vec_of_erased![Ref::keyword("FIRST"), Ref::keyword("NEXT")]),
1516 Ref::new("NumericLiteralSegment").optional(),
1517 one_of(vec_of_erased![Ref::keyword("ROW"), Ref::keyword("ROWS")]),
1518 Ref::keyword("ONLY"),
1519 ])
1520 .to_matchable(),
1521 )
1522 .to_matchable()
1523 .into(),
1524 ),
1525 (
1526 "FunctionDefinitionGrammar".into(),
1527 NodeMatcher::new(
1528 SyntaxKind::FunctionDefinition,
1529 Sequence::new(vec_of_erased![
1530 Ref::keyword("AS"),
1531 Ref::new("QuotedLiteralSegment"),
1532 Sequence::new(vec_of_erased![
1533 Ref::keyword("LANGUAGE"),
1534 Ref::new("NakedIdentifierSegment")
1535 ])
1536 .config(|this| this.optional()),
1537 ])
1538 .to_matchable(),
1539 )
1540 .to_matchable()
1541 .into(),
1542 ),
1543 (
1544 "AlterSequenceOptionsSegment".into(),
1545 NodeMatcher::new(
1546 SyntaxKind::AlterSequenceOptionsSegment,
1547 one_of(vec_of_erased![
1548 Sequence::new(vec_of_erased![
1549 Ref::keyword("INCREMENT"),
1550 Ref::keyword("BY"),
1551 Ref::new("NumericLiteralSegment")
1552 ]),
1553 one_of(vec_of_erased![
1554 Sequence::new(vec_of_erased![
1555 Ref::keyword("MINVALUE"),
1556 Ref::new("NumericLiteralSegment")
1557 ]),
1558 Sequence::new(vec_of_erased![Ref::keyword("NO"), Ref::keyword("MINVALUE")])
1559 ]),
1560 one_of(vec_of_erased![
1561 Sequence::new(vec_of_erased![
1562 Ref::keyword("MAXVALUE"),
1563 Ref::new("NumericLiteralSegment")
1564 ]),
1565 Sequence::new(vec_of_erased![Ref::keyword("NO"), Ref::keyword("MAXVALUE")])
1566 ]),
1567 one_of(vec_of_erased![
1568 Sequence::new(vec_of_erased![
1569 Ref::keyword("CACHE"),
1570 Ref::new("NumericLiteralSegment")
1571 ]),
1572 Ref::keyword("NOCACHE")
1573 ]),
1574 one_of(vec_of_erased![
1575 Ref::keyword("CYCLE"),
1576 Ref::keyword("NOCYCLE")
1577 ]),
1578 one_of(vec_of_erased![
1579 Ref::keyword("ORDER"),
1580 Ref::keyword("NOORDER")
1581 ])
1582 ])
1583 .to_matchable(),
1584 )
1585 .to_matchable()
1586 .into(),
1587 ),
1588 (
1589 "RoleReferenceSegment".into(),
1590 NodeMatcher::new(
1591 SyntaxKind::RoleReference,
1592 Ref::new("SingleIdentifierGrammar").to_matchable(),
1593 )
1594 .to_matchable()
1595 .into(),
1596 ),
1597 (
1598 "TablespaceReferenceSegment".into(),
1599 NodeMatcher::new(
1600 SyntaxKind::TablespaceReference,
1601 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
1602 .config(|this| {
1603 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
1604 this.disallow_gaps();
1605 this.terminators =
1606 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
1607 })
1608 .to_matchable(),
1609 )
1610 .to_matchable()
1611 .into(),
1612 ),
1613 (
1614 "ExtensionReferenceSegment".into(),
1615 NodeMatcher::new(
1616 SyntaxKind::ExtensionReference,
1617 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
1618 .config(|this| {
1619 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
1620 this.disallow_gaps();
1621 this.terminators =
1622 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
1623 })
1624 .to_matchable(),
1625 )
1626 .to_matchable()
1627 .into(),
1628 ),
1629 (
1630 "TagReferenceSegment".into(),
1631 NodeMatcher::new(
1632 SyntaxKind::TagReference,
1633 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
1634 .config(|this| {
1635 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
1636 this.disallow_gaps();
1637 this.terminators =
1638 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
1639 })
1640 .to_matchable(),
1641 )
1642 .to_matchable()
1643 .into(),
1644 ),
1645 (
1646 "ColumnDefinitionSegment".into(),
1647 NodeMatcher::new(
1648 SyntaxKind::ColumnDefinition,
1649 Sequence::new(vec_of_erased![
1650 Ref::new("SingleIdentifierGrammar"), Ref::new("DatatypeSegment"), Bracketed::new(vec_of_erased![Anything::new()]).config(|this| this.optional()),
1653 AnyNumberOf::new(vec_of_erased![Ref::new("ColumnConstraintSegment")])
1654 .config(|this| this.optional())
1655 ])
1656 .to_matchable(),
1657 )
1658 .to_matchable()
1659 .into(),
1660 ),
1661 (
1662 "ColumnConstraintSegment".into(),
1663 NodeMatcher::new(
1664 SyntaxKind::ColumnConstraintSegment,
1665 Sequence::new(vec_of_erased![
1666 Sequence::new(vec_of_erased![
1667 Ref::keyword("CONSTRAINT"),
1668 Ref::new("ObjectReferenceSegment"), ])
1670 .config(|this| this.optional()),
1671 one_of(vec_of_erased![
1672 Sequence::new(vec_of_erased![
1673 Ref::keyword("NOT").optional(),
1674 Ref::keyword("NULL"),
1675 ]),
1676 Sequence::new(vec_of_erased![
1677 Ref::keyword("CHECK"),
1678 Bracketed::new(vec_of_erased![Ref::new("ExpressionSegment")]),
1679 ]),
1680 Sequence::new(vec_of_erased![
1681 Ref::keyword("DEFAULT"),
1682 Ref::new("ColumnConstraintDefaultGrammar"),
1683 ]),
1684 Ref::new("PrimaryKeyGrammar"),
1685 Ref::new("UniqueKeyGrammar"), Ref::new("AutoIncrementGrammar"),
1687 Ref::new("ReferenceDefinitionGrammar"), Ref::new("CommentClauseSegment"),
1690 Sequence::new(vec_of_erased![
1691 Ref::keyword("COLLATE"),
1692 Ref::new("CollationReferenceSegment"),
1693 ]), ]),
1695 ])
1696 .to_matchable(),
1697 )
1698 .to_matchable()
1699 .into(),
1700 ),
1701 (
1702 "CommentClauseSegment".into(),
1703 NodeMatcher::new(
1704 SyntaxKind::CommentClause,
1705 Sequence::new(vec_of_erased![
1706 Ref::keyword("COMMENT"),
1707 Ref::new("QuotedLiteralSegment")
1708 ])
1709 .to_matchable(),
1710 )
1711 .to_matchable()
1712 .into(),
1713 ),
1714 (
1715 "TableEndClauseSegment".into(),
1716 NodeMatcher::new(SyntaxKind::TableEndClause, Nothing::new().to_matchable())
1717 .to_matchable()
1718 .into(),
1719 ),
1720 (
1721 "MergeMatchSegment".into(),
1722 NodeMatcher::new(
1723 SyntaxKind::MergeMatch,
1724 AnyNumberOf::new(vec_of_erased![
1725 Ref::new("MergeMatchedClauseSegment"),
1726 Ref::new("MergeNotMatchedClauseSegment")
1727 ])
1728 .config(|this| this.min_times(1))
1729 .to_matchable(),
1730 )
1731 .to_matchable()
1732 .into(),
1733 ),
1734 (
1735 "MergeMatchedClauseSegment".into(),
1736 NodeMatcher::new(
1737 SyntaxKind::MergeWhenMatchedClause,
1738 Sequence::new(vec_of_erased![
1739 Ref::keyword("WHEN"),
1740 Ref::keyword("MATCHED"),
1741 Sequence::new(vec_of_erased![
1742 Ref::keyword("AND"),
1743 Ref::new("ExpressionSegment")
1744 ])
1745 .config(|this| this.optional()),
1746 Ref::keyword("THEN"),
1747 MetaSegment::indent(),
1748 one_of(vec_of_erased![
1749 Ref::new("MergeUpdateClauseSegment"),
1750 Ref::new("MergeDeleteClauseSegment")
1751 ]),
1752 MetaSegment::dedent()
1753 ])
1754 .to_matchable(),
1755 )
1756 .to_matchable()
1757 .into(),
1758 ),
1759 (
1760 "MergeNotMatchedClauseSegment".into(),
1761 NodeMatcher::new(
1762 SyntaxKind::MergeWhenNotMatchedClause,
1763 Sequence::new(vec_of_erased![
1764 Ref::keyword("WHEN"),
1765 Ref::keyword("NOT"),
1766 Ref::keyword("MATCHED"),
1767 Sequence::new(vec_of_erased![
1768 Ref::keyword("AND"),
1769 Ref::new("ExpressionSegment")
1770 ])
1771 .config(|this| this.optional()),
1772 Ref::keyword("THEN"),
1773 MetaSegment::indent(),
1774 Ref::new("MergeInsertClauseSegment"),
1775 MetaSegment::dedent(),
1776 ])
1777 .to_matchable(),
1778 )
1779 .to_matchable()
1780 .into(),
1781 ),
1782 (
1783 "MergeInsertClauseSegment".into(),
1784 NodeMatcher::new(
1785 SyntaxKind::MergeInsertClause,
1786 Sequence::new(vec_of_erased![
1787 Ref::keyword("INSERT"),
1788 MetaSegment::indent(),
1789 Ref::new("BracketedColumnReferenceListGrammar").optional(),
1790 MetaSegment::dedent(),
1791 Ref::new("ValuesClauseSegment").optional()
1792 ])
1793 .to_matchable(),
1794 )
1795 .to_matchable()
1796 .into(),
1797 ),
1798 (
1799 "MergeUpdateClauseSegment".into(),
1800 NodeMatcher::new(
1801 SyntaxKind::MergeUpdateClause,
1802 Sequence::new(vec_of_erased![
1803 Ref::keyword("UPDATE"),
1804 MetaSegment::indent(),
1805 Ref::new("SetClauseListSegment"),
1806 MetaSegment::dedent(),
1807 ])
1808 .to_matchable(),
1809 )
1810 .to_matchable()
1811 .into(),
1812 ),
1813 (
1814 "MergeDeleteClauseSegment".into(),
1815 NodeMatcher::new(
1816 SyntaxKind::MergeDeleteClause,
1817 Ref::keyword("DELETE").to_matchable(),
1818 )
1819 .to_matchable()
1820 .into(),
1821 ),
1822 (
1823 "SetClauseListSegment".into(),
1824 NodeMatcher::new(
1825 SyntaxKind::SetClauseList,
1826 Sequence::new(vec_of_erased![
1827 Ref::keyword("SET"),
1828 MetaSegment::indent(),
1829 Ref::new("SetClauseSegment"),
1830 AnyNumberOf::new(vec_of_erased![
1831 Ref::new("CommaSegment"),
1832 Ref::new("SetClauseSegment"),
1833 ]),
1834 MetaSegment::dedent(),
1835 ])
1836 .to_matchable(),
1837 )
1838 .to_matchable()
1839 .into(),
1840 ),
1841 (
1842 "TableReferenceSegment".into(),
1843 NodeMatcher::new(
1844 SyntaxKind::TableReference,
1845 ansi_dialect
1846 .grammar("ObjectReferenceSegment")
1847 .match_grammar()
1848 .unwrap()
1849 .clone(),
1850 )
1851 .to_matchable()
1852 .into(),
1853 ),
1854 (
1855 "SchemaReferenceSegment".into(),
1856 NodeMatcher::new(
1857 SyntaxKind::TableReference,
1858 Ref::new("ObjectReferenceSegment").to_matchable(),
1859 )
1860 .to_matchable()
1861 .into(),
1862 ),
1863 (
1864 "SingleIdentifierListSegment".into(),
1865 NodeMatcher::new(
1866 SyntaxKind::IdentifierList,
1867 Delimited::new(vec_of_erased![Ref::new("SingleIdentifierGrammar")])
1868 .config(|this| this.optional())
1869 .to_matchable(),
1870 )
1871 .to_matchable()
1872 .into(),
1873 ),
1874 (
1875 "GroupByClauseSegment".into(),
1876 NodeMatcher::new(
1877 SyntaxKind::GroupbyClause,
1878 Sequence::new(vec_of_erased![
1879 Ref::keyword("GROUP"),
1880 Ref::keyword("BY"),
1881 one_of(vec_of_erased![
1882 Ref::new("CubeRollupClauseSegment"),
1883 Sequence::new(vec_of_erased![
1884 MetaSegment::indent(),
1885 Delimited::new(vec_of_erased![one_of(vec_of_erased![
1886 Ref::new("ColumnReferenceSegment"),
1887 Ref::new("NumericLiteralSegment"),
1888 Ref::new("ExpressionSegment"),
1889 ])])
1890 .config(|this| {
1891 this.terminators =
1892 vec![Ref::new("GroupByClauseTerminatorGrammar").to_matchable()];
1893 }),
1894 MetaSegment::dedent()
1895 ])
1896 ])
1897 ])
1898 .to_matchable(),
1899 )
1900 .to_matchable()
1901 .into(),
1902 ),
1903 (
1904 "FrameClauseSegment".into(),
1905 NodeMatcher::new(
1906 SyntaxKind::FrameClause,
1907 Sequence::new(vec_of_erased![
1908 Ref::new("FrameClauseUnitGrammar"),
1909 one_of(vec_of_erased![
1910 frame_extent(),
1911 Sequence::new(vec_of_erased![
1912 Ref::keyword("BETWEEN"),
1913 frame_extent(),
1914 Ref::keyword("AND"),
1915 frame_extent(),
1916 ])
1917 ])
1918 ])
1919 .to_matchable(),
1920 )
1921 .to_matchable()
1922 .into(),
1923 ),
1924 (
1925 "WithCompoundStatementSegment".into(),
1926 NodeMatcher::new(
1927 SyntaxKind::WithCompoundStatement,
1928 Sequence::new(vec_of_erased![
1929 Ref::keyword("WITH"),
1930 Ref::keyword("RECURSIVE").optional(),
1931 Conditional::new(MetaSegment::indent()).indented_ctes(),
1932 Delimited::new(vec_of_erased![Ref::new("CTEDefinitionSegment")]).config(
1933 |this| {
1934 this.terminators = vec_of_erased![Ref::keyword("SELECT")];
1935 this.allow_trailing();
1936 }
1937 ),
1938 Conditional::new(MetaSegment::dedent()).indented_ctes(),
1939 Ref::new("NonWithSelectableGrammar"),
1940 ])
1941 .to_matchable(),
1942 )
1943 .to_matchable()
1944 .into(),
1945 ),
1946 (
1947 "WithCompoundNonSelectStatementSegment".into(),
1948 NodeMatcher::new(
1949 SyntaxKind::WithCompoundStatement,
1950 Sequence::new(vec_of_erased![
1951 Ref::keyword("WITH"),
1952 Ref::keyword("RECURSIVE").optional(),
1953 Conditional::new(MetaSegment::indent()).indented_ctes(),
1954 Delimited::new(vec_of_erased![Ref::new("CTEDefinitionSegment")]).config(
1955 |this| {
1956 this.terminators = vec_of_erased![Ref::keyword("SELECT")];
1957 this.allow_trailing();
1958 }
1959 ),
1960 Conditional::new(MetaSegment::dedent()).indented_ctes(),
1961 Ref::new("NonWithNonSelectableGrammar"),
1962 ])
1963 .to_matchable(),
1964 )
1965 .to_matchable()
1966 .into(),
1967 ),
1968 (
1969 "CTEDefinitionSegment".into(),
1970 NodeMatcher::new(
1971 SyntaxKind::CommonTableExpression,
1972 Sequence::new(vec_of_erased![
1973 Ref::new("SingleIdentifierGrammar"),
1974 Ref::new("CTEColumnList").optional(),
1975 Ref::keyword("AS").optional(),
1976 Bracketed::new(vec_of_erased![Ref::new("SelectableGrammar")])
1977 ])
1978 .to_matchable(),
1979 )
1980 .to_matchable()
1981 .into(),
1982 ),
1983 (
1984 "CTEColumnList".into(),
1985 NodeMatcher::new(
1986 SyntaxKind::CTEColumnList,
1987 Bracketed::new(vec_of_erased![Ref::new("SingleIdentifierListSegment")])
1988 .to_matchable(),
1989 )
1990 .to_matchable()
1991 .into(),
1992 ),
1993 (
1994 "SequenceReferenceSegment".into(),
1995 NodeMatcher::new(
1996 SyntaxKind::ColumnReference,
1997 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
1998 .config(|this| {
1999 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
2000 this.disallow_gaps();
2001 this.terminators =
2002 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
2003 })
2004 .to_matchable(),
2005 )
2006 .to_matchable()
2007 .into(),
2008 ),
2009 (
2010 "TriggerReferenceSegment".into(),
2011 NodeMatcher::new(
2012 SyntaxKind::TriggerReference,
2013 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
2014 .config(|this| {
2015 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
2016 this.disallow_gaps();
2017 this.terminators =
2018 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
2019 })
2020 .to_matchable(),
2021 )
2022 .to_matchable()
2023 .into(),
2024 ),
2025 (
2026 "TableConstraintSegment".into(),
2027 NodeMatcher::new(
2028 SyntaxKind::TableConstraint,
2029 Sequence::new(vec_of_erased![
2030 Sequence::new(vec_of_erased![
2031 Ref::keyword("CONSTRAINT"),
2032 Ref::new("ObjectReferenceSegment")
2033 ])
2034 .config(|this| this.optional()),
2035 one_of(vec_of_erased![
2036 Sequence::new(vec_of_erased![
2037 Ref::keyword("UNIQUE"),
2038 Ref::new("BracketedColumnReferenceListGrammar")
2039 ]),
2040 Sequence::new(vec_of_erased![
2041 Ref::new("PrimaryKeyGrammar"),
2042 Ref::new("BracketedColumnReferenceListGrammar")
2043 ]),
2044 Sequence::new(vec_of_erased![
2045 Ref::new("ForeignKeyGrammar"),
2046 Ref::new("BracketedColumnReferenceListGrammar"),
2047 Ref::new("ReferenceDefinitionGrammar")
2048 ])
2049 ])
2050 ])
2051 .to_matchable(),
2052 )
2053 .to_matchable()
2054 .into(),
2055 ),
2056 (
2057 "JoinOnConditionSegment".into(),
2058 NodeMatcher::new(
2059 SyntaxKind::JoinOnCondition,
2060 Sequence::new(vec_of_erased![
2061 Ref::keyword("ON"),
2062 Conditional::new(MetaSegment::implicit_indent()).indented_on_contents(),
2063 optionally_bracketed(vec_of_erased![Ref::new("ExpressionSegment")]),
2064 Conditional::new(MetaSegment::dedent()).indented_on_contents()
2065 ])
2066 .to_matchable(),
2067 )
2068 .to_matchable()
2069 .into(),
2070 ),
2071 (
2072 "DatabaseReferenceSegment".into(),
2073 NodeMatcher::new(
2074 SyntaxKind::DatabaseReference,
2075 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
2076 .config(|this| {
2077 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
2078 this.disallow_gaps();
2079 this.terminators =
2080 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
2081 })
2082 .to_matchable(),
2083 )
2084 .to_matchable()
2085 .into(),
2086 ),
2087 (
2088 "IndexReferenceSegment".into(),
2089 NodeMatcher::new(
2090 SyntaxKind::DatabaseReference,
2091 Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
2092 .config(|this| {
2093 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
2094 this.disallow_gaps();
2095 this.terminators =
2096 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
2097 })
2098 .to_matchable(),
2099 )
2100 .to_matchable()
2101 .into(),
2102 ),
2103 (
2104 "CollationReferenceSegment".into(),
2105 NodeMatcher::new(
2106 SyntaxKind::CollationReference,
2107 one_of(vec_of_erased![
2108 Ref::new("QuotedLiteralSegment"),
2109 Delimited::new(vec_of_erased![Ref::new("SingleIdentifierGrammar")]).config(
2110 |this| {
2111 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
2112 this.terminators =
2113 vec_of_erased![Ref::new("ObjectReferenceTerminatorGrammar")];
2114 this.allow_gaps = false;
2115 }
2116 ),
2117 ])
2118 .to_matchable(),
2119 )
2120 .to_matchable()
2121 .into(),
2122 ),
2123 (
2124 "OverClauseSegment".into(),
2125 NodeMatcher::new(
2126 SyntaxKind::OverClause,
2127 Sequence::new(vec_of_erased![
2128 MetaSegment::indent(),
2129 Ref::new("IgnoreRespectNullsGrammar").optional(),
2130 Ref::keyword("OVER"),
2131 one_of(vec_of_erased![
2132 Ref::new("SingleIdentifierGrammar"),
2133 Bracketed::new(vec_of_erased![
2134 Ref::new("WindowSpecificationSegment").optional()
2135 ])
2136 .config(|this| this.parse_mode(ParseMode::Greedy))
2137 ]),
2138 MetaSegment::dedent()
2139 ])
2140 .to_matchable(),
2141 )
2142 .to_matchable()
2143 .into(),
2144 ),
2145 (
2146 "NamedWindowSegment".into(),
2147 NodeMatcher::new(
2148 SyntaxKind::NamedWindow,
2149 Sequence::new(vec_of_erased![
2150 Ref::keyword("WINDOW"),
2151 MetaSegment::indent(),
2152 Delimited::new(vec_of_erased![Ref::new("NamedWindowExpressionSegment")]),
2153 MetaSegment::dedent(),
2154 ])
2155 .to_matchable(),
2156 )
2157 .to_matchable()
2158 .into(),
2159 ),
2160 (
2161 "WindowSpecificationSegment".into(),
2162 NodeMatcher::new(
2163 SyntaxKind::WindowSpecification,
2164 Sequence::new(vec_of_erased![
2165 Ref::new("SingleIdentifierGrammar")
2166 .optional()
2167 .exclude(Ref::keyword("PARTITION")),
2168 Ref::new("PartitionClauseSegment").optional(),
2169 Ref::new("OrderByClauseSegment").optional(),
2170 Ref::new("FrameClauseSegment").optional()
2171 ])
2172 .config(|this| this.optional())
2173 .to_matchable(),
2174 )
2175 .to_matchable()
2176 .into(),
2177 ),
2178 (
2179 "PartitionClauseSegment".into(),
2180 NodeMatcher::new(
2181 SyntaxKind::PartitionbyClause,
2182 Sequence::new(vec_of_erased![
2183 Ref::keyword("PARTITION"),
2184 Ref::keyword("BY"),
2185 MetaSegment::indent(),
2186 optionally_bracketed(vec_of_erased![Delimited::new(vec_of_erased![Ref::new(
2187 "ExpressionSegment"
2188 )])]),
2189 MetaSegment::dedent()
2190 ])
2191 .to_matchable(),
2192 )
2193 .to_matchable()
2194 .into(),
2195 ),
2196 (
2197 "JoinClauseSegment".into(),
2198 NodeMatcher::new(
2199 SyntaxKind::JoinClause,
2200 one_of(vec_of_erased![
2201 Sequence::new(vec_of_erased![
2202 Ref::new("JoinTypeKeywordsGrammar").optional(),
2203 Ref::new("JoinKeywordsGrammar"),
2204 MetaSegment::indent(),
2205 Ref::new("FromExpressionElementSegment"),
2206 AnyNumberOf::new(vec_of_erased![Ref::new("NestedJoinGrammar")]),
2207 MetaSegment::dedent(),
2208 Sequence::new(vec_of_erased![
2209 Conditional::new(MetaSegment::indent()).indented_using_on(),
2210 one_of(vec_of_erased![
2211 Ref::new("JoinOnConditionSegment"),
2212 Sequence::new(vec_of_erased![
2213 Ref::keyword("USING"),
2214 MetaSegment::indent(),
2215 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
2216 Ref::new("SingleIdentifierGrammar")
2217 ])])
2218 .config(|this| this.parse_mode = ParseMode::Greedy),
2219 MetaSegment::dedent(),
2220 ])
2221 ]),
2222 Conditional::new(MetaSegment::dedent()).indented_using_on(),
2223 ])
2224 .config(|this| this.optional())
2225 ]),
2226 Sequence::new(vec_of_erased![
2227 Ref::new("NaturalJoinKeywordsGrammar"),
2228 Ref::new("JoinKeywordsGrammar"),
2229 MetaSegment::indent(),
2230 Ref::new("FromExpressionElementSegment"),
2231 MetaSegment::dedent(),
2232 ]),
2233 Sequence::new(vec_of_erased![
2234 Ref::new("ExtendedNaturalJoinKeywordsGrammar"),
2235 MetaSegment::indent(),
2236 Ref::new("FromExpressionElementSegment"),
2237 MetaSegment::dedent(),
2238 ])
2239 ])
2240 .to_matchable(),
2241 )
2242 .to_matchable()
2243 .into(),
2244 ),
2245 (
2246 "DropTriggerStatementSegment".into(),
2247 NodeMatcher::new(
2248 SyntaxKind::DropTriggerStatement,
2249 Sequence::new(vec_of_erased![
2250 Ref::keyword("DROP"),
2251 Ref::keyword("TRIGGER"),
2252 Ref::new("IfExistsGrammar").optional(),
2253 Ref::new("TriggerReferenceSegment")
2254 ])
2255 .to_matchable(),
2256 )
2257 .to_matchable()
2258 .into(),
2259 ),
2260 (
2261 "SamplingExpressionSegment".into(),
2262 NodeMatcher::new(
2263 SyntaxKind::SampleExpression,
2264 Sequence::new(vec_of_erased![
2265 Ref::keyword("TABLESAMPLE"),
2266 one_of(vec_of_erased![
2267 Ref::keyword("BERNOULLI"),
2268 Ref::keyword("SYSTEM")
2269 ]),
2270 Bracketed::new(vec_of_erased![Ref::new("NumericLiteralSegment")]),
2271 Sequence::new(vec_of_erased![
2272 Ref::keyword("REPEATABLE"),
2273 Bracketed::new(vec_of_erased![Ref::new("NumericLiteralSegment")]),
2274 ])
2275 .config(|this| this.optional())
2276 ])
2277 .to_matchable(),
2278 )
2279 .to_matchable()
2280 .into(),
2281 ),
2282 (
2283 "TableExpressionSegment".into(),
2284 NodeMatcher::new(
2285 SyntaxKind::TableExpression,
2286 one_of(vec_of_erased![
2287 Ref::new("ValuesClauseSegment"),
2288 Ref::new("BareFunctionSegment"),
2289 Ref::new("FunctionSegment"),
2290 Ref::new("TableReferenceSegment"),
2291 Bracketed::new(vec_of_erased![Ref::new("SelectableGrammar")]),
2292 Bracketed::new(vec_of_erased![Ref::new("MergeStatementSegment")])
2293 ])
2294 .to_matchable(),
2295 )
2296 .to_matchable()
2297 .into(),
2298 ),
2299 (
2300 "DropTriggerStatementSegment".into(),
2301 NodeMatcher::new(
2302 SyntaxKind::DropTriggerStatement,
2303 Sequence::new(vec_of_erased![
2304 Ref::keyword("DROP"),
2305 Ref::keyword("TRIGGER"),
2306 Ref::new("IfExistsGrammar").optional(),
2307 Ref::new("TriggerReferenceSegment")
2308 ])
2309 .to_matchable(),
2310 )
2311 .to_matchable()
2312 .into(),
2313 ),
2314 (
2315 "SamplingExpressionSegment".into(),
2316 NodeMatcher::new(
2317 SyntaxKind::SampleExpression,
2318 Sequence::new(vec_of_erased![
2319 Ref::keyword("TABLESAMPLE"),
2320 one_of(vec_of_erased![
2321 Ref::keyword("BERNOULLI"),
2322 Ref::keyword("SYSTEM")
2323 ]),
2324 Bracketed::new(vec_of_erased![Ref::new("NumericLiteralSegment")]),
2325 Sequence::new(vec_of_erased![
2326 Ref::keyword("REPEATABLE"),
2327 Bracketed::new(vec_of_erased![Ref::new("NumericLiteralSegment")]),
2328 ])
2329 .config(|this| this.optional())
2330 ])
2331 .to_matchable(),
2332 )
2333 .to_matchable()
2334 .into(),
2335 ),
2336 (
2337 "TableExpressionSegment".into(),
2338 NodeMatcher::new(
2339 SyntaxKind::TableExpression,
2340 one_of(vec_of_erased![
2341 Ref::new("ValuesClauseSegment"),
2342 Ref::new("BareFunctionSegment"),
2343 Ref::new("FunctionSegment"),
2344 Ref::new("TableReferenceSegment"),
2345 Bracketed::new(vec_of_erased![Ref::new("SelectableGrammar")]),
2346 Bracketed::new(vec_of_erased![Ref::new("MergeStatementSegment")])
2347 ])
2348 .to_matchable(),
2349 )
2350 .to_matchable()
2351 .into(),
2352 ),
2353 (
2354 "CreateTriggerStatementSegment".into(),
2355 NodeMatcher::new(
2356 SyntaxKind::CreateTriggerStatement,
2357 Sequence::new(vec![
2358 Ref::keyword("CREATE").to_matchable(),
2359 Ref::keyword("TRIGGER").to_matchable(),
2360 Ref::new("TriggerReferenceSegment").to_matchable(),
2361 one_of(vec![
2362 Ref::keyword("BEFORE").to_matchable(),
2363 Ref::keyword("AFTER").to_matchable(),
2364 Sequence::new(vec![
2365 Ref::keyword("INSTEAD").to_matchable(),
2366 Ref::keyword("OF").to_matchable(),
2367 ])
2368 .to_matchable(),
2369 ])
2370 .config(|this| this.optional())
2371 .to_matchable(),
2372 Delimited::new(vec![
2373 Ref::keyword("INSERT").to_matchable(),
2374 Ref::keyword("DELETE").to_matchable(),
2375 Sequence::new(vec![
2376 Ref::keyword("UPDATE").to_matchable(),
2377 Ref::keyword("OF").to_matchable(),
2378 Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
2379 .to_matchable(),
2381 ])
2382 .to_matchable(),
2383 ])
2384 .config(|this| {
2385 this.delimiter(Ref::keyword("OR"));
2386 })
2388 .to_matchable(),
2389 Ref::keyword("ON").to_matchable(),
2390 Ref::new("TableReferenceSegment").to_matchable(),
2391 AnyNumberOf::new(vec_of_erased![
2392 Sequence::new(vec_of_erased![
2393 Ref::keyword("REFERENCING"),
2394 Ref::keyword("OLD"),
2395 Ref::keyword("ROW"),
2396 Ref::keyword("AS"),
2397 Ref::new("ParameterNameSegment"),
2398 Ref::keyword("NEW"),
2399 Ref::keyword("ROW"),
2400 Ref::keyword("AS"),
2401 Ref::new("ParameterNameSegment"),
2402 ]),
2403 Sequence::new(vec_of_erased![
2404 Ref::keyword("FROM"),
2405 Ref::new("TableReferenceSegment"),
2406 ]),
2407 one_of(vec_of_erased![
2408 Sequence::new(vec_of_erased![
2409 Ref::keyword("NOT"),
2410 Ref::keyword("DEFERRABLE"),
2411 ]),
2412 Sequence::new(vec_of_erased![
2413 Ref::keyword("DEFERRABLE").optional(),
2414 one_of(vec_of_erased![
2415 Sequence::new(vec_of_erased![
2416 Ref::keyword("INITIALLY"),
2417 Ref::keyword("IMMEDIATE"),
2418 ]),
2419 Sequence::new(vec_of_erased![
2420 Ref::keyword("INITIALLY"),
2421 Ref::keyword("DEFERRED"),
2422 ]),
2423 ]),
2424 ]),
2425 ]),
2426 Sequence::new(vec_of_erased![
2427 Ref::keyword("FOR"),
2428 Ref::keyword("EACH").optional(),
2429 one_of(vec_of_erased![
2430 Ref::keyword("ROW"),
2431 Ref::keyword("STATEMENT"),
2432 ]),
2433 ]),
2434 Sequence::new(vec_of_erased![
2435 Ref::keyword("WHEN"),
2436 Bracketed::new(vec_of_erased![Ref::new("ExpressionSegment"),]),
2437 ]),
2438 ])
2439 .to_matchable(),
2440 Sequence::new(vec![
2441 Ref::keyword("EXECUTE").to_matchable(),
2442 Ref::keyword("PROCEDURE").to_matchable(),
2443 Ref::new("FunctionNameIdentifierSegment").to_matchable(),
2444 Bracketed::new(vec![
2445 Ref::new("FunctionContentsGrammar")
2446 .optional()
2447 .to_matchable(),
2448 ])
2449 .to_matchable(),
2450 ])
2451 .config(|this| this.optional())
2452 .to_matchable(),
2453 ])
2454 .to_matchable(),
2455 )
2456 .to_matchable()
2457 .into(),
2458 ),
2459 (
2460 "DropModelStatementSegment".into(),
2461 NodeMatcher::new(
2462 SyntaxKind::DropModelStatement,
2463 Sequence::new(vec_of_erased![
2464 Ref::keyword("DROP"),
2465 Ref::keyword("MODEL"),
2466 Ref::new("IfExistsGrammar").optional(),
2467 Ref::new("ObjectReferenceSegment")
2468 ])
2469 .to_matchable(),
2470 )
2471 .to_matchable()
2472 .into(),
2473 ),
2474 (
2475 "DescribeStatementSegment".into(),
2476 NodeMatcher::new(
2477 SyntaxKind::DescribeStatement,
2478 Sequence::new(vec_of_erased![
2479 Ref::keyword("DESCRIBE"),
2480 Ref::new("NakedIdentifierSegment"),
2481 Ref::new("ObjectReferenceSegment")
2482 ])
2483 .to_matchable(),
2484 )
2485 .to_matchable()
2486 .into(),
2487 ),
2488 (
2489 "UseStatementSegment".into(),
2490 NodeMatcher::new(
2491 SyntaxKind::UseStatement,
2492 Sequence::new(vec_of_erased![
2493 Ref::keyword("USE"),
2494 Ref::new("DatabaseReferenceSegment")
2495 ])
2496 .to_matchable(),
2497 )
2498 .to_matchable()
2499 .into(),
2500 ),
2501 (
2502 "ExplainStatementSegment".into(),
2503 NodeMatcher::new(
2504 SyntaxKind::ExplainStatement,
2505 Sequence::new(vec_of_erased![
2506 Ref::keyword("EXPLAIN"),
2507 one_of(vec_of_erased![
2508 Ref::new("SelectableGrammar"),
2509 Ref::new("InsertStatementSegment"),
2510 Ref::new("UpdateStatementSegment"),
2511 Ref::new("DeleteStatementSegment")
2512 ])
2513 ])
2514 .to_matchable(),
2515 )
2516 .to_matchable()
2517 .into(),
2518 ),
2519 (
2520 "CreateSequenceStatementSegment".into(),
2521 NodeMatcher::new(
2522 SyntaxKind::CreateSequenceStatement,
2523 Sequence::new(vec_of_erased![
2524 Ref::keyword("CREATE"),
2525 Ref::keyword("SEQUENCE"),
2526 Ref::new("SequenceReferenceSegment"),
2527 AnyNumberOf::new(vec_of_erased![Ref::new("CreateSequenceOptionsSegment")])
2528 .config(|this| this.optional())
2529 ])
2530 .to_matchable(),
2531 )
2532 .to_matchable()
2533 .into(),
2534 ),
2535 (
2536 "CreateSequenceOptionsSegment".into(),
2537 NodeMatcher::new(
2538 SyntaxKind::CreateSequenceOptionsSegment,
2539 one_of(vec_of_erased![
2540 Sequence::new(vec_of_erased![
2541 Ref::keyword("INCREMENT"),
2542 Ref::keyword("BY"),
2543 Ref::new("NumericLiteralSegment")
2544 ]),
2545 Sequence::new(vec_of_erased![
2546 Ref::keyword("START"),
2547 Ref::keyword("WITH").optional(),
2548 Ref::new("NumericLiteralSegment")
2549 ]),
2550 one_of(vec_of_erased![
2551 Sequence::new(vec_of_erased![
2552 Ref::keyword("MINVALUE"),
2553 Ref::new("NumericLiteralSegment")
2554 ]),
2555 Sequence::new(vec_of_erased![Ref::keyword("NO"), Ref::keyword("MINVALUE")])
2556 ]),
2557 one_of(vec_of_erased![
2558 Sequence::new(vec_of_erased![
2559 Ref::keyword("MAXVALUE"),
2560 Ref::new("NumericLiteralSegment")
2561 ]),
2562 Sequence::new(vec_of_erased![Ref::keyword("NO"), Ref::keyword("MAXVALUE")])
2563 ]),
2564 one_of(vec_of_erased![
2565 Sequence::new(vec_of_erased![
2566 Ref::keyword("CACHE"),
2567 Ref::new("NumericLiteralSegment")
2568 ]),
2569 Ref::keyword("NOCACHE")
2570 ]),
2571 one_of(vec_of_erased![
2572 Ref::keyword("CYCLE"),
2573 Ref::keyword("NOCYCLE")
2574 ]),
2575 one_of(vec_of_erased![
2576 Ref::keyword("ORDER"),
2577 Ref::keyword("NOORDER")
2578 ])
2579 ])
2580 .to_matchable(),
2581 )
2582 .to_matchable()
2583 .into(),
2584 ),
2585 (
2586 "AlterSequenceStatementSegment".into(),
2587 NodeMatcher::new(
2588 SyntaxKind::AlterSequenceStatement,
2589 Sequence::new(vec_of_erased![
2590 Ref::keyword("ALTER"),
2591 Ref::keyword("SEQUENCE"),
2592 Ref::new("SequenceReferenceSegment"),
2593 AnyNumberOf::new(vec_of_erased![Ref::new("AlterSequenceOptionsSegment")])
2594 ])
2595 .to_matchable(),
2596 )
2597 .to_matchable()
2598 .into(),
2599 ),
2600 (
2601 "DropSequenceStatementSegment".into(),
2602 NodeMatcher::new(
2603 SyntaxKind::DropSequenceStatement,
2604 Sequence::new(vec_of_erased![
2605 Ref::keyword("DROP"),
2606 Ref::keyword("SEQUENCE"),
2607 Ref::new("SequenceReferenceSegment")
2608 ])
2609 .to_matchable(),
2610 )
2611 .to_matchable()
2612 .into(),
2613 ),
2614 (
2615 "DropCastStatementSegment".into(),
2616 NodeMatcher::new(
2617 SyntaxKind::DropCastStatement,
2618 Sequence::new(vec_of_erased![
2619 Ref::keyword("DROP"),
2620 Ref::keyword("CAST"),
2621 Bracketed::new(vec_of_erased![
2622 Ref::new("DatatypeSegment"),
2623 Ref::keyword("AS"),
2624 Ref::new("DatatypeSegment")
2625 ]),
2626 Ref::new("DropBehaviorGrammar").optional()
2627 ])
2628 .to_matchable(),
2629 )
2630 .to_matchable()
2631 .into(),
2632 ),
2633 (
2634 "CreateFunctionStatementSegment".into(),
2635 NodeMatcher::new(
2636 SyntaxKind::CreateFunctionStatement,
2637 Sequence::new(vec_of_erased![
2638 Ref::keyword("CREATE"),
2639 Ref::new("OrReplaceGrammar").optional(),
2640 Ref::new("TemporaryGrammar").optional(),
2641 Ref::keyword("FUNCTION"),
2642 Ref::new("IfNotExistsGrammar").optional(),
2643 Ref::new("FunctionNameSegment"),
2644 Ref::new("FunctionParameterListGrammar"),
2645 Sequence::new(vec_of_erased![
2646 Ref::keyword("RETURNS"),
2647 Ref::new("DatatypeSegment")
2648 ])
2649 .config(|this| this.optional()),
2650 Ref::new("FunctionDefinitionGrammar")
2651 ])
2652 .to_matchable(),
2653 )
2654 .to_matchable()
2655 .into(),
2656 ),
2657 (
2658 "DropFunctionStatementSegment".into(),
2659 NodeMatcher::new(
2660 SyntaxKind::DropFunctionStatement,
2661 Sequence::new(vec_of_erased![
2662 Ref::keyword("DROP"),
2663 Ref::keyword("FUNCTION"),
2664 Ref::new("IfExistsGrammar").optional(),
2665 Ref::new("FunctionNameSegment")
2666 ])
2667 .to_matchable(),
2668 )
2669 .to_matchable()
2670 .into(),
2671 ),
2672 (
2673 "CreateModelStatementSegment".into(),
2674 NodeMatcher::new(
2675 SyntaxKind::CreateModelStatement,
2676 Sequence::new(vec_of_erased![
2677 Ref::keyword("CREATE"),
2678 Ref::new("OrReplaceGrammar").optional(),
2679 Ref::keyword("MODEL"),
2680 Ref::new("IfNotExistsGrammar").optional(),
2681 Ref::new("ObjectReferenceSegment"),
2682 Sequence::new(vec_of_erased![
2683 Ref::keyword("OPTIONS"),
2684 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
2685 Sequence::new(vec_of_erased![
2686 Ref::new("ParameterNameSegment"),
2687 Ref::new("EqualsSegment"),
2688 one_of(vec_of_erased![
2689 Ref::new("LiteralGrammar"), Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
2691 Ref::new("QuotedLiteralSegment")
2692 ])])
2693 .config(|this| {
2694 this.bracket_type("square");
2695 this.optional();
2696 })
2697 ])
2698 ])
2699 ])])
2700 ])
2701 .config(|this| this.optional()),
2702 Ref::keyword("AS"),
2703 Ref::new("SelectableGrammar")
2704 ])
2705 .to_matchable(),
2706 )
2707 .to_matchable()
2708 .into(),
2709 ),
2710 (
2711 "CreateViewStatementSegment".into(),
2712 NodeMatcher::new(
2713 SyntaxKind::CreateViewStatement,
2714 Sequence::new(vec_of_erased![
2715 Ref::keyword("CREATE"),
2716 Ref::new("OrReplaceGrammar").optional(),
2717 Ref::keyword("VIEW"),
2718 Ref::new("IfNotExistsGrammar").optional(),
2719 Ref::new("TableReferenceSegment"),
2720 Ref::new("BracketedColumnReferenceListGrammar").optional(),
2721 Ref::keyword("AS"),
2722 optionally_bracketed(vec_of_erased![Ref::new("SelectableGrammar")]),
2723 Ref::new("WithNoSchemaBindingClauseSegment").optional()
2724 ])
2725 .to_matchable(),
2726 )
2727 .to_matchable()
2728 .into(),
2729 ),
2730 (
2731 "DeleteStatementSegment".into(),
2732 NodeMatcher::new(
2733 SyntaxKind::DeleteStatement,
2734 Sequence::new(vec_of_erased![
2735 Ref::keyword("DELETE"),
2736 Ref::new("FromClauseSegment"),
2737 Ref::new("WhereClauseSegment").optional()
2738 ])
2739 .to_matchable(),
2740 )
2741 .to_matchable()
2742 .into(),
2743 ),
2744 (
2745 "UpdateStatementSegment".into(),
2746 NodeMatcher::new(
2747 SyntaxKind::UpdateStatement,
2748 Sequence::new(vec_of_erased![
2749 Ref::keyword("UPDATE"),
2750 Ref::new("TableReferenceSegment"),
2751 Ref::new("AliasExpressionSegment")
2752 .exclude(Ref::keyword("SET"))
2753 .optional(),
2754 Ref::new("SetClauseListSegment"),
2755 Ref::new("FromClauseSegment").optional(),
2756 Ref::new("WhereClauseSegment").optional()
2757 ])
2758 .to_matchable(),
2759 )
2760 .to_matchable()
2761 .into(),
2762 ),
2763 (
2764 "CreateCastStatementSegment".into(),
2765 NodeMatcher::new(
2766 SyntaxKind::CreateCastStatement,
2767 Sequence::new(vec_of_erased![
2768 Ref::keyword("CREATE"),
2769 Ref::keyword("CAST"),
2770 Bracketed::new(vec_of_erased![
2771 Ref::new("DatatypeSegment"),
2772 Ref::keyword("AS"),
2773 Ref::new("DatatypeSegment")
2774 ]),
2775 Ref::keyword("WITH"),
2776 Ref::keyword("SPECIFIC").optional(),
2777 one_of(vec_of_erased![
2778 Ref::keyword("ROUTINE"),
2779 Ref::keyword("FUNCTION"),
2780 Ref::keyword("PROCEDURE"),
2781 Sequence::new(vec_of_erased![
2782 one_of(vec_of_erased![
2783 Ref::keyword("INSTANCE"),
2784 Ref::keyword("STATIC"),
2785 Ref::keyword("CONSTRUCTOR")
2786 ])
2787 .config(|this| this.optional()),
2788 Ref::keyword("METHOD")
2789 ])
2790 ]),
2791 Ref::new("FunctionNameSegment"),
2792 Ref::new("FunctionParameterListGrammar").optional(),
2793 Sequence::new(vec_of_erased![
2794 Ref::keyword("FOR"),
2795 Ref::new("ObjectReferenceSegment")
2796 ])
2797 .config(|this| this.optional()),
2798 Sequence::new(vec_of_erased![
2799 Ref::keyword("AS"),
2800 Ref::keyword("ASSIGNMENT")
2801 ])
2802 .config(|this| this.optional())
2803 ])
2804 .to_matchable(),
2805 )
2806 .to_matchable()
2807 .into(),
2808 ),
2809 (
2810 "CreateRoleStatementSegment".into(),
2811 NodeMatcher::new(
2812 SyntaxKind::CreateRoleStatement,
2813 Sequence::new(vec_of_erased![
2814 Ref::keyword("CREATE"),
2815 Ref::keyword("ROLE"),
2816 Ref::new("RoleReferenceSegment")
2817 ])
2818 .to_matchable(),
2819 )
2820 .to_matchable()
2821 .into(),
2822 ),
2823 (
2824 "DropRoleStatementSegment".into(),
2825 NodeMatcher::new(
2826 SyntaxKind::DropRoleStatement,
2827 Sequence::new(vec_of_erased![
2828 Ref::keyword("DROP"),
2829 Ref::keyword("ROLE"),
2830 Ref::new("IfExistsGrammar").optional(),
2831 Ref::new("SingleIdentifierGrammar")
2832 ])
2833 .to_matchable(),
2834 )
2835 .to_matchable()
2836 .into(),
2837 ),
2838 (
2839 "AlterTableStatementSegment".into(),
2840 NodeMatcher::new(
2841 SyntaxKind::AlterTableStatement,
2842 Sequence::new(vec_of_erased![
2843 Ref::keyword("ALTER"),
2844 Ref::keyword("TABLE"),
2845 Ref::new("TableReferenceSegment"),
2846 Delimited::new(vec_of_erased![Ref::new("AlterTableOptionsGrammar")])
2847 ])
2848 .to_matchable(),
2849 )
2850 .to_matchable()
2851 .into(),
2852 ),
2853 (
2854 "SetSchemaStatementSegment".into(),
2855 NodeMatcher::new(
2856 SyntaxKind::SetSchemaStatement,
2857 Sequence::new(vec_of_erased![
2858 Ref::keyword("SET"),
2859 Ref::keyword("SCHEMA"),
2860 Ref::new("IfNotExistsGrammar").optional(),
2861 Ref::new("SchemaReferenceSegment")
2862 ])
2863 .to_matchable(),
2864 )
2865 .to_matchable()
2866 .into(),
2867 ),
2868 (
2869 "DropSchemaStatementSegment".into(),
2870 NodeMatcher::new(
2871 SyntaxKind::DropSchemaStatement,
2872 Sequence::new(vec_of_erased![
2873 Ref::keyword("DROP"),
2874 Ref::keyword("SCHEMA"),
2875 Ref::new("IfExistsGrammar").optional(),
2876 Ref::new("SchemaReferenceSegment"),
2877 Ref::new("DropBehaviorGrammar").optional()
2878 ])
2879 .to_matchable(),
2880 )
2881 .to_matchable()
2882 .into(),
2883 ),
2884 (
2885 "DropTypeStatementSegment".into(),
2886 NodeMatcher::new(
2887 SyntaxKind::DropTypeStatement,
2888 Sequence::new(vec_of_erased![
2889 Ref::keyword("DROP"),
2890 Ref::keyword("TYPE"),
2891 Ref::new("IfExistsGrammar").optional(),
2892 Ref::new("ObjectReferenceSegment"),
2893 Ref::new("DropBehaviorGrammar").optional()
2894 ])
2895 .to_matchable(),
2896 )
2897 .to_matchable()
2898 .into(),
2899 ),
2900 (
2901 "CreateDatabaseStatementSegment".into(),
2902 NodeMatcher::new(
2903 SyntaxKind::CreateDatabaseStatement,
2904 Sequence::new(vec_of_erased![
2905 Ref::keyword("CREATE"),
2906 Ref::keyword("DATABASE"),
2907 Ref::new("IfNotExistsGrammar").optional(),
2908 Ref::new("DatabaseReferenceSegment")
2909 ])
2910 .to_matchable(),
2911 )
2912 .to_matchable()
2913 .into(),
2914 ),
2915 (
2916 "DropDatabaseStatementSegment".into(),
2917 NodeMatcher::new(
2918 SyntaxKind::DropDatabaseStatement,
2919 Sequence::new(vec_of_erased![
2920 Ref::keyword("DROP"),
2921 Ref::keyword("DATABASE"),
2922 Ref::new("IfExistsGrammar").optional(),
2923 Ref::new("DatabaseReferenceSegment"),
2924 Ref::new("DropBehaviorGrammar").optional()
2925 ])
2926 .to_matchable(),
2927 )
2928 .to_matchable()
2929 .into(),
2930 ),
2931 (
2932 "FunctionParameterListGrammar".into(),
2933 NodeMatcher::new(
2934 SyntaxKind::FunctionParameterList,
2935 Bracketed::new(vec_of_erased![
2936 Delimited::new(vec_of_erased![Ref::new("FunctionParameterGrammar")])
2937 .config(|this| this.optional())
2938 ])
2939 .to_matchable(),
2940 )
2941 .to_matchable()
2942 .into(),
2943 ),
2944 (
2945 "CreateIndexStatementSegment".into(),
2946 NodeMatcher::new(
2947 SyntaxKind::CreateIndexStatement,
2948 Sequence::new(vec_of_erased![
2949 Ref::keyword("CREATE"),
2950 Ref::new("OrReplaceGrammar").optional(),
2951 Ref::keyword("UNIQUE").optional(),
2952 Ref::keyword("INDEX"),
2953 Ref::new("IfNotExistsGrammar").optional(),
2954 Ref::new("IndexReferenceSegment"),
2955 Ref::keyword("ON"),
2956 Ref::new("TableReferenceSegment"),
2957 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![Ref::new(
2958 "IndexColumnDefinitionSegment"
2959 )])])
2960 ])
2961 .to_matchable(),
2962 )
2963 .to_matchable()
2964 .into(),
2965 ),
2966 (
2967 "DropIndexStatementSegment".into(),
2968 NodeMatcher::new(
2969 SyntaxKind::DropIndexStatement,
2970 Sequence::new(vec_of_erased![
2971 Ref::keyword("DROP"),
2972 Ref::keyword("INDEX"),
2973 Ref::new("IfExistsGrammar").optional(),
2974 Ref::new("IndexReferenceSegment"),
2975 Ref::new("DropBehaviorGrammar").optional()
2976 ])
2977 .to_matchable(),
2978 )
2979 .to_matchable()
2980 .into(),
2981 ),
2982 (
2983 "CreateTableStatementSegment".into(),
2984 NodeMatcher::new(
2985 SyntaxKind::CreateTableStatement,
2986 Sequence::new(vec_of_erased![
2987 Ref::keyword("CREATE"),
2988 Ref::new("OrReplaceGrammar").optional(),
2989 Ref::new("TemporaryTransientGrammar").optional(),
2990 Ref::keyword("TABLE"),
2991 Ref::new("IfNotExistsGrammar").optional(),
2992 Ref::new("TableReferenceSegment"),
2993 one_of(vec_of_erased![
2994 Sequence::new(vec_of_erased![
2996 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![one_of(
2997 vec_of_erased![
2998 Ref::new("TableConstraintSegment"),
2999 Ref::new("ColumnDefinitionSegment")
3000 ]
3001 )])]),
3002 Ref::new("CommentClauseSegment").optional()
3003 ]),
3004 Sequence::new(vec_of_erased![
3006 Ref::keyword("AS"),
3007 optionally_bracketed(vec_of_erased![Ref::new("SelectableGrammar")])
3008 ]),
3009 Sequence::new(vec_of_erased![
3011 Ref::keyword("LIKE"),
3012 Ref::new("TableReferenceSegment")
3013 ])
3014 ]),
3015 Ref::new("TableEndClauseSegment").optional()
3016 ])
3017 .to_matchable(),
3018 )
3019 .to_matchable()
3020 .into(),
3021 ),
3022 (
3023 "AccessStatementSegment".into(),
3024 NodeMatcher::new(
3025 SyntaxKind::AccessStatement,
3026 {
3027 let global_permissions = one_of(vec_of_erased![
3028 Sequence::new(vec_of_erased![
3029 Ref::keyword("CREATE"),
3030 one_of(vec_of_erased![
3031 Ref::keyword("ROLE"),
3032 Ref::keyword("USER"),
3033 Ref::keyword("WAREHOUSE"),
3034 Ref::keyword("DATABASE"),
3035 Ref::keyword("INTEGRATION"),
3036 ]),
3037 ]),
3038 Sequence::new(vec_of_erased![
3039 Ref::keyword("APPLY"),
3040 Ref::keyword("MASKING"),
3041 Ref::keyword("POLICY"),
3042 ]),
3043 Sequence::new(vec_of_erased![
3044 Ref::keyword("EXECUTE"),
3045 Ref::keyword("TASK")
3046 ]),
3047 Sequence::new(vec_of_erased![
3048 Ref::keyword("MANAGE"),
3049 Ref::keyword("GRANTS")
3050 ]),
3051 Sequence::new(vec_of_erased![
3052 Ref::keyword("MONITOR"),
3053 one_of(vec_of_erased![
3054 Ref::keyword("EXECUTION"),
3055 Ref::keyword("USAGE")
3056 ]),
3057 ]),
3058 ]);
3059
3060 let schema_object_types = one_of(vec_of_erased![
3061 Ref::keyword("TABLE"),
3062 Ref::keyword("VIEW"),
3063 Ref::keyword("STAGE"),
3064 Ref::keyword("FUNCTION"),
3065 Ref::keyword("PROCEDURE"),
3066 Ref::keyword("ROUTINE"),
3067 Ref::keyword("SEQUENCE"),
3068 Ref::keyword("STREAM"),
3069 Ref::keyword("TASK"),
3070 ]);
3071
3072 let permissions = Sequence::new(vec_of_erased![
3073 one_of(vec_of_erased![
3074 Sequence::new(vec_of_erased![
3075 Ref::keyword("CREATE"),
3076 one_of(vec_of_erased![
3077 Ref::keyword("SCHEMA"),
3078 Sequence::new(vec_of_erased![
3079 Ref::keyword("MASKING"),
3080 Ref::keyword("POLICY"),
3081 ]),
3082 Ref::keyword("PIPE"),
3083 schema_object_types.clone(),
3084 ]),
3085 ]),
3086 Sequence::new(vec_of_erased![
3087 Ref::keyword("IMPORTED"),
3088 Ref::keyword("PRIVILEGES")
3089 ]),
3090 Ref::keyword("APPLY"),
3091 Ref::keyword("CONNECT"),
3092 Ref::keyword("CREATE"),
3093 Ref::keyword("DELETE"),
3094 Ref::keyword("EXECUTE"),
3095 Ref::keyword("INSERT"),
3096 Ref::keyword("MODIFY"),
3097 Ref::keyword("MONITOR"),
3098 Ref::keyword("OPERATE"),
3099 Ref::keyword("OWNERSHIP"),
3100 Ref::keyword("READ"),
3101 Ref::keyword("REFERENCE_USAGE"),
3102 Ref::keyword("REFERENCES"),
3103 Ref::keyword("SELECT"),
3104 Ref::keyword("TEMP"),
3105 Ref::keyword("TEMPORARY"),
3106 Ref::keyword("TRIGGER"),
3107 Ref::keyword("TRUNCATE"),
3108 Ref::keyword("UPDATE"),
3109 Ref::keyword("USAGE"),
3110 Ref::keyword("USE_ANY_ROLE"),
3111 Ref::keyword("WRITE"),
3112 Sequence::new(vec_of_erased![
3113 Ref::keyword("ALL"),
3114 Ref::keyword("PRIVILEGES").optional(),
3115 ]),
3116 ]),
3117 Ref::new("BracketedColumnReferenceListGrammar").optional(),
3118 ]);
3119
3120 let objects = one_of(vec_of_erased![
3121 Ref::keyword("ACCOUNT"),
3122 Sequence::new(vec_of_erased![
3123 one_of(vec_of_erased![
3124 Sequence::new(vec_of_erased![
3125 Ref::keyword("RESOURCE"),
3126 Ref::keyword("MONITOR"),
3127 ]),
3128 Ref::keyword("WAREHOUSE"),
3129 Ref::keyword("DATABASE"),
3130 Ref::keyword("DOMAIN"),
3131 Ref::keyword("INTEGRATION"),
3132 Ref::keyword("LANGUAGE"),
3133 Ref::keyword("SCHEMA"),
3134 Ref::keyword("ROLE"),
3135 Ref::keyword("TABLESPACE"),
3136 Ref::keyword("TYPE"),
3137 Sequence::new(vec_of_erased![
3138 Ref::keyword("FOREIGN"),
3139 one_of(vec_of_erased![
3140 Ref::keyword("SERVER"),
3141 Sequence::new(vec_of_erased![
3142 Ref::keyword("DATA"),
3143 Ref::keyword("WRAPPER"),
3144 ]),
3145 ]),
3146 ]),
3147 Sequence::new(vec_of_erased![
3148 Ref::keyword("ALL"),
3149 Ref::keyword("SCHEMAS"),
3150 Ref::keyword("IN"),
3151 Ref::keyword("DATABASE"),
3152 ]),
3153 Sequence::new(vec_of_erased![
3154 Ref::keyword("FUTURE"),
3155 Ref::keyword("SCHEMAS"),
3156 Ref::keyword("IN"),
3157 Ref::keyword("DATABASE"),
3158 ]),
3159 schema_object_types.clone(),
3160 Sequence::new(vec_of_erased![
3161 Ref::keyword("ALL"),
3162 one_of(vec_of_erased![
3163 Ref::keyword("TABLES"),
3164 Ref::keyword("VIEWS"),
3165 Ref::keyword("STAGES"),
3166 Ref::keyword("FUNCTIONS"),
3167 Ref::keyword("PROCEDURES"),
3168 Ref::keyword("ROUTINES"),
3169 Ref::keyword("SEQUENCES"),
3170 Ref::keyword("STREAMS"),
3171 Ref::keyword("TASKS"),
3172 ]),
3173 Ref::keyword("IN"),
3174 Ref::keyword("SCHEMA"),
3175 ]),
3176 Sequence::new(vec_of_erased![
3177 Ref::keyword("FUTURE"),
3178 Ref::keyword("IN"),
3179 one_of(vec_of_erased![
3180 Ref::keyword("DATABASE"),
3181 Ref::keyword("SCHEMA")
3182 ]),
3183 ]),
3184 ])
3185 .config(|this| this.optional()),
3186 Delimited::new(vec_of_erased![
3187 Ref::new("ObjectReferenceSegment"),
3188 Sequence::new(vec_of_erased![
3189 Ref::new("FunctionNameSegment"),
3190 Ref::new("FunctionParameterListGrammar").optional(),
3191 ]),
3192 ])
3193 .config(|this| this.terminators =
3194 vec_of_erased![Ref::keyword("TO"), Ref::keyword("FROM")]),
3195 ]),
3196 Sequence::new(vec_of_erased![
3197 Ref::keyword("LARGE"),
3198 Ref::keyword("OBJECT"),
3199 Ref::new("NumericLiteralSegment"),
3200 ]),
3201 ]);
3202
3203 one_of(vec_of_erased![
3204 Sequence::new(vec_of_erased![
3205 Ref::keyword("GRANT"),
3206 one_of(vec_of_erased![
3207 Sequence::new(vec_of_erased![
3208 Delimited::new(vec_of_erased![one_of(vec_of_erased![
3209 global_permissions.clone(),
3210 permissions.clone()
3211 ])])
3212 .config(|this| this.terminators =
3213 vec_of_erased![Ref::keyword("ON")]),
3214 Ref::keyword("ON"),
3215 objects.clone()
3216 ]),
3217 Sequence::new(vec_of_erased![
3218 Ref::keyword("ROLE"),
3219 Ref::new("ObjectReferenceSegment")
3220 ]),
3221 Sequence::new(vec_of_erased![
3222 Ref::keyword("OWNERSHIP"),
3223 Ref::keyword("ON"),
3224 Ref::keyword("USER"),
3225 Ref::new("ObjectReferenceSegment"),
3226 ]),
3227 Ref::new("ObjectReferenceSegment")
3228 ]),
3229 Ref::keyword("TO"),
3230 one_of(vec_of_erased![
3231 Ref::keyword("GROUP"),
3232 Ref::keyword("USER"),
3233 Ref::keyword("ROLE"),
3234 Ref::keyword("SHARE")
3235 ])
3236 .config(|this| this.optional()),
3237 Delimited::new(vec_of_erased![one_of(vec_of_erased![
3238 Ref::new("RoleReferenceSegment"),
3239 Ref::new("FunctionSegment"),
3240 Ref::keyword("PUBLIC")
3241 ])]),
3242 one_of(vec_of_erased![
3243 Sequence::new(vec_of_erased![
3244 Ref::keyword("WITH"),
3245 Ref::keyword("GRANT"),
3246 Ref::keyword("OPTION"),
3247 ]),
3248 Sequence::new(vec_of_erased![
3249 Ref::keyword("WITH"),
3250 Ref::keyword("ADMIN"),
3251 Ref::keyword("OPTION"),
3252 ]),
3253 Sequence::new(vec_of_erased![
3254 Ref::keyword("COPY"),
3255 Ref::keyword("CURRENT"),
3256 Ref::keyword("GRANTS"),
3257 ])
3258 ])
3259 .config(|this| this.optional()),
3260 Sequence::new(vec_of_erased![
3261 Ref::keyword("GRANTED"),
3262 Ref::keyword("BY"),
3263 one_of(vec_of_erased![
3264 Ref::keyword("CURRENT_USER"),
3265 Ref::keyword("SESSION_USER"),
3266 Ref::new("ObjectReferenceSegment")
3267 ])
3268 ])
3269 .config(|this| this.optional())
3270 ]),
3271 Sequence::new(vec_of_erased![
3272 Ref::keyword("REVOKE"),
3273 Sequence::new(vec_of_erased![
3274 Ref::keyword("GRANT"),
3275 Ref::keyword("OPTION"),
3276 Ref::keyword("FOR")
3277 ])
3278 .config(|this| this.optional()),
3279 one_of(vec_of_erased![
3280 Sequence::new(vec_of_erased![
3281 Delimited::new(vec_of_erased![
3282 one_of(vec_of_erased![global_permissions, permissions])
3283 .config(|this| this.terminators =
3284 vec_of_erased![Ref::keyword("ON")])
3285 ]),
3286 Ref::keyword("ON"),
3287 objects
3288 ]),
3289 Sequence::new(vec_of_erased![
3290 Ref::keyword("ROLE"),
3291 Ref::new("ObjectReferenceSegment")
3292 ]),
3293 Sequence::new(vec_of_erased![
3294 Ref::keyword("OWNERSHIP"),
3295 Ref::keyword("ON"),
3296 Ref::keyword("USER"),
3297 Ref::new("ObjectReferenceSegment"),
3298 ]),
3299 Ref::new("ObjectReferenceSegment"),
3300 ]),
3301 Ref::keyword("FROM"),
3302 one_of(vec_of_erased![
3303 Ref::keyword("GROUP"),
3304 Ref::keyword("USER"),
3305 Ref::keyword("ROLE"),
3306 Ref::keyword("SHARE")
3307 ])
3308 .config(|this| this.optional()),
3309 Delimited::new(vec_of_erased![Ref::new("ObjectReferenceSegment")]),
3310 Ref::new("DropBehaviorGrammar").optional()
3311 ])
3312 ])
3313 }
3314 .to_matchable(),
3315 )
3316 .to_matchable()
3317 .into(),
3318 ),
3319 (
3320 "InsertStatementSegment".into(),
3321 NodeMatcher::new(
3322 SyntaxKind::InsertStatement,
3323 Sequence::new(vec_of_erased![
3324 Ref::keyword("INSERT"),
3325 Ref::keyword("OVERWRITE").optional(),
3326 Ref::keyword("INTO"),
3327 Ref::new("TableReferenceSegment"),
3328 one_of(vec_of_erased![
3329 Ref::new("SelectableGrammar"),
3330 Sequence::new(vec_of_erased![
3331 Ref::new("BracketedColumnReferenceListGrammar"),
3332 Ref::new("SelectableGrammar")
3333 ]),
3334 Ref::new("DefaultValuesGrammar")
3335 ])
3336 ])
3337 .to_matchable(),
3338 )
3339 .to_matchable()
3340 .into(),
3341 ),
3342 (
3343 "TransactionStatementSegment".into(),
3344 NodeMatcher::new(
3345 SyntaxKind::TransactionStatement,
3346 Sequence::new(vec_of_erased![
3347 one_of(vec_of_erased![
3348 Ref::keyword("START"),
3349 Ref::keyword("BEGIN"),
3350 Ref::keyword("COMMIT"),
3351 Ref::keyword("ROLLBACK"),
3352 Ref::keyword("END")
3353 ]),
3354 one_of(vec_of_erased![
3355 Ref::keyword("TRANSACTION"),
3356 Ref::keyword("WORK")
3357 ])
3358 .config(|this| this.optional()),
3359 Sequence::new(vec_of_erased![
3360 Ref::keyword("NAME"),
3361 Ref::new("SingleIdentifierGrammar")
3362 ])
3363 .config(|this| this.optional()),
3364 Sequence::new(vec_of_erased![
3365 Ref::keyword("AND"),
3366 Ref::keyword("NO").optional(),
3367 Ref::keyword("CHAIN")
3368 ])
3369 .config(|this| this.optional())
3370 ])
3371 .to_matchable(),
3372 )
3373 .to_matchable()
3374 .into(),
3375 ),
3376 (
3377 "DropTableStatementSegment".into(),
3378 NodeMatcher::new(
3379 SyntaxKind::DropTableStatement,
3380 Sequence::new(vec_of_erased![
3381 Ref::keyword("DROP"),
3382 Ref::new("TemporaryGrammar").optional(),
3383 Ref::keyword("TABLE"),
3384 Ref::new("IfExistsGrammar").optional(),
3385 Delimited::new(vec_of_erased![Ref::new("TableReferenceSegment")]),
3386 Ref::new("DropBehaviorGrammar").optional()
3387 ])
3388 .to_matchable(),
3389 )
3390 .to_matchable()
3391 .into(),
3392 ),
3393 (
3394 "DropViewStatementSegment".into(),
3395 NodeMatcher::new(
3396 SyntaxKind::DropViewStatement,
3397 Sequence::new(vec_of_erased![
3398 Ref::keyword("DROP"),
3399 Ref::keyword("VIEW"),
3400 Ref::new("IfExistsGrammar").optional(),
3401 Ref::new("TableReferenceSegment"),
3402 Ref::new("DropBehaviorGrammar").optional()
3403 ])
3404 .to_matchable(),
3405 )
3406 .to_matchable()
3407 .into(),
3408 ),
3409 (
3410 "CreateUserStatementSegment".into(),
3411 NodeMatcher::new(
3412 SyntaxKind::CreateUserStatement,
3413 Sequence::new(vec_of_erased![
3414 Ref::keyword("CREATE"),
3415 Ref::keyword("USER"),
3416 Ref::new("RoleReferenceSegment")
3417 ])
3418 .to_matchable(),
3419 )
3420 .to_matchable()
3421 .into(),
3422 ),
3423 (
3424 "DropUserStatementSegment".into(),
3425 NodeMatcher::new(
3426 SyntaxKind::DropUserStatement,
3427 Sequence::new(vec_of_erased![
3428 Ref::keyword("DROP"),
3429 Ref::keyword("USER"),
3430 Ref::new("IfExistsGrammar").optional(),
3431 Ref::new("RoleReferenceSegment")
3432 ])
3433 .to_matchable(),
3434 )
3435 .to_matchable()
3436 .into(),
3437 ),
3438 (
3439 "NotEqualToSegment".into(),
3440 NodeMatcher::new(
3441 SyntaxKind::ComparisonOperator,
3442 one_of(vec![
3443 Sequence::new(vec![
3444 Ref::new("RawNotSegment").to_matchable(),
3445 Ref::new("RawEqualsSegment").to_matchable(),
3446 ])
3447 .allow_gaps(false)
3448 .to_matchable(),
3449 Sequence::new(vec![
3450 Ref::new("RawLessThanSegment").to_matchable(),
3451 Ref::new("RawGreaterThanSegment").to_matchable(),
3452 ])
3453 .allow_gaps(false)
3454 .to_matchable(),
3455 ])
3456 .to_matchable(),
3457 )
3458 .to_matchable()
3459 .into(),
3460 ),
3461 (
3462 "ConcatSegment".into(),
3463 NodeMatcher::new(
3464 SyntaxKind::BinaryOperator,
3465 Sequence::new(vec![
3466 Ref::new("PipeSegment").to_matchable(),
3467 Ref::new("PipeSegment").to_matchable(),
3468 ])
3469 .allow_gaps(false)
3470 .to_matchable(),
3471 )
3472 .to_matchable()
3473 .into(),
3474 ),
3475 (
3476 "ArrayExpressionSegment".into(),
3477 NodeMatcher::new(SyntaxKind::ArrayExpression, Nothing::new().to_matchable())
3478 .to_matchable()
3479 .into(),
3480 ),
3481 (
3482 "LocalAliasSegment".into(),
3483 NodeMatcher::new(SyntaxKind::LocalAlias, Nothing::new().to_matchable())
3484 .to_matchable()
3485 .into(),
3486 ),
3487 (
3488 "MergeStatementSegment".into(),
3489 NodeMatcher::new(
3490 SyntaxKind::MergeStatement,
3491 Sequence::new(vec![
3492 Ref::new("MergeIntoLiteralGrammar").to_matchable(),
3493 MetaSegment::indent().to_matchable(),
3494 one_of(vec![
3495 Ref::new("TableReferenceSegment").to_matchable(),
3496 Ref::new("AliasedTableReferenceGrammar").to_matchable(),
3497 ])
3498 .to_matchable(),
3499 MetaSegment::dedent().to_matchable(),
3500 Ref::keyword("USING").to_matchable(),
3501 MetaSegment::indent().to_matchable(),
3502 one_of(vec![
3503 Ref::new("TableReferenceSegment").to_matchable(),
3504 Ref::new("AliasedTableReferenceGrammar").to_matchable(),
3505 Sequence::new(vec![
3506 Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
3507 .to_matchable(),
3508 Ref::new("AliasExpressionSegment").optional().to_matchable(),
3509 ])
3510 .to_matchable(),
3511 ])
3512 .to_matchable(),
3513 MetaSegment::dedent().to_matchable(),
3514 Conditional::new(MetaSegment::indent())
3515 .indented_using_on()
3516 .to_matchable(),
3517 Ref::new("JoinOnConditionSegment").to_matchable(),
3518 Conditional::new(MetaSegment::dedent())
3519 .indented_using_on()
3520 .to_matchable(),
3521 Ref::new("MergeMatchSegment").to_matchable(),
3522 ])
3523 .to_matchable(),
3524 )
3525 .to_matchable()
3526 .into(),
3527 ),
3528 (
3529 "IndexColumnDefinitionSegment".into(),
3530 NodeMatcher::new(
3531 SyntaxKind::IndexColumnDefinition,
3532 Sequence::new(vec![
3533 Ref::new("SingleIdentifierGrammar").to_matchable(), one_of(vec![
3535 Ref::keyword("ASC").to_matchable(),
3536 Ref::keyword("DESC").to_matchable(),
3537 ])
3538 .config(|this| this.optional())
3539 .to_matchable(),
3540 ])
3541 .to_matchable(),
3542 )
3543 .to_matchable()
3544 .into(),
3545 ),
3546 (
3547 "BitwiseAndSegment".into(),
3548 NodeMatcher::new(
3549 SyntaxKind::ComparisonOperator,
3550 Ref::new("AmpersandSegment").to_matchable(),
3551 )
3552 .to_matchable()
3553 .into(),
3554 ),
3555 (
3556 "BitwiseOrSegment".into(),
3557 NodeMatcher::new(
3558 SyntaxKind::ComparisonOperator,
3559 Ref::new("PipeSegment").to_matchable(),
3560 )
3561 .to_matchable()
3562 .into(),
3563 ),
3564 (
3565 "BitwiseLShiftSegment".into(),
3566 NodeMatcher::new(
3567 SyntaxKind::ComparisonOperator,
3568 Sequence::new(vec![
3569 Ref::new("RawLessThanSegment").to_matchable(),
3570 Ref::new("RawLessThanSegment").to_matchable(),
3571 ])
3572 .allow_gaps(false)
3573 .to_matchable(),
3574 )
3575 .to_matchable()
3576 .into(),
3577 ),
3578 (
3579 "BitwiseRShiftSegment".into(),
3580 NodeMatcher::new(
3581 SyntaxKind::ComparisonOperator,
3582 Sequence::new(vec![
3583 Ref::new("RawGreaterThanSegment").to_matchable(),
3584 Ref::new("RawGreaterThanSegment").to_matchable(),
3585 ])
3586 .allow_gaps(false)
3587 .to_matchable(),
3588 )
3589 .to_matchable()
3590 .into(),
3591 ),
3592 (
3593 "LessThanSegment".into(),
3594 NodeMatcher::new(
3595 SyntaxKind::ComparisonOperator,
3596 Ref::new("RawLessThanSegment").to_matchable(),
3597 )
3598 .to_matchable()
3599 .into(),
3600 ),
3601 (
3602 "GreaterThanOrEqualToSegment".into(),
3603 NodeMatcher::new(
3604 SyntaxKind::ComparisonOperator,
3605 Sequence::new(vec![
3606 Ref::new("RawGreaterThanSegment").to_matchable(),
3607 Ref::new("RawEqualsSegment").to_matchable(),
3608 ])
3609 .allow_gaps(false)
3610 .to_matchable(),
3611 )
3612 .to_matchable()
3613 .into(),
3614 ),
3615 (
3616 "LessThanOrEqualToSegment".into(),
3617 NodeMatcher::new(
3618 SyntaxKind::ComparisonOperator,
3619 Sequence::new(vec![
3620 Ref::new("RawLessThanSegment").to_matchable(),
3621 Ref::new("RawEqualsSegment").to_matchable(),
3622 ])
3623 .allow_gaps(false)
3624 .to_matchable(),
3625 )
3626 .to_matchable()
3627 .into(),
3628 ),
3629 (
3630 "EqualsSegment".into(),
3631 NodeMatcher::new(
3632 SyntaxKind::ComparisonOperator,
3633 Ref::new("RawEqualsSegment").to_matchable(),
3634 )
3635 .to_matchable()
3636 .into(),
3637 ),
3638 (
3639 "GreaterThanSegment".into(),
3640 NodeMatcher::new(
3641 SyntaxKind::ComparisonOperator,
3642 Ref::new("RawGreaterThanSegment").to_matchable(),
3643 )
3644 .to_matchable()
3645 .into(),
3646 ),
3647 (
3648 "QualifiedNumericLiteralSegment".into(),
3649 NodeMatcher::new(
3650 SyntaxKind::NumericLiteral,
3651 Sequence::new(vec![
3652 Ref::new("SignedSegmentGrammar").to_matchable(),
3653 Ref::new("NumericLiteralSegment").to_matchable(),
3654 ])
3655 .to_matchable(),
3656 )
3657 .to_matchable()
3658 .into(),
3659 ),
3660 (
3661 "AggregateOrderByClause".into(),
3662 NodeMatcher::new(
3663 SyntaxKind::AggregateOrderByClause,
3664 Ref::new("OrderByClauseSegment").to_matchable(),
3665 )
3666 .to_matchable()
3667 .into(),
3668 ),
3669 (
3670 "FunctionNameSegment".into(),
3671 NodeMatcher::new(
3672 SyntaxKind::FunctionName,
3673 Sequence::new(vec_of_erased![
3674 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
3675 Ref::new("SingleIdentifierGrammar"),
3676 Ref::new("DotSegment")
3677 ])])
3678 .config(|this| this.terminators = vec_of_erased![Ref::new("BracketedSegment")]),
3679 one_of(vec_of_erased![
3680 Ref::new("FunctionNameIdentifierSegment"),
3681 Ref::new("QuotedIdentifierSegment")
3682 ])
3683 ])
3684 .terminators(vec_of_erased![Ref::new("BracketedSegment")])
3685 .allow_gaps(false)
3686 .to_matchable(),
3687 )
3688 .to_matchable()
3689 .into(),
3690 ),
3691 (
3692 "CaseExpressionSegment".into(),
3693 NodeMatcher::new(
3694 SyntaxKind::CaseExpression,
3695 one_of(vec_of_erased![
3696 Sequence::new(vec_of_erased![
3697 Ref::keyword("CASE"),
3698 MetaSegment::implicit_indent(),
3699 AnyNumberOf::new(vec_of_erased![Ref::new("WhenClauseSegment")],).config(
3700 |this| {
3701 this.reset_terminators = true;
3702 this.terminators =
3703 vec_of_erased![Ref::keyword("ELSE"), Ref::keyword("END")];
3704 }
3705 ),
3706 Ref::new("ElseClauseSegment").optional(),
3707 MetaSegment::dedent(),
3708 Ref::keyword("END"),
3709 ]),
3710 Sequence::new(vec_of_erased![
3711 Ref::keyword("CASE"),
3712 Ref::new("ExpressionSegment"),
3713 MetaSegment::implicit_indent(),
3714 AnyNumberOf::new(vec_of_erased![Ref::new("WhenClauseSegment")],).config(
3715 |this| {
3716 this.reset_terminators = true;
3717 this.terminators =
3718 vec_of_erased![Ref::keyword("ELSE"), Ref::keyword("END")];
3719 }
3720 ),
3721 Ref::new("ElseClauseSegment").optional(),
3722 MetaSegment::dedent(),
3723 Ref::keyword("END"),
3724 ]),
3725 ])
3726 .config(|this| {
3727 this.terminators = vec_of_erased![
3728 Ref::new("ComparisonOperatorGrammar"),
3729 Ref::new("CommaSegment"),
3730 Ref::new("BinaryOperatorGrammar")
3731 ]
3732 })
3733 .to_matchable(),
3734 )
3735 .to_matchable()
3736 .into(),
3737 ),
3738 (
3739 "WhenClauseSegment".into(),
3740 NodeMatcher::new(
3741 SyntaxKind::WhenClause,
3742 Sequence::new(vec_of_erased![
3743 Ref::keyword("WHEN"),
3744 Sequence::new(vec_of_erased![
3745 MetaSegment::implicit_indent(),
3746 Ref::new("ExpressionSegment"),
3747 MetaSegment::dedent(),
3748 ]),
3749 Conditional::new(MetaSegment::indent()).indented_then(),
3750 Ref::keyword("THEN"),
3751 Conditional::new(MetaSegment::implicit_indent()).indented_then_contents(),
3752 Ref::new("ExpressionSegment"),
3753 Conditional::new(MetaSegment::dedent()).indented_then_contents(),
3754 Conditional::new(MetaSegment::dedent()).indented_then(),
3755 ])
3756 .to_matchable(),
3757 )
3758 .to_matchable()
3759 .into(),
3760 ),
3761 (
3762 "ElseClauseSegment".into(),
3763 NodeMatcher::new(
3764 SyntaxKind::ElseClause,
3765 Sequence::new(vec![
3766 Ref::keyword("ELSE").to_matchable(),
3767 MetaSegment::implicit_indent().to_matchable(),
3768 Ref::new("ExpressionSegment").to_matchable(),
3769 MetaSegment::dedent().to_matchable(),
3770 ])
3771 .to_matchable(),
3772 )
3773 .to_matchable()
3774 .into(),
3775 ),
3776 (
3777 "WhereClauseSegment".into(),
3778 NodeMatcher::new(
3779 SyntaxKind::WhereClause,
3780 Sequence::new(vec_of_erased![
3781 Ref::keyword("WHERE"),
3782 MetaSegment::implicit_indent(),
3783 optionally_bracketed(vec_of_erased![Ref::new("ExpressionSegment")]),
3784 MetaSegment::dedent()
3785 ])
3786 .to_matchable(),
3787 )
3788 .to_matchable()
3789 .into(),
3790 ),
3791 (
3792 "SetOperatorSegment".into(),
3793 NodeMatcher::new(
3794 SyntaxKind::SetOperator,
3795 one_of(vec_of_erased![
3796 Ref::new("UnionGrammar"),
3797 Sequence::new(vec_of_erased![
3798 one_of(vec_of_erased![
3799 Ref::keyword("INTERSECT"),
3800 Ref::keyword("EXCEPT")
3801 ]),
3802 Ref::keyword("ALL").optional(),
3803 ]),
3804 Ref::keyword("MINUS"),
3805 ])
3806 .to_matchable(),
3807 )
3808 .to_matchable()
3809 .into(),
3810 ),
3811 (
3812 "ValuesClauseSegment".into(),
3813 NodeMatcher::new(
3814 SyntaxKind::ValuesClause,
3815 Sequence::new(vec![
3816 one_of(vec![
3817 Ref::keyword("VALUE").to_matchable(),
3818 Ref::keyword("VALUES").to_matchable(),
3819 ])
3820 .to_matchable(),
3821 Delimited::new(vec![
3822 Sequence::new(vec![
3823 Ref::keyword("ROW").optional().to_matchable(),
3824 Bracketed::new(vec![
3825 Delimited::new(vec![
3826 Ref::keyword("DEFAULT").to_matchable(),
3827 Ref::new("LiteralGrammar").to_matchable(),
3828 Ref::new("ExpressionSegment").to_matchable(),
3829 ])
3830 .to_matchable(),
3831 ])
3832 .config(|this| this.parse_mode(ParseMode::Greedy))
3833 .to_matchable(),
3834 ])
3835 .to_matchable(),
3836 ])
3837 .to_matchable(),
3838 ])
3839 .to_matchable(),
3840 )
3841 .to_matchable()
3842 .into(),
3843 ),
3844 (
3845 "EmptyStructLiteralSegment".into(),
3846 NodeMatcher::new(
3847 SyntaxKind::EmptyStructLiteral,
3848 Sequence::new(vec![
3849 Ref::new("StructTypeSegment").to_matchable(),
3850 Ref::new("EmptyStructLiteralBracketsSegment").to_matchable(),
3851 ])
3852 .to_matchable(),
3853 )
3854 .to_matchable()
3855 .into(),
3856 ),
3857 (
3858 "ObjectLiteralSegment".into(),
3859 NodeMatcher::new(
3860 SyntaxKind::ObjectLiteral,
3861 Bracketed::new(vec![
3862 Delimited::new(vec![Ref::new("ObjectLiteralElementSegment").to_matchable()])
3863 .config(|this| {
3864 this.optional();
3865 })
3866 .to_matchable(),
3867 ])
3868 .config(|this| {
3869 this.bracket_type("curly");
3870 })
3871 .to_matchable(),
3872 )
3873 .to_matchable()
3874 .into(),
3875 ),
3876 (
3877 "ObjectLiteralElementSegment".into(),
3878 NodeMatcher::new(
3879 SyntaxKind::ObjectLiteralElement,
3880 Sequence::new(vec![
3881 Ref::new("QuotedLiteralSegment").to_matchable(),
3882 Ref::new("ColonSegment").to_matchable(),
3883 Ref::new("BaseExpressionElementGrammar").to_matchable(),
3884 ])
3885 .to_matchable(),
3886 )
3887 .to_matchable()
3888 .into(),
3889 ),
3890 (
3891 "TimeZoneGrammar".into(),
3892 NodeMatcher::new(
3893 SyntaxKind::TimeZoneGrammar,
3894 AnyNumberOf::new(vec![
3895 Sequence::new(vec![
3896 Ref::keyword("AT").to_matchable(),
3897 Ref::keyword("TIME").to_matchable(),
3898 Ref::keyword("ZONE").to_matchable(),
3899 Ref::new("ExpressionSegment").to_matchable(),
3900 ])
3901 .to_matchable(),
3902 ])
3903 .to_matchable(),
3904 )
3905 .to_matchable()
3906 .into(),
3907 ),
3908 (
3909 "BracketedArguments".into(),
3910 NodeMatcher::new(
3911 SyntaxKind::BracketedArguments,
3912 Bracketed::new(vec![
3913 Delimited::new(vec![Ref::new("LiteralGrammar").to_matchable()])
3914 .config(|this| {
3915 this.optional();
3916 })
3917 .to_matchable(),
3918 ])
3919 .to_matchable(),
3920 )
3921 .to_matchable()
3922 .into(),
3923 ),
3924 (
3925 "DatatypeSegment".into(),
3926 NodeMatcher::new(
3927 SyntaxKind::DataType,
3928 one_of(vec_of_erased![
3929 Sequence::new(vec_of_erased![
3930 one_of(vec_of_erased![
3931 Ref::keyword("TIME"),
3932 Ref::keyword("TIMESTAMP")
3933 ]),
3934 Bracketed::new(vec_of_erased![Ref::new("NumericLiteralSegment")])
3935 .config(|this| this.optional()),
3936 Sequence::new(vec_of_erased![
3937 one_of(vec_of_erased![
3938 Ref::keyword("WITH"),
3939 Ref::keyword("WITHOUT")
3940 ]),
3941 Ref::keyword("TIME"),
3942 Ref::keyword("ZONE"),
3943 ])
3944 .config(|this| this.optional()),
3945 ]),
3946 Sequence::new(vec_of_erased![
3947 Ref::keyword("DOUBLE"),
3948 Ref::keyword("PRECISION")
3949 ]),
3950 Sequence::new(vec_of_erased![
3951 one_of(vec_of_erased![
3952 Sequence::new(vec_of_erased![
3953 one_of(vec_of_erased![
3954 Ref::keyword("CHARACTER"),
3955 Ref::keyword("BINARY")
3956 ]),
3957 one_of(vec_of_erased![
3958 Ref::keyword("VARYING"),
3959 Sequence::new(vec_of_erased![
3960 Ref::keyword("LARGE"),
3961 Ref::keyword("OBJECT"),
3962 ]),
3963 ]),
3964 ]),
3965 Sequence::new(vec_of_erased![
3966 Sequence::new(vec_of_erased![
3967 Ref::new("SingleIdentifierGrammar"),
3968 Ref::new("DotSegment"),
3969 ])
3970 .config(|this| this.optional()),
3971 Ref::new("DatatypeIdentifierSegment"),
3972 ]),
3973 ]),
3974 Ref::new("BracketedArguments").optional(),
3975 one_of(vec_of_erased![
3976 Ref::keyword("UNSIGNED"),
3977 Ref::new("CharCharacterSetGrammar"),
3978 ])
3979 .config(|config| config.optional()),
3980 ]),
3981 ])
3982 .to_matchable(),
3983 )
3984 .to_matchable()
3985 .into(),
3986 ),
3987 (
3988 "AliasExpressionSegment".into(),
3989 NodeMatcher::new(
3990 SyntaxKind::AliasExpression,
3991 Sequence::new(vec_of_erased![
3992 MetaSegment::indent(),
3993 Ref::keyword("AS").optional(),
3994 one_of(vec_of_erased![
3995 Sequence::new(vec_of_erased![
3996 Ref::new("SingleIdentifierGrammar"),
3997 Bracketed::new(vec_of_erased![Ref::new("SingleIdentifierListSegment")])
3998 .config(|this| this.optional())
3999 ]),
4000 Ref::new("SingleQuotedIdentifierSegment")
4001 ]),
4002 MetaSegment::dedent(),
4003 ])
4004 .to_matchable(),
4005 )
4006 .to_matchable()
4007 .into(),
4008 ),
4009 (
4010 "ShorthandCastSegment".into(),
4011 NodeMatcher::new(
4012 SyntaxKind::CastExpression,
4013 Sequence::new(vec_of_erased![
4014 one_of(vec_of_erased![
4015 Ref::new("Expression_D_Grammar"),
4016 Ref::new("CaseExpressionSegment")
4017 ]),
4018 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
4019 Ref::new("CastOperatorSegment"),
4020 Ref::new("DatatypeSegment"),
4021 Ref::new("TimeZoneGrammar").optional()
4022 ]),])
4023 .config(|this| this.min_times(1)),
4024 ])
4025 .to_matchable(),
4026 )
4027 .to_matchable()
4028 .into(),
4029 ),
4030 (
4031 "ArrayAccessorSegment".into(),
4032 NodeMatcher::new(
4033 SyntaxKind::ArrayAccessor,
4034 Bracketed::new(vec![
4035 Delimited::new(vec![
4036 one_of(vec![
4037 Ref::new("NumericLiteralSegment").to_matchable(),
4038 Ref::new("ExpressionSegment").to_matchable(),
4039 ])
4040 .to_matchable(),
4041 ])
4042 .config(|this| this.delimiter(Ref::new("SliceSegment")))
4043 .to_matchable(),
4044 ])
4045 .config(|this| {
4046 this.bracket_type("square");
4047 this.parse_mode(ParseMode::Greedy);
4048 })
4049 .to_matchable(),
4050 )
4051 .to_matchable()
4052 .into(),
4053 ),
4054 (
4055 "ArrayLiteralSegment".into(),
4056 NodeMatcher::new(
4057 SyntaxKind::ArrayLiteral,
4058 Bracketed::new(vec_of_erased![
4059 Delimited::new(vec_of_erased![Ref::new("BaseExpressionElementGrammar")])
4060 .config(|this| {
4061 this.delimiter(Ref::new("CommaSegment"));
4062 this.optional();
4063 }),
4064 ])
4065 .config(|this| {
4066 this.bracket_type("square");
4067 this.parse_mode(ParseMode::Greedy);
4068 })
4069 .to_matchable(),
4070 )
4071 .to_matchable()
4072 .into(),
4073 ),
4074 (
4075 "TypedArrayLiteralSegment".into(),
4076 NodeMatcher::new(
4077 SyntaxKind::TypedArrayLiteral,
4078 Sequence::new(vec![
4079 Ref::new("ArrayTypeSegment").to_matchable(),
4080 Ref::new("ArrayLiteralSegment").to_matchable(),
4081 ])
4082 .to_matchable(),
4083 )
4084 .to_matchable()
4085 .into(),
4086 ),
4087 (
4088 "StructTypeSegment".into(),
4089 NodeMatcher::new(SyntaxKind::StructType, Nothing::new().to_matchable())
4090 .to_matchable()
4091 .into(),
4092 ),
4093 (
4094 "StructLiteralSegment".into(),
4095 NodeMatcher::new(
4096 SyntaxKind::StructLiteral,
4097 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
4098 Sequence::new(vec_of_erased![
4099 Ref::new("BaseExpressionElementGrammar"),
4100 Ref::new("AliasExpressionSegment").optional(),
4101 ])
4102 ])])
4103 .to_matchable(),
4104 )
4105 .to_matchable()
4106 .into(),
4107 ),
4108 (
4109 "TypedStructLiteralSegment".into(),
4110 NodeMatcher::new(
4111 SyntaxKind::TypedStructLiteral,
4112 Sequence::new(vec![
4113 Ref::new("StructTypeSegment").to_matchable(),
4114 Ref::new("StructLiteralSegment").to_matchable(),
4115 ])
4116 .to_matchable(),
4117 )
4118 .to_matchable()
4119 .into(),
4120 ),
4121 (
4122 "IntervalExpressionSegment".into(),
4123 NodeMatcher::new(
4124 SyntaxKind::IntervalExpression,
4125 Sequence::new(vec![
4126 Ref::keyword("INTERVAL").to_matchable(),
4127 one_of(vec![
4128 Sequence::new(vec![
4129 Ref::new("NumericLiteralSegment").to_matchable(),
4130 one_of(vec![
4131 Ref::new("QuotedLiteralSegment").to_matchable(),
4132 Ref::new("DatetimeUnitSegment").to_matchable(),
4133 ])
4134 .to_matchable(),
4135 ])
4136 .to_matchable(),
4137 Ref::new("QuotedLiteralSegment").to_matchable(),
4138 ])
4139 .to_matchable(),
4140 ])
4141 .to_matchable(),
4142 )
4143 .to_matchable()
4144 .into(),
4145 ),
4146 (
4147 "ArrayTypeSegment".into(),
4148 NodeMatcher::new(SyntaxKind::ArrayType, Nothing::new().to_matchable())
4149 .to_matchable()
4150 .into(),
4151 ),
4152 (
4153 "SizedArrayTypeSegment".into(),
4154 NodeMatcher::new(
4155 SyntaxKind::SizedArrayType,
4156 Sequence::new(vec![
4157 Ref::new("ArrayTypeSegment").to_matchable(),
4158 Ref::new("ArrayAccessorSegment").to_matchable(),
4159 ])
4160 .to_matchable(),
4161 )
4162 .to_matchable()
4163 .into(),
4164 ),
4165 (
4166 "UnorderedSelectStatementSegment".into(),
4167 NodeMatcher::new(
4168 SyntaxKind::SelectStatement,
4169 Sequence::new(vec_of_erased![
4170 Ref::new("SelectClauseSegment"),
4171 MetaSegment::dedent(),
4172 Ref::new("FromClauseSegment").optional(),
4173 Ref::new("WhereClauseSegment").optional(),
4174 Ref::new("GroupByClauseSegment").optional(),
4175 Ref::new("HavingClauseSegment").optional(),
4176 Ref::new("OverlapsClauseSegment").optional(),
4177 Ref::new("NamedWindowSegment").optional()
4178 ])
4179 .terminators(vec_of_erased![
4180 Ref::new("SetOperatorSegment"),
4181 Ref::new("WithNoSchemaBindingClauseSegment"),
4182 Ref::new("WithDataClauseSegment"),
4183 Ref::new("OrderByClauseSegment"),
4184 Ref::new("LimitClauseSegment")
4185 ])
4186 .config(|this| {
4187 this.parse_mode(ParseMode::GreedyOnceStarted);
4188 })
4189 .to_matchable(),
4190 )
4191 .to_matchable()
4192 .into(),
4193 ),
4194 (
4195 "OverlapsClauseSegment".into(),
4196 NodeMatcher::new(
4197 SyntaxKind::OverlapsClause,
4198 Sequence::new(vec_of_erased![
4199 Ref::keyword("OVERLAPS"),
4200 one_of(vec_of_erased![
4201 Bracketed::new(vec_of_erased![
4202 Ref::new("DateTimeLiteralGrammar"),
4203 Ref::new("CommaSegment"),
4204 Ref::new("DateTimeLiteralGrammar"),
4205 ]),
4206 Ref::new("ColumnReferenceSegment"),
4207 ]),
4208 ])
4209 .to_matchable(),
4210 )
4211 .to_matchable()
4212 .into(),
4213 ),
4214 ("SelectClauseSegment".into(), {
4215 NodeMatcher::new(SyntaxKind::SelectClause, select_clause_segment())
4216 .to_matchable()
4217 .into()
4218 }),
4219 (
4220 "StatementSegment".into(),
4221 NodeMatcher::new(SyntaxKind::Statement, statement_segment())
4222 .to_matchable()
4223 .into(),
4224 ),
4225 (
4226 "WithNoSchemaBindingClauseSegment".into(),
4227 NodeMatcher::new(
4228 SyntaxKind::WithNoSchemaBindingClause,
4229 Sequence::new(vec_of_erased![
4230 Ref::keyword("WITH"),
4231 Ref::keyword("NO"),
4232 Ref::keyword("SCHEMA"),
4233 Ref::keyword("BINDING"),
4234 ])
4235 .to_matchable(),
4236 )
4237 .to_matchable()
4238 .into(),
4239 ),
4240 (
4241 "WithDataClauseSegment".into(),
4242 NodeMatcher::new(
4243 SyntaxKind::WithDataClause,
4244 Sequence::new(vec_of_erased![
4245 Ref::keyword("WITH"),
4246 Sequence::new(vec_of_erased![Ref::keyword("NO")])
4247 .config(|this| this.optional()),
4248 Ref::keyword("DATA"),
4249 ])
4250 .to_matchable(),
4251 )
4252 .to_matchable()
4253 .into(),
4254 ),
4255 (
4256 "SetExpressionSegment".into(),
4257 NodeMatcher::new(
4258 SyntaxKind::SetExpression,
4259 Sequence::new(vec_of_erased![
4260 Ref::new("NonSetSelectableGrammar"),
4261 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
4262 Ref::new("SetOperatorSegment"),
4263 Ref::new("NonSetSelectableGrammar"),
4264 ])])
4265 .config(|this| this.min_times(1)),
4266 Ref::new("OrderByClauseSegment").optional(),
4267 Ref::new("LimitClauseSegment").optional(),
4268 Ref::new("NamedWindowSegment").optional(),
4269 ])
4270 .to_matchable(),
4271 )
4272 .to_matchable()
4273 .into(),
4274 ),
4275 (
4276 "FromClauseSegment".into(),
4277 NodeMatcher::new(
4278 SyntaxKind::FromClause,
4279 Sequence::new(vec_of_erased![
4280 Ref::keyword("FROM"),
4281 Delimited::new(vec_of_erased![Ref::new("FromExpressionSegment")]),
4282 ])
4283 .to_matchable(),
4284 )
4285 .to_matchable()
4286 .into(),
4287 ),
4288 (
4289 "EmptyStructLiteralBracketsSegment".into(),
4290 NodeMatcher::new(
4291 SyntaxKind::EmptyStructLiteralBrackets,
4292 Bracketed::new(vec![]).to_matchable(),
4293 )
4294 .to_matchable()
4295 .into(),
4296 ),
4297 (
4298 "WildcardExpressionSegment".into(),
4299 NodeMatcher::new(
4300 SyntaxKind::WildcardExpression,
4301 wildcard_expression_segment(),
4302 )
4303 .to_matchable()
4304 .into(),
4305 ),
4306 (
4307 "OrderByClauseSegment".into(),
4308 NodeMatcher::new(
4309 SyntaxKind::OrderbyClause,
4310 Sequence::new(vec_of_erased![
4311 Ref::keyword("ORDER"),
4312 Ref::keyword("BY"),
4313 MetaSegment::indent(),
4314 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
4315 one_of(vec_of_erased![
4316 Ref::new("ColumnReferenceSegment"),
4317 Ref::new("NumericLiteralSegment"),
4318 Ref::new("ExpressionSegment"),
4319 ]),
4320 one_of(vec_of_erased![Ref::keyword("ASC"), Ref::keyword("DESC"),])
4321 .config(|this| this.optional()),
4322 Sequence::new(vec_of_erased![
4323 Ref::keyword("NULLS"),
4324 one_of(vec_of_erased![Ref::keyword("FIRST"), Ref::keyword("LAST"),]),
4325 ])
4326 .config(|this| this.optional()),
4327 ])])
4328 .config(|this| this.terminators =
4329 vec_of_erased![Ref::keyword("LIMIT"), Ref::new("FrameClauseUnitGrammar")]),
4330 MetaSegment::dedent(),
4331 ])
4332 .to_matchable(),
4333 )
4334 .to_matchable()
4335 .into(),
4336 ),
4337 (
4338 "TruncateStatementSegment".into(),
4339 NodeMatcher::new(
4340 SyntaxKind::TruncateStatement,
4341 Sequence::new(vec![
4342 Ref::keyword("TRUNCATE").to_matchable(),
4343 Ref::keyword("TABLE").optional().to_matchable(),
4344 Ref::new("TableReferenceSegment").to_matchable(),
4345 ])
4346 .to_matchable(),
4347 )
4348 .to_matchable()
4349 .into(),
4350 ),
4351 (
4352 "FromExpressionSegment".into(),
4353 NodeMatcher::new(
4354 SyntaxKind::FromExpression,
4355 optionally_bracketed(vec_of_erased![Sequence::new(vec_of_erased![
4356 MetaSegment::indent(),
4357 one_of(vec_of_erased![
4358 Ref::new("FromExpressionElementSegment"),
4359 Bracketed::new(vec_of_erased![Ref::new("FromExpressionSegment")])
4360 ])
4361 .config(|this| this.terminators = vec_of_erased![
4362 Sequence::new(vec_of_erased![Ref::keyword("ORDER"), Ref::keyword("BY")]),
4363 Sequence::new(vec_of_erased![Ref::keyword("GROUP"), Ref::keyword("BY")]),
4364 ]),
4365 MetaSegment::dedent(),
4366 Conditional::new(MetaSegment::indent()).indented_joins(),
4367 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
4368 one_of(vec_of_erased![
4369 Ref::new("JoinClauseSegment"),
4370 Ref::new("JoinLikeClauseGrammar")
4371 ])
4372 .config(|this| {
4373 this.optional();
4374 this.terminators = vec_of_erased![
4375 Sequence::new(vec_of_erased![
4376 Ref::keyword("ORDER"),
4377 Ref::keyword("BY")
4378 ]),
4379 Sequence::new(vec_of_erased![
4380 Ref::keyword("GROUP"),
4381 Ref::keyword("BY")
4382 ]),
4383 ];
4384 })
4385 ])]),
4386 Conditional::new(MetaSegment::dedent()).indented_joins(),
4387 ])])
4388 .to_matchable(),
4389 )
4390 .to_matchable()
4391 .into(),
4392 ),
4393 (
4394 "DatePartFunctionNameSegment".into(),
4395 NodeMatcher::new(
4396 SyntaxKind::FunctionName,
4397 Ref::new("DatePartFunctionName").to_matchable(),
4398 )
4399 .to_matchable()
4400 .into(),
4401 ),
4402 (
4403 "FromExpressionElementSegment".into(),
4404 NodeMatcher::new(
4405 SyntaxKind::FromExpressionElement,
4406 Sequence::new(vec_of_erased![
4407 Ref::new("PreTableFunctionKeywordsGrammar").optional(),
4408 optionally_bracketed(vec_of_erased![Ref::new("TableExpressionSegment")]),
4409 Ref::new("AliasExpressionSegment")
4410 .exclude(one_of(vec_of_erased![
4411 Ref::new("FromClauseTerminatorGrammar"),
4412 Ref::new("SamplingExpressionSegment"),
4413 Ref::new("JoinLikeClauseGrammar")
4414 ]))
4415 .optional(),
4416 Sequence::new(vec_of_erased![
4417 Ref::keyword("WITH"),
4418 Ref::keyword("OFFSET"),
4419 Ref::new("AliasExpressionSegment")
4420 ])
4421 .config(|this| this.optional()),
4422 Ref::new("SamplingExpressionSegment").optional(),
4423 Ref::new("PostTableExpressionGrammar").optional()
4424 ])
4425 .to_matchable(),
4426 )
4427 .to_matchable()
4428 .into(),
4429 ),
4430 (
4431 "SelectStatementSegment".into(),
4432 NodeMatcher::new(SyntaxKind::SelectStatement, select_statement())
4433 .to_matchable()
4434 .into(),
4435 ),
4436 (
4437 "CreateSchemaStatementSegment".into(),
4438 NodeMatcher::new(
4439 SyntaxKind::CreateSchemaStatement,
4440 Sequence::new(vec_of_erased![
4441 Ref::keyword("CREATE"),
4442 Ref::keyword("SCHEMA"),
4443 Ref::new("IfNotExistsGrammar").optional(),
4444 Ref::new("SchemaReferenceSegment")
4445 ])
4446 .to_matchable(),
4447 )
4448 .to_matchable()
4449 .into(),
4450 ),
4451 (
4452 "SelectClauseModifierSegment".into(),
4453 NodeMatcher::new(
4454 SyntaxKind::SelectClauseModifier,
4455 one_of(vec![
4456 Ref::keyword("DISTINCT").to_matchable(),
4457 Ref::keyword("ALL").to_matchable(),
4458 ])
4459 .to_matchable(),
4460 )
4461 .to_matchable()
4462 .into(),
4463 ),
4464 (
4465 "SelectClauseElementSegment".into(),
4466 NodeMatcher::new(SyntaxKind::SelectClauseElement, select_clause_element())
4467 .to_matchable()
4468 .into(),
4469 ),
4470 ]);
4471
4472 ansi_dialect.add([(
4474 "CharCharacterSetGrammar".into(),
4475 Nothing::new().to_matchable().into(),
4476 )]);
4477
4478 ansi_dialect.add([(
4480 "AliasedTableReferenceGrammar".into(),
4481 Sequence::new(vec_of_erased![
4482 Ref::new("TableReferenceSegment"),
4483 Ref::new("AliasExpressionSegment"),
4484 ])
4485 .to_matchable()
4486 .into(),
4487 )]);
4488
4489 ansi_dialect.add([
4490 (
4492 "FunctionContentsExpressionGrammar".into(),
4493 Ref::new("ExpressionSegment").to_matchable().into(),
4494 ),
4495 (
4496 "FunctionContentsGrammar".into(),
4497 AnyNumberOf::new(vec![
4498 Ref::new("ExpressionSegment").to_matchable(),
4499 Sequence::new(vec![
4501 Ref::new("ExpressionSegment").to_matchable(),
4502 Ref::keyword("AS").to_matchable(),
4503 Ref::new("DatatypeSegment").to_matchable(),
4504 ])
4505 .to_matchable(),
4506 Sequence::new(vec![
4508 Ref::new("TrimParametersGrammar").to_matchable(),
4509 Ref::new("ExpressionSegment")
4510 .optional()
4511 .exclude(Ref::keyword("FROM"))
4512 .to_matchable(),
4513 Ref::keyword("FROM").to_matchable(),
4514 Ref::new("ExpressionSegment").to_matchable(),
4515 ])
4516 .to_matchable(),
4517 Sequence::new(vec![
4519 one_of(vec![
4520 Ref::new("DatetimeUnitSegment").to_matchable(),
4521 Ref::new("ExpressionSegment").to_matchable(),
4522 ])
4523 .to_matchable(),
4524 Ref::keyword("FROM").to_matchable(),
4525 Ref::new("ExpressionSegment").to_matchable(),
4526 ])
4527 .to_matchable(),
4528 Sequence::new(vec![
4529 Ref::keyword("DISTINCT").optional().to_matchable(),
4531 one_of(vec![
4532 Ref::new("StarSegment").to_matchable(),
4534 Delimited::new(vec![
4535 Ref::new("FunctionContentsExpressionGrammar").to_matchable(),
4536 ])
4537 .to_matchable(),
4538 ])
4539 .to_matchable(),
4540 ])
4541 .to_matchable(),
4542 Ref::new("AggregateOrderByClause").to_matchable(), Sequence::new(vec![
4544 Ref::keyword("SEPARATOR").to_matchable(),
4545 Ref::new("LiteralGrammar").to_matchable(),
4546 ])
4547 .to_matchable(),
4548 Sequence::new(vec![
4550 one_of(vec![
4551 Ref::new("QuotedLiteralSegment").to_matchable(),
4552 Ref::new("SingleIdentifierGrammar").to_matchable(),
4553 Ref::new("ColumnReferenceSegment").to_matchable(),
4554 ])
4555 .to_matchable(),
4556 Ref::keyword("IN").to_matchable(),
4557 one_of(vec![
4558 Ref::new("QuotedLiteralSegment").to_matchable(),
4559 Ref::new("SingleIdentifierGrammar").to_matchable(),
4560 Ref::new("ColumnReferenceSegment").to_matchable(),
4561 ])
4562 .to_matchable(),
4563 ])
4564 .to_matchable(),
4565 Ref::new("IgnoreRespectNullsGrammar").to_matchable(),
4566 Ref::new("IndexColumnDefinitionSegment").to_matchable(),
4567 Ref::new("EmptyStructLiteralSegment").to_matchable(),
4568 ])
4569 .to_matchable()
4570 .into(),
4571 ),
4572 (
4573 "PostFunctionGrammar".into(),
4574 one_of(vec![
4575 Ref::new("OverClauseSegment").to_matchable(),
4576 Ref::new("FilterClauseGrammar").to_matchable(),
4577 ])
4578 .to_matchable()
4579 .into(),
4580 ),
4581 ]);
4582
4583 ansi_dialect.add([(
4586 "JoinLikeClauseGrammar".into(),
4587 Nothing::new().to_matchable().into(),
4588 )]);
4589
4590 ansi_dialect.add([
4591 (
4592 "Expression_A_Unary_Operator_Grammar".into(),
4599 one_of(vec![
4600 Ref::new("SignedSegmentGrammar")
4603 .exclude(Sequence::new(vec![
4604 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
4605 ]))
4606 .to_matchable(),
4607 Ref::new("TildeSegment").to_matchable(),
4608 Ref::new("NotOperatorGrammar").to_matchable(),
4609 Ref::keyword("PRIOR").to_matchable(),
4611 ])
4612 .to_matchable()
4613 .into(),
4614 ),
4615 (
4616 "Tail_Recurse_Expression_A_Grammar".into(),
4617 Sequence::new(vec_of_erased![
4618 AnyNumberOf::new(vec_of_erased![Ref::new("Expression_A_Unary_Operator_Grammar")])
4622 .config(
4623 |this| this.terminators = vec_of_erased![Ref::new("BinaryOperatorGrammar")]
4624 ),
4625 Ref::new("Expression_C_Grammar"),
4626 ])
4627 .to_matchable()
4628 .into(),
4629 ),
4630 (
4631 "Expression_A_Grammar".into(),
4632 Sequence::new(vec![
4633 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4634 AnyNumberOf::new(vec![
4635 one_of(vec![
4636 Sequence::new(vec![
4638 Sequence::new(vec![
4639 Ref::keyword("NOT").optional().to_matchable(),
4640 Ref::new("LikeGrammar").to_matchable(),
4641 ])
4642 .to_matchable(),
4643 Ref::new("Expression_A_Grammar").to_matchable(),
4644 Sequence::new(vec![
4645 Ref::keyword("ESCAPE").to_matchable(),
4646 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4647 ])
4648 .config(|this| this.optional())
4649 .to_matchable(),
4650 ])
4651 .to_matchable(),
4652 Sequence::new(vec![
4654 Ref::new("BinaryOperatorGrammar").to_matchable(),
4655 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4656 ])
4657 .to_matchable(),
4658 Sequence::new(vec![
4660 Ref::keyword("NOT").optional().to_matchable(),
4661 Ref::keyword("IN").to_matchable(),
4662 Bracketed::new(vec![
4663 one_of(vec![
4664 Delimited::new(vec![
4665 Ref::new("Expression_A_Grammar").to_matchable(),
4666 ])
4667 .to_matchable(),
4668 Ref::new("SelectableGrammar").to_matchable(),
4669 ])
4670 .to_matchable(),
4671 ])
4672 .config(|this| this.parse_mode(ParseMode::Greedy))
4673 .to_matchable(),
4674 ])
4675 .to_matchable(),
4676 Sequence::new(vec![
4678 Ref::keyword("NOT").optional().to_matchable(),
4679 Ref::keyword("IN").to_matchable(),
4680 Ref::new("FunctionSegment").to_matchable(),
4681 ])
4682 .to_matchable(),
4683 Sequence::new(vec![
4685 Ref::keyword("IS").to_matchable(),
4686 Ref::keyword("NOT").optional().to_matchable(),
4687 Ref::new("IsClauseGrammar").to_matchable(),
4688 ])
4689 .to_matchable(),
4690 Ref::new("IsNullGrammar").to_matchable(),
4692 Ref::new("NotNullGrammar").to_matchable(),
4693 Ref::new("CollateGrammar").to_matchable(),
4695 Sequence::new(vec![
4697 Ref::keyword("NOT").optional().to_matchable(),
4698 Ref::keyword("BETWEEN").to_matchable(),
4699 Ref::new("Expression_B_Grammar").to_matchable(),
4700 Ref::keyword("AND").to_matchable(),
4701 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4702 ])
4703 .to_matchable(),
4704 ])
4706 .to_matchable(),
4707 ])
4708 .to_matchable(),
4709 ])
4710 .to_matchable()
4711 .into(),
4712 ),
4713 (
4720 "Expression_B_Unary_Operator_Grammar".into(),
4721 one_of(vec![
4722 Ref::new("SignedSegmentGrammar")
4723 .exclude(Sequence::new(vec![
4724 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
4725 ]))
4726 .to_matchable(),
4727 Ref::new("TildeSegment").to_matchable(),
4728 ])
4729 .to_matchable()
4730 .into(),
4731 ),
4732 (
4733 "Tail_Recurse_Expression_B_Grammar".into(),
4734 Sequence::new(vec![
4735 AnyNumberOf::new(vec![
4738 Ref::new("Expression_B_Unary_Operator_Grammar").to_matchable(),
4739 ])
4740 .to_matchable(),
4741 Ref::new("Expression_C_Grammar").to_matchable(),
4742 ])
4743 .to_matchable()
4744 .into(),
4745 ),
4746 (
4747 "Expression_B_Grammar".into(),
4748 Sequence::new(vec![
4749 Ref::new("Tail_Recurse_Expression_B_Grammar").to_matchable(),
4751 AnyNumberOf::new(vec![
4752 one_of(vec![
4753 Sequence::new(vec![
4756 one_of(vec![
4757 Ref::new("ArithmeticBinaryOperatorGrammar").to_matchable(),
4758 Ref::new("StringBinaryOperatorGrammar").to_matchable(),
4759 Ref::new("ComparisonOperatorGrammar").to_matchable(),
4760 ])
4761 .to_matchable(),
4762 Ref::new("Tail_Recurse_Expression_B_Grammar").to_matchable(),
4763 ])
4764 .to_matchable(),
4765 ])
4767 .to_matchable(),
4768 ])
4769 .to_matchable(),
4770 ])
4771 .to_matchable()
4772 .into(),
4773 ),
4774 (
4775 "Expression_C_Grammar".into(),
4776 one_of(vec![
4777 Sequence::new(vec![
4779 Ref::keyword("EXISTS").to_matchable(),
4780 Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
4781 .to_matchable(),
4782 ])
4783 .to_matchable(),
4784 Sequence::new(vec![
4787 one_of(vec![
4788 Ref::new("Expression_D_Grammar").to_matchable(),
4789 Ref::new("CaseExpressionSegment").to_matchable(),
4790 ])
4791 .to_matchable(),
4792 AnyNumberOf::new(vec![Ref::new("TimeZoneGrammar").to_matchable()])
4793 .config(|this| this.optional())
4794 .to_matchable(),
4795 ])
4796 .to_matchable(),
4797 Ref::new("ShorthandCastSegment").to_matchable(),
4798 ])
4799 .config(|this| this.terminators = vec_of_erased![Ref::new("CommaSegment")])
4800 .to_matchable()
4801 .into(),
4802 ),
4803 (
4804 "Expression_D_Grammar".into(),
4805 Sequence::new(vec![
4806 one_of(vec![
4807 Ref::new("BareFunctionSegment").to_matchable(),
4808 Ref::new("FunctionSegment").to_matchable(),
4809 Bracketed::new(vec![
4810 one_of(vec![
4811 Ref::new("ExpressionSegment").to_matchable(),
4812 Ref::new("SelectableGrammar").to_matchable(),
4813 Delimited::new(vec![
4814 Ref::new("ColumnReferenceSegment").to_matchable(),
4815 Ref::new("FunctionSegment").to_matchable(),
4816 Ref::new("LiteralGrammar").to_matchable(),
4817 Ref::new("LocalAliasSegment").to_matchable(),
4818 ])
4819 .to_matchable(),
4820 ])
4821 .to_matchable(),
4822 ])
4823 .config(|this| this.parse_mode(ParseMode::Greedy))
4824 .to_matchable(),
4825 Ref::new("SelectStatementSegment").to_matchable(),
4826 Ref::new("LiteralGrammar").to_matchable(),
4827 Ref::new("IntervalExpressionSegment").to_matchable(),
4828 Ref::new("TypedStructLiteralSegment").to_matchable(),
4829 Ref::new("ArrayExpressionSegment").to_matchable(),
4830 Ref::new("ColumnReferenceSegment").to_matchable(),
4831 Sequence::new(vec![
4832 Ref::new("SingleIdentifierGrammar").to_matchable(),
4833 Ref::new("ObjectReferenceDelimiterGrammar").to_matchable(),
4834 Ref::new("StarSegment").to_matchable(),
4835 ])
4836 .to_matchable(),
4837 Sequence::new(vec![
4838 Ref::new("StructTypeSegment").to_matchable(),
4839 Bracketed::new(vec![
4840 Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4841 .to_matchable(),
4842 ])
4843 .to_matchable(),
4844 ])
4845 .to_matchable(),
4846 Sequence::new(vec![
4847 Ref::new("DatatypeSegment").to_matchable(),
4848 one_of(vec![
4849 Ref::new("QuotedLiteralSegment").to_matchable(),
4850 Ref::new("NumericLiteralSegment").to_matchable(),
4851 Ref::new("BooleanLiteralGrammar").to_matchable(),
4852 Ref::new("NullLiteralSegment").to_matchable(),
4853 Ref::new("DateTimeLiteralGrammar").to_matchable(),
4854 ])
4855 .to_matchable(),
4856 ])
4857 .to_matchable(),
4858 Ref::new("LocalAliasSegment").to_matchable(),
4859 ])
4860 .config(|this| this.terminators = vec_of_erased![Ref::new("CommaSegment")])
4861 .to_matchable(),
4862 Ref::new("AccessorGrammar").optional().to_matchable(),
4863 ])
4864 .allow_gaps(true)
4865 .to_matchable()
4866 .into(),
4867 ),
4868 (
4869 "AccessorGrammar".into(),
4870 AnyNumberOf::new(vec![Ref::new("ArrayAccessorSegment").to_matchable()])
4871 .to_matchable()
4872 .into(),
4873 ),
4874 ]);
4875
4876 ansi_dialect.add([
4877 (
4878 "SelectableGrammar".into(),
4879 one_of(vec_of_erased![
4880 optionally_bracketed(vec_of_erased![Ref::new("WithCompoundStatementSegment")]),
4881 optionally_bracketed(vec_of_erased![Ref::new(
4882 "WithCompoundNonSelectStatementSegment"
4883 )]),
4884 Ref::new("NonWithSelectableGrammar"),
4885 Bracketed::new(vec_of_erased![Ref::new("SelectableGrammar")]),
4886 ])
4887 .to_matchable()
4888 .into(),
4889 ),
4890 (
4891 "NonWithSelectableGrammar".into(),
4892 one_of(vec![
4893 Ref::new("SetExpressionSegment").to_matchable(),
4894 optionally_bracketed(vec![Ref::new("SelectStatementSegment").to_matchable()])
4895 .to_matchable(),
4896 Ref::new("NonSetSelectableGrammar").to_matchable(),
4897 ])
4898 .to_matchable()
4899 .into(),
4900 ),
4901 (
4902 "NonWithNonSelectableGrammar".into(),
4903 one_of(vec![
4904 Ref::new("UpdateStatementSegment").to_matchable(),
4905 Ref::new("InsertStatementSegment").to_matchable(),
4906 Ref::new("DeleteStatementSegment").to_matchable(),
4907 ])
4908 .to_matchable()
4909 .into(),
4910 ),
4911 (
4912 "NonSetSelectableGrammar".into(),
4913 one_of(vec![
4914 Ref::new("ValuesClauseSegment").to_matchable(),
4915 Ref::new("UnorderedSelectStatementSegment").to_matchable(),
4916 Bracketed::new(vec![Ref::new("SelectStatementSegment").to_matchable()])
4917 .to_matchable(),
4918 Bracketed::new(vec![
4919 Ref::new("WithCompoundStatementSegment").to_matchable(),
4920 ])
4921 .to_matchable(),
4922 Bracketed::new(vec![Ref::new("NonSetSelectableGrammar").to_matchable()])
4923 .to_matchable(),
4924 ])
4925 .to_matchable()
4926 .into(),
4927 ),
4928 ]);
4929
4930 ansi_dialect.add([
4932 (
4933 "PostTableExpressionGrammar".into(),
4934 Nothing::new().to_matchable().into(),
4935 ),
4936 (
4937 "BracketedSegment".into(),
4938 BracketedSegmentMatcher::new().to_matchable().into(),
4939 ),
4940 ]);
4941
4942 ansi_dialect
4943}
4944
4945pub fn select_clause_element() -> Matchable {
4946 one_of(vec_of_erased![
4947 Ref::new("WildcardExpressionSegment"),
4949 Sequence::new(vec_of_erased![
4950 Ref::new("BaseExpressionElementGrammar"),
4951 Ref::new("AliasExpressionSegment").optional(),
4952 ]),
4953 ])
4954 .to_matchable()
4955}
4956
4957fn lexer_matchers() -> Vec<Matcher> {
4958 vec![
4959 Matcher::regex("whitespace", r"[^\S\r\n]+", SyntaxKind::Whitespace),
4960 Matcher::regex("inline_comment", r"(--|#)[^\n]*", SyntaxKind::InlineComment),
4961 Matcher::native("block_comment", block_comment, SyntaxKind::BlockComment)
4962 .subdivider(Pattern::legacy(
4963 "newline",
4964 |_| true,
4965 r"\r\n|\n",
4966 SyntaxKind::Newline,
4967 ))
4968 .post_subdivide(Pattern::legacy(
4969 "whitespace",
4970 |_| true,
4971 r"[^\S\r\n]+",
4972 SyntaxKind::Whitespace,
4973 )),
4974 Matcher::regex(
4975 "single_quote",
4976 r"'([^'\\]|\\.|'')*'",
4977 SyntaxKind::SingleQuote,
4978 ),
4979 Matcher::regex(
4980 "double_quote",
4981 r#""([^"\\]|\\.)*""#,
4982 SyntaxKind::DoubleQuote,
4983 ),
4984 Matcher::regex("back_quote", r"`[^`]*`", SyntaxKind::BackQuote),
4985 Matcher::legacy(
4986 "dollar_quote",
4987 |s| s.starts_with("$"),
4988 r"\$(\w*)\$[\s\S]*?\$\1\$",
4989 SyntaxKind::DollarQuote,
4990 ),
4991 Matcher::native(
4992 "numeric_literal",
4993 numeric_literal,
4994 SyntaxKind::NumericLiteral,
4995 ),
4996 Matcher::regex("like_operator", r"!?~~?\*?", SyntaxKind::LikeOperator),
4997 Matcher::regex("newline", r"(\r\n|\n)", SyntaxKind::Newline),
4998 Matcher::string("casting_operator", "::", SyntaxKind::CastingOperator),
4999 Matcher::string("equals", "=", SyntaxKind::RawComparisonOperator),
5000 Matcher::string("greater_than", ">", SyntaxKind::RawComparisonOperator),
5001 Matcher::string("less_than", "<", SyntaxKind::RawComparisonOperator),
5002 Matcher::string("not", "!", SyntaxKind::RawComparisonOperator),
5003 Matcher::string("dot", ".", SyntaxKind::Dot),
5004 Matcher::string("comma", ",", SyntaxKind::Comma),
5005 Matcher::string("plus", "+", SyntaxKind::Plus),
5006 Matcher::string("minus", "-", SyntaxKind::Minus),
5007 Matcher::string("divide", "/", SyntaxKind::Divide),
5008 Matcher::string("percent", "%", SyntaxKind::Percent),
5009 Matcher::string("question", "?", SyntaxKind::Question),
5010 Matcher::string("ampersand", "&", SyntaxKind::Ampersand),
5011 Matcher::string("vertical_bar", "|", SyntaxKind::VerticalBar),
5012 Matcher::string("caret", "^", SyntaxKind::Caret),
5013 Matcher::string("star", "*", SyntaxKind::Star),
5014 Matcher::string("start_bracket", "(", SyntaxKind::StartBracket),
5015 Matcher::string("end_bracket", ")", SyntaxKind::EndBracket),
5016 Matcher::string("start_square_bracket", "[", SyntaxKind::StartSquareBracket),
5017 Matcher::string("end_square_bracket", "]", SyntaxKind::EndSquareBracket),
5018 Matcher::string("start_curly_bracket", "{", SyntaxKind::StartCurlyBracket),
5019 Matcher::string("end_curly_bracket", "}", SyntaxKind::EndCurlyBracket),
5020 Matcher::string("colon", ":", SyntaxKind::Colon),
5021 Matcher::string("semicolon", ";", SyntaxKind::Semicolon),
5022 Matcher::regex("word", "[0-9a-zA-Z_]+", SyntaxKind::Word),
5023 ]
5024}
5025
5026pub fn frame_extent() -> AnyNumberOf {
5027 one_of(vec_of_erased![
5028 Sequence::new(vec_of_erased![Ref::keyword("CURRENT"), Ref::keyword("ROW")]),
5029 Sequence::new(vec_of_erased![
5030 one_of(vec_of_erased![
5031 Ref::new("NumericLiteralSegment"),
5032 Sequence::new(vec_of_erased![
5033 Ref::keyword("INTERVAL"),
5034 Ref::new("QuotedLiteralSegment")
5035 ]),
5036 Ref::keyword("UNBOUNDED")
5037 ]),
5038 one_of(vec_of_erased![
5039 Ref::keyword("PRECEDING"),
5040 Ref::keyword("FOLLOWING")
5041 ])
5042 ])
5043 ])
5044}
5045
5046pub fn explainable_stmt() -> AnyNumberOf {
5047 one_of(vec_of_erased![
5048 Ref::new("SelectableGrammar"),
5049 Ref::new("InsertStatementSegment"),
5050 Ref::new("UpdateStatementSegment"),
5051 Ref::new("DeleteStatementSegment")
5052 ])
5053}
5054
5055pub fn get_unordered_select_statement_segment_grammar() -> Matchable {
5056 Sequence::new(vec_of_erased![
5057 Ref::new("SelectClauseSegment"),
5058 MetaSegment::dedent(),
5059 Ref::new("FromClauseSegment").optional(),
5060 Ref::new("WhereClauseSegment").optional(),
5061 Ref::new("GroupByClauseSegment").optional(),
5062 Ref::new("HavingClauseSegment").optional(),
5063 Ref::new("OverlapsClauseSegment").optional(),
5064 Ref::new("NamedWindowSegment").optional()
5065 ])
5066 .terminators(vec_of_erased![
5067 Ref::new("SetOperatorSegment"),
5068 Ref::new("WithNoSchemaBindingClauseSegment"),
5069 Ref::new("WithDataClauseSegment"),
5070 Ref::new("OrderByClauseSegment"),
5071 Ref::new("LimitClauseSegment")
5072 ])
5073 .config(|this| {
5074 this.parse_mode(ParseMode::GreedyOnceStarted);
5075 })
5076 .to_matchable()
5077}
5078
5079pub fn select_statement() -> Matchable {
5080 get_unordered_select_statement_segment_grammar().copy(
5081 Some(vec_of_erased![
5082 Ref::new("OrderByClauseSegment").optional(),
5083 Ref::new("FetchClauseSegment").optional(),
5084 Ref::new("LimitClauseSegment").optional(),
5085 Ref::new("NamedWindowSegment").optional()
5086 ]),
5087 None,
5088 None,
5089 None,
5090 vec_of_erased![
5091 Ref::new("SetOperatorSegment"),
5092 Ref::new("WithNoSchemaBindingClauseSegment"),
5093 Ref::new("WithDataClauseSegment")
5094 ],
5095 true,
5096 )
5097}
5098
5099pub fn select_clause_segment() -> Matchable {
5100 Sequence::new(vec_of_erased![
5101 Ref::keyword("SELECT"),
5102 Ref::new("SelectClauseModifierSegment").optional(),
5103 MetaSegment::indent(),
5104 Delimited::new(vec_of_erased![Ref::new("SelectClauseElementSegment")])
5105 .config(|this| this.allow_trailing()),
5106 ])
5107 .terminators(vec_of_erased![Ref::new("SelectClauseTerminatorGrammar")])
5108 .config(|this| {
5109 this.parse_mode(ParseMode::GreedyOnceStarted);
5110 })
5111 .to_matchable()
5112}
5113
5114pub fn statement_segment() -> Matchable {
5115 one_of(vec![
5116 Ref::new("SelectableGrammar").to_matchable(),
5117 Ref::new("MergeStatementSegment").to_matchable(),
5118 Ref::new("InsertStatementSegment").to_matchable(),
5119 Ref::new("TransactionStatementSegment").to_matchable(),
5120 Ref::new("DropTableStatementSegment").to_matchable(),
5121 Ref::new("DropViewStatementSegment").to_matchable(),
5122 Ref::new("CreateUserStatementSegment").to_matchable(),
5123 Ref::new("DropUserStatementSegment").to_matchable(),
5124 Ref::new("TruncateStatementSegment").to_matchable(),
5125 Ref::new("AccessStatementSegment").to_matchable(),
5126 Ref::new("CreateTableStatementSegment").to_matchable(),
5127 Ref::new("CreateRoleStatementSegment").to_matchable(),
5128 Ref::new("DropRoleStatementSegment").to_matchable(),
5129 Ref::new("AlterTableStatementSegment").to_matchable(),
5130 Ref::new("CreateSchemaStatementSegment").to_matchable(),
5131 Ref::new("SetSchemaStatementSegment").to_matchable(),
5132 Ref::new("DropSchemaStatementSegment").to_matchable(),
5133 Ref::new("DropTypeStatementSegment").to_matchable(),
5134 Ref::new("CreateDatabaseStatementSegment").to_matchable(),
5135 Ref::new("DropDatabaseStatementSegment").to_matchable(),
5136 Ref::new("CreateIndexStatementSegment").to_matchable(),
5137 Ref::new("DropIndexStatementSegment").to_matchable(),
5138 Ref::new("CreateViewStatementSegment").to_matchable(),
5139 Ref::new("DeleteStatementSegment").to_matchable(),
5140 Ref::new("UpdateStatementSegment").to_matchable(),
5141 Ref::new("CreateCastStatementSegment").to_matchable(),
5142 Ref::new("DropCastStatementSegment").to_matchable(),
5143 Ref::new("CreateFunctionStatementSegment").to_matchable(),
5144 Ref::new("DropFunctionStatementSegment").to_matchable(),
5145 Ref::new("CreateModelStatementSegment").to_matchable(),
5146 Ref::new("DropModelStatementSegment").to_matchable(),
5147 Ref::new("DescribeStatementSegment").to_matchable(),
5148 Ref::new("UseStatementSegment").to_matchable(),
5149 Ref::new("ExplainStatementSegment").to_matchable(),
5150 Ref::new("CreateSequenceStatementSegment").to_matchable(),
5151 Ref::new("AlterSequenceStatementSegment").to_matchable(),
5152 Ref::new("DropSequenceStatementSegment").to_matchable(),
5153 Ref::new("CreateTriggerStatementSegment").to_matchable(),
5154 Ref::new("DropTriggerStatementSegment").to_matchable(),
5155 ])
5156 .config(|this| this.terminators = vec_of_erased![Ref::new("DelimiterGrammar")])
5157 .to_matchable()
5158}
5159
5160pub fn wildcard_expression_segment() -> Matchable {
5161 Sequence::new(vec![Ref::new("WildcardIdentifierSegment").to_matchable()]).to_matchable()
5162}
5163
5164fn numeric_literal(cursor: &mut Cursor) -> bool {
5165 let first_char = cursor.shift();
5166 match first_char {
5167 '0'..='9' | '.' => {
5168 let has_decimal = first_char == '.';
5169
5170 if has_decimal {
5171 if cursor.peek().is_ascii_digit() {
5172 cursor.shift_while(|c| c.is_ascii_digit());
5173 } else {
5174 return false;
5175 }
5176 } else {
5177 cursor.shift_while(|c| c.is_ascii_digit());
5178 if cursor.peek() == '.' {
5179 cursor.shift();
5180 cursor.shift_while(|c| c.is_ascii_digit());
5181 }
5182 }
5183
5184 if let 'e' | 'E' = cursor.peek() {
5185 cursor.shift();
5186 if let '+' | '-' = cursor.peek() {
5187 cursor.shift();
5188 }
5189 let mut exp_digits = false;
5190 while cursor.peek().is_ascii_digit() {
5191 cursor.shift();
5192 exp_digits = true;
5193 }
5194 if !exp_digits {
5195 return false;
5196 }
5197 }
5198
5199 let next_char = cursor.peek();
5200 if next_char == '.' || next_char.is_ascii_alphanumeric() || next_char == '_' {
5201 return false;
5202 }
5203
5204 true
5205 }
5206 _ => false,
5207 }
5208}
5209
5210fn block_comment(cursor: &mut Cursor) -> bool {
5211 if cursor.shift() != '/' {
5212 return false;
5213 }
5214
5215 if cursor.shift() != '*' {
5216 return false;
5217 }
5218
5219 let mut depth = 1usize;
5220
5221 loop {
5222 match cursor.shift() {
5223 '\0' => return false,
5224 '/' if cursor.peek() == '*' => {
5225 cursor.shift();
5226 depth += 1;
5227 }
5228 '*' if cursor.peek() == '/' => {
5229 cursor.shift();
5230 depth -= 1;
5231 if depth == 0 {
5232 break true;
5233 }
5234 }
5235 _ => {}
5236 }
5237 }
5238}
5239
5240pub(crate) fn select_clause_terminators() -> Vec<Matchable> {
5241 vec_of_erased![
5242 Ref::keyword("FROM"),
5243 Ref::keyword("WHERE"),
5244 Sequence::new(vec_of_erased![Ref::keyword("ORDER"), Ref::keyword("BY")]),
5245 Ref::keyword("LIMIT"),
5246 Ref::keyword("OVERLAPS"),
5247 Ref::new("SetOperatorSegment"),
5248 Ref::keyword("FETCH"),
5249 ]
5250}