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 Ref::new("AccessStatementSegmentGrantRoleWithOptionGrammar").optional(),
3243 Sequence::new(vec_of_erased![
3244 Ref::keyword("GRANTED"),
3245 Ref::keyword("BY"),
3246 one_of(vec_of_erased![
3247 Ref::keyword("CURRENT_USER"),
3248 Ref::keyword("SESSION_USER"),
3249 Ref::new("ObjectReferenceSegment")
3250 ])
3251 ])
3252 .config(|this| this.optional())
3253 ]),
3254 Sequence::new(vec_of_erased![
3255 Ref::keyword("REVOKE"),
3256 Sequence::new(vec_of_erased![
3257 Ref::keyword("GRANT"),
3258 Ref::keyword("OPTION"),
3259 Ref::keyword("FOR")
3260 ])
3261 .config(|this| this.optional()),
3262 one_of(vec_of_erased![
3263 Sequence::new(vec_of_erased![
3264 Delimited::new(vec_of_erased![
3265 one_of(vec_of_erased![global_permissions, permissions])
3266 .config(|this| this.terminators =
3267 vec_of_erased![Ref::keyword("ON")])
3268 ]),
3269 Ref::keyword("ON"),
3270 objects
3271 ]),
3272 Sequence::new(vec_of_erased![
3273 Ref::keyword("ROLE"),
3274 Ref::new("ObjectReferenceSegment")
3275 ]),
3276 Sequence::new(vec_of_erased![
3277 Ref::keyword("OWNERSHIP"),
3278 Ref::keyword("ON"),
3279 Ref::keyword("USER"),
3280 Ref::new("ObjectReferenceSegment"),
3281 ]),
3282 Ref::new("ObjectReferenceSegment"),
3283 ]),
3284 Ref::keyword("FROM"),
3285 one_of(vec_of_erased![
3286 Ref::keyword("GROUP"),
3287 Ref::keyword("USER"),
3288 Ref::keyword("ROLE"),
3289 Ref::keyword("SHARE")
3290 ])
3291 .config(|this| this.optional()),
3292 Delimited::new(vec_of_erased![Ref::new("ObjectReferenceSegment")]),
3293 Ref::new("DropBehaviorGrammar").optional()
3294 ])
3295 ])
3296 }
3297 .to_matchable(),
3298 )
3299 .to_matchable()
3300 .into(),
3301 ),
3302 (
3303 "InsertStatementSegment".into(),
3304 NodeMatcher::new(
3305 SyntaxKind::InsertStatement,
3306 Sequence::new(vec_of_erased![
3307 Ref::keyword("INSERT"),
3308 Ref::keyword("OVERWRITE").optional(),
3309 Ref::keyword("INTO"),
3310 Ref::new("TableReferenceSegment"),
3311 one_of(vec_of_erased![
3312 Ref::new("SelectableGrammar"),
3313 Sequence::new(vec_of_erased![
3314 Ref::new("BracketedColumnReferenceListGrammar"),
3315 Ref::new("SelectableGrammar")
3316 ]),
3317 Ref::new("DefaultValuesGrammar")
3318 ])
3319 ])
3320 .to_matchable(),
3321 )
3322 .to_matchable()
3323 .into(),
3324 ),
3325 (
3326 "TransactionStatementSegment".into(),
3327 NodeMatcher::new(
3328 SyntaxKind::TransactionStatement,
3329 Sequence::new(vec_of_erased![
3330 one_of(vec_of_erased![
3331 Ref::keyword("START"),
3332 Ref::keyword("BEGIN"),
3333 Ref::keyword("COMMIT"),
3334 Ref::keyword("ROLLBACK"),
3335 Ref::keyword("END")
3336 ]),
3337 one_of(vec_of_erased![
3338 Ref::keyword("TRANSACTION"),
3339 Ref::keyword("WORK")
3340 ])
3341 .config(|this| this.optional()),
3342 Sequence::new(vec_of_erased![
3343 Ref::keyword("NAME"),
3344 Ref::new("SingleIdentifierGrammar")
3345 ])
3346 .config(|this| this.optional()),
3347 Sequence::new(vec_of_erased![
3348 Ref::keyword("AND"),
3349 Ref::keyword("NO").optional(),
3350 Ref::keyword("CHAIN")
3351 ])
3352 .config(|this| this.optional())
3353 ])
3354 .to_matchable(),
3355 )
3356 .to_matchable()
3357 .into(),
3358 ),
3359 (
3360 "DropTableStatementSegment".into(),
3361 NodeMatcher::new(
3362 SyntaxKind::DropTableStatement,
3363 Sequence::new(vec_of_erased![
3364 Ref::keyword("DROP"),
3365 Ref::new("TemporaryGrammar").optional(),
3366 Ref::keyword("TABLE"),
3367 Ref::new("IfExistsGrammar").optional(),
3368 Delimited::new(vec_of_erased![Ref::new("TableReferenceSegment")]),
3369 Ref::new("DropBehaviorGrammar").optional()
3370 ])
3371 .to_matchable(),
3372 )
3373 .to_matchable()
3374 .into(),
3375 ),
3376 (
3377 "DropViewStatementSegment".into(),
3378 NodeMatcher::new(
3379 SyntaxKind::DropViewStatement,
3380 Sequence::new(vec_of_erased![
3381 Ref::keyword("DROP"),
3382 Ref::keyword("VIEW"),
3383 Ref::new("IfExistsGrammar").optional(),
3384 Ref::new("TableReferenceSegment"),
3385 Ref::new("DropBehaviorGrammar").optional()
3386 ])
3387 .to_matchable(),
3388 )
3389 .to_matchable()
3390 .into(),
3391 ),
3392 (
3393 "CreateUserStatementSegment".into(),
3394 NodeMatcher::new(
3395 SyntaxKind::CreateUserStatement,
3396 Sequence::new(vec_of_erased![
3397 Ref::keyword("CREATE"),
3398 Ref::keyword("USER"),
3399 Ref::new("RoleReferenceSegment")
3400 ])
3401 .to_matchable(),
3402 )
3403 .to_matchable()
3404 .into(),
3405 ),
3406 (
3407 "DropUserStatementSegment".into(),
3408 NodeMatcher::new(
3409 SyntaxKind::DropUserStatement,
3410 Sequence::new(vec_of_erased![
3411 Ref::keyword("DROP"),
3412 Ref::keyword("USER"),
3413 Ref::new("IfExistsGrammar").optional(),
3414 Ref::new("RoleReferenceSegment")
3415 ])
3416 .to_matchable(),
3417 )
3418 .to_matchable()
3419 .into(),
3420 ),
3421 (
3422 "NotEqualToSegment".into(),
3423 NodeMatcher::new(
3424 SyntaxKind::ComparisonOperator,
3425 one_of(vec![
3426 Sequence::new(vec![
3427 Ref::new("RawNotSegment").to_matchable(),
3428 Ref::new("RawEqualsSegment").to_matchable(),
3429 ])
3430 .allow_gaps(false)
3431 .to_matchable(),
3432 Sequence::new(vec![
3433 Ref::new("RawLessThanSegment").to_matchable(),
3434 Ref::new("RawGreaterThanSegment").to_matchable(),
3435 ])
3436 .allow_gaps(false)
3437 .to_matchable(),
3438 ])
3439 .to_matchable(),
3440 )
3441 .to_matchable()
3442 .into(),
3443 ),
3444 (
3445 "ConcatSegment".into(),
3446 NodeMatcher::new(
3447 SyntaxKind::BinaryOperator,
3448 Sequence::new(vec![
3449 Ref::new("PipeSegment").to_matchable(),
3450 Ref::new("PipeSegment").to_matchable(),
3451 ])
3452 .allow_gaps(false)
3453 .to_matchable(),
3454 )
3455 .to_matchable()
3456 .into(),
3457 ),
3458 (
3459 "ArrayExpressionSegment".into(),
3460 NodeMatcher::new(SyntaxKind::ArrayExpression, Nothing::new().to_matchable())
3461 .to_matchable()
3462 .into(),
3463 ),
3464 (
3465 "LocalAliasSegment".into(),
3466 NodeMatcher::new(SyntaxKind::LocalAlias, Nothing::new().to_matchable())
3467 .to_matchable()
3468 .into(),
3469 ),
3470 (
3471 "MergeStatementSegment".into(),
3472 NodeMatcher::new(
3473 SyntaxKind::MergeStatement,
3474 Sequence::new(vec![
3475 Ref::new("MergeIntoLiteralGrammar").to_matchable(),
3476 MetaSegment::indent().to_matchable(),
3477 one_of(vec![
3478 Ref::new("TableReferenceSegment").to_matchable(),
3479 Ref::new("AliasedTableReferenceGrammar").to_matchable(),
3480 ])
3481 .to_matchable(),
3482 MetaSegment::dedent().to_matchable(),
3483 Ref::keyword("USING").to_matchable(),
3484 MetaSegment::indent().to_matchable(),
3485 one_of(vec![
3486 Ref::new("TableReferenceSegment").to_matchable(),
3487 Ref::new("AliasedTableReferenceGrammar").to_matchable(),
3488 Sequence::new(vec![
3489 Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
3490 .to_matchable(),
3491 Ref::new("AliasExpressionSegment").optional().to_matchable(),
3492 ])
3493 .to_matchable(),
3494 ])
3495 .to_matchable(),
3496 MetaSegment::dedent().to_matchable(),
3497 Conditional::new(MetaSegment::indent())
3498 .indented_using_on()
3499 .to_matchable(),
3500 Ref::new("JoinOnConditionSegment").to_matchable(),
3501 Conditional::new(MetaSegment::dedent())
3502 .indented_using_on()
3503 .to_matchable(),
3504 Ref::new("MergeMatchSegment").to_matchable(),
3505 ])
3506 .to_matchable(),
3507 )
3508 .to_matchable()
3509 .into(),
3510 ),
3511 (
3512 "IndexColumnDefinitionSegment".into(),
3513 NodeMatcher::new(
3514 SyntaxKind::IndexColumnDefinition,
3515 Sequence::new(vec![
3516 Ref::new("SingleIdentifierGrammar").to_matchable(), one_of(vec![
3518 Ref::keyword("ASC").to_matchable(),
3519 Ref::keyword("DESC").to_matchable(),
3520 ])
3521 .config(|this| this.optional())
3522 .to_matchable(),
3523 ])
3524 .to_matchable(),
3525 )
3526 .to_matchable()
3527 .into(),
3528 ),
3529 (
3530 "BitwiseAndSegment".into(),
3531 NodeMatcher::new(
3532 SyntaxKind::ComparisonOperator,
3533 Ref::new("AmpersandSegment").to_matchable(),
3534 )
3535 .to_matchable()
3536 .into(),
3537 ),
3538 (
3539 "BitwiseOrSegment".into(),
3540 NodeMatcher::new(
3541 SyntaxKind::ComparisonOperator,
3542 Ref::new("PipeSegment").to_matchable(),
3543 )
3544 .to_matchable()
3545 .into(),
3546 ),
3547 (
3548 "BitwiseLShiftSegment".into(),
3549 NodeMatcher::new(
3550 SyntaxKind::ComparisonOperator,
3551 Sequence::new(vec![
3552 Ref::new("RawLessThanSegment").to_matchable(),
3553 Ref::new("RawLessThanSegment").to_matchable(),
3554 ])
3555 .allow_gaps(false)
3556 .to_matchable(),
3557 )
3558 .to_matchable()
3559 .into(),
3560 ),
3561 (
3562 "BitwiseRShiftSegment".into(),
3563 NodeMatcher::new(
3564 SyntaxKind::ComparisonOperator,
3565 Sequence::new(vec![
3566 Ref::new("RawGreaterThanSegment").to_matchable(),
3567 Ref::new("RawGreaterThanSegment").to_matchable(),
3568 ])
3569 .allow_gaps(false)
3570 .to_matchable(),
3571 )
3572 .to_matchable()
3573 .into(),
3574 ),
3575 (
3576 "LessThanSegment".into(),
3577 NodeMatcher::new(
3578 SyntaxKind::ComparisonOperator,
3579 Ref::new("RawLessThanSegment").to_matchable(),
3580 )
3581 .to_matchable()
3582 .into(),
3583 ),
3584 (
3585 "GreaterThanOrEqualToSegment".into(),
3586 NodeMatcher::new(
3587 SyntaxKind::ComparisonOperator,
3588 Sequence::new(vec![
3589 Ref::new("RawGreaterThanSegment").to_matchable(),
3590 Ref::new("RawEqualsSegment").to_matchable(),
3591 ])
3592 .allow_gaps(false)
3593 .to_matchable(),
3594 )
3595 .to_matchable()
3596 .into(),
3597 ),
3598 (
3599 "LessThanOrEqualToSegment".into(),
3600 NodeMatcher::new(
3601 SyntaxKind::ComparisonOperator,
3602 Sequence::new(vec![
3603 Ref::new("RawLessThanSegment").to_matchable(),
3604 Ref::new("RawEqualsSegment").to_matchable(),
3605 ])
3606 .allow_gaps(false)
3607 .to_matchable(),
3608 )
3609 .to_matchable()
3610 .into(),
3611 ),
3612 (
3613 "EqualsSegment".into(),
3614 NodeMatcher::new(
3615 SyntaxKind::ComparisonOperator,
3616 Ref::new("RawEqualsSegment").to_matchable(),
3617 )
3618 .to_matchable()
3619 .into(),
3620 ),
3621 (
3622 "GreaterThanSegment".into(),
3623 NodeMatcher::new(
3624 SyntaxKind::ComparisonOperator,
3625 Ref::new("RawGreaterThanSegment").to_matchable(),
3626 )
3627 .to_matchable()
3628 .into(),
3629 ),
3630 (
3631 "QualifiedNumericLiteralSegment".into(),
3632 NodeMatcher::new(
3633 SyntaxKind::NumericLiteral,
3634 Sequence::new(vec![
3635 Ref::new("SignedSegmentGrammar").to_matchable(),
3636 Ref::new("NumericLiteralSegment").to_matchable(),
3637 ])
3638 .to_matchable(),
3639 )
3640 .to_matchable()
3641 .into(),
3642 ),
3643 (
3644 "AggregateOrderByClause".into(),
3645 NodeMatcher::new(
3646 SyntaxKind::AggregateOrderByClause,
3647 Ref::new("OrderByClauseSegment").to_matchable(),
3648 )
3649 .to_matchable()
3650 .into(),
3651 ),
3652 (
3653 "FunctionNameSegment".into(),
3654 NodeMatcher::new(
3655 SyntaxKind::FunctionName,
3656 Sequence::new(vec_of_erased![
3657 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
3658 Ref::new("SingleIdentifierGrammar"),
3659 Ref::new("DotSegment")
3660 ])])
3661 .config(|this| this.terminators = vec_of_erased![Ref::new("BracketedSegment")]),
3662 one_of(vec_of_erased![
3663 Ref::new("FunctionNameIdentifierSegment"),
3664 Ref::new("QuotedIdentifierSegment")
3665 ])
3666 ])
3667 .terminators(vec_of_erased![Ref::new("BracketedSegment")])
3668 .allow_gaps(false)
3669 .to_matchable(),
3670 )
3671 .to_matchable()
3672 .into(),
3673 ),
3674 (
3675 "CaseExpressionSegment".into(),
3676 NodeMatcher::new(
3677 SyntaxKind::CaseExpression,
3678 one_of(vec_of_erased![
3679 Sequence::new(vec_of_erased![
3680 Ref::keyword("CASE"),
3681 MetaSegment::implicit_indent(),
3682 AnyNumberOf::new(vec_of_erased![Ref::new("WhenClauseSegment")],).config(
3683 |this| {
3684 this.reset_terminators = true;
3685 this.terminators =
3686 vec_of_erased![Ref::keyword("ELSE"), Ref::keyword("END")];
3687 }
3688 ),
3689 Ref::new("ElseClauseSegment").optional(),
3690 MetaSegment::dedent(),
3691 Ref::keyword("END"),
3692 ]),
3693 Sequence::new(vec_of_erased![
3694 Ref::keyword("CASE"),
3695 Ref::new("ExpressionSegment"),
3696 MetaSegment::implicit_indent(),
3697 AnyNumberOf::new(vec_of_erased![Ref::new("WhenClauseSegment")],).config(
3698 |this| {
3699 this.reset_terminators = true;
3700 this.terminators =
3701 vec_of_erased![Ref::keyword("ELSE"), Ref::keyword("END")];
3702 }
3703 ),
3704 Ref::new("ElseClauseSegment").optional(),
3705 MetaSegment::dedent(),
3706 Ref::keyword("END"),
3707 ]),
3708 ])
3709 .config(|this| {
3710 this.terminators = vec_of_erased![
3711 Ref::new("ComparisonOperatorGrammar"),
3712 Ref::new("CommaSegment"),
3713 Ref::new("BinaryOperatorGrammar")
3714 ]
3715 })
3716 .to_matchable(),
3717 )
3718 .to_matchable()
3719 .into(),
3720 ),
3721 (
3722 "WhenClauseSegment".into(),
3723 NodeMatcher::new(
3724 SyntaxKind::WhenClause,
3725 Sequence::new(vec_of_erased![
3726 Ref::keyword("WHEN"),
3727 Sequence::new(vec_of_erased![
3728 MetaSegment::implicit_indent(),
3729 Ref::new("ExpressionSegment"),
3730 MetaSegment::dedent(),
3731 ]),
3732 Conditional::new(MetaSegment::indent()).indented_then(),
3733 Ref::keyword("THEN"),
3734 Conditional::new(MetaSegment::implicit_indent()).indented_then_contents(),
3735 Ref::new("ExpressionSegment"),
3736 Conditional::new(MetaSegment::dedent()).indented_then_contents(),
3737 Conditional::new(MetaSegment::dedent()).indented_then(),
3738 ])
3739 .to_matchable(),
3740 )
3741 .to_matchable()
3742 .into(),
3743 ),
3744 (
3745 "ElseClauseSegment".into(),
3746 NodeMatcher::new(
3747 SyntaxKind::ElseClause,
3748 Sequence::new(vec![
3749 Ref::keyword("ELSE").to_matchable(),
3750 MetaSegment::implicit_indent().to_matchable(),
3751 Ref::new("ExpressionSegment").to_matchable(),
3752 MetaSegment::dedent().to_matchable(),
3753 ])
3754 .to_matchable(),
3755 )
3756 .to_matchable()
3757 .into(),
3758 ),
3759 (
3760 "WhereClauseSegment".into(),
3761 NodeMatcher::new(
3762 SyntaxKind::WhereClause,
3763 Sequence::new(vec_of_erased![
3764 Ref::keyword("WHERE"),
3765 MetaSegment::implicit_indent(),
3766 optionally_bracketed(vec_of_erased![Ref::new("ExpressionSegment")]),
3767 MetaSegment::dedent()
3768 ])
3769 .to_matchable(),
3770 )
3771 .to_matchable()
3772 .into(),
3773 ),
3774 (
3775 "SetOperatorSegment".into(),
3776 NodeMatcher::new(
3777 SyntaxKind::SetOperator,
3778 one_of(vec_of_erased![
3779 Ref::new("UnionGrammar"),
3780 Sequence::new(vec_of_erased![
3781 one_of(vec_of_erased![
3782 Ref::keyword("INTERSECT"),
3783 Ref::keyword("EXCEPT")
3784 ]),
3785 Ref::keyword("ALL").optional(),
3786 ]),
3787 Ref::keyword("MINUS"),
3788 ])
3789 .to_matchable(),
3790 )
3791 .to_matchable()
3792 .into(),
3793 ),
3794 (
3795 "ValuesClauseSegment".into(),
3796 NodeMatcher::new(
3797 SyntaxKind::ValuesClause,
3798 Sequence::new(vec![
3799 one_of(vec![
3800 Ref::keyword("VALUE").to_matchable(),
3801 Ref::keyword("VALUES").to_matchable(),
3802 ])
3803 .to_matchable(),
3804 Delimited::new(vec![
3805 Sequence::new(vec![
3806 Ref::keyword("ROW").optional().to_matchable(),
3807 Bracketed::new(vec![
3808 Delimited::new(vec![
3809 Ref::keyword("DEFAULT").to_matchable(),
3810 Ref::new("LiteralGrammar").to_matchable(),
3811 Ref::new("ExpressionSegment").to_matchable(),
3812 ])
3813 .to_matchable(),
3814 ])
3815 .config(|this| this.parse_mode(ParseMode::Greedy))
3816 .to_matchable(),
3817 ])
3818 .to_matchable(),
3819 ])
3820 .to_matchable(),
3821 ])
3822 .to_matchable(),
3823 )
3824 .to_matchable()
3825 .into(),
3826 ),
3827 (
3828 "EmptyStructLiteralSegment".into(),
3829 NodeMatcher::new(
3830 SyntaxKind::EmptyStructLiteral,
3831 Sequence::new(vec![
3832 Ref::new("StructTypeSegment").to_matchable(),
3833 Ref::new("EmptyStructLiteralBracketsSegment").to_matchable(),
3834 ])
3835 .to_matchable(),
3836 )
3837 .to_matchable()
3838 .into(),
3839 ),
3840 (
3841 "ObjectLiteralSegment".into(),
3842 NodeMatcher::new(
3843 SyntaxKind::ObjectLiteral,
3844 Bracketed::new(vec![
3845 Delimited::new(vec![Ref::new("ObjectLiteralElementSegment").to_matchable()])
3846 .config(|this| {
3847 this.optional();
3848 })
3849 .to_matchable(),
3850 ])
3851 .config(|this| {
3852 this.bracket_type("curly");
3853 })
3854 .to_matchable(),
3855 )
3856 .to_matchable()
3857 .into(),
3858 ),
3859 (
3860 "ObjectLiteralElementSegment".into(),
3861 NodeMatcher::new(
3862 SyntaxKind::ObjectLiteralElement,
3863 Sequence::new(vec![
3864 Ref::new("QuotedLiteralSegment").to_matchable(),
3865 Ref::new("ColonSegment").to_matchable(),
3866 Ref::new("BaseExpressionElementGrammar").to_matchable(),
3867 ])
3868 .to_matchable(),
3869 )
3870 .to_matchable()
3871 .into(),
3872 ),
3873 (
3874 "TimeZoneGrammar".into(),
3875 NodeMatcher::new(
3876 SyntaxKind::TimeZoneGrammar,
3877 AnyNumberOf::new(vec![
3878 Sequence::new(vec![
3879 Ref::keyword("AT").to_matchable(),
3880 Ref::keyword("TIME").to_matchable(),
3881 Ref::keyword("ZONE").to_matchable(),
3882 Ref::new("ExpressionSegment").to_matchable(),
3883 ])
3884 .to_matchable(),
3885 ])
3886 .to_matchable(),
3887 )
3888 .to_matchable()
3889 .into(),
3890 ),
3891 (
3892 "BracketedArguments".into(),
3893 NodeMatcher::new(
3894 SyntaxKind::BracketedArguments,
3895 Bracketed::new(vec![
3896 Delimited::new(vec![Ref::new("LiteralGrammar").to_matchable()])
3897 .config(|this| {
3898 this.optional();
3899 })
3900 .to_matchable(),
3901 ])
3902 .to_matchable(),
3903 )
3904 .to_matchable()
3905 .into(),
3906 ),
3907 (
3908 "DatatypeSegment".into(),
3909 NodeMatcher::new(
3910 SyntaxKind::DataType,
3911 one_of(vec_of_erased![
3912 Sequence::new(vec_of_erased![
3913 one_of(vec_of_erased![
3914 Ref::keyword("TIME"),
3915 Ref::keyword("TIMESTAMP")
3916 ]),
3917 Bracketed::new(vec_of_erased![Ref::new("NumericLiteralSegment")])
3918 .config(|this| this.optional()),
3919 Sequence::new(vec_of_erased![
3920 one_of(vec_of_erased![
3921 Ref::keyword("WITH"),
3922 Ref::keyword("WITHOUT")
3923 ]),
3924 Ref::keyword("TIME"),
3925 Ref::keyword("ZONE"),
3926 ])
3927 .config(|this| this.optional()),
3928 ]),
3929 Sequence::new(vec_of_erased![
3930 Ref::keyword("DOUBLE"),
3931 Ref::keyword("PRECISION")
3932 ]),
3933 Sequence::new(vec_of_erased![
3934 one_of(vec_of_erased![
3935 Sequence::new(vec_of_erased![
3936 one_of(vec_of_erased![
3937 Ref::keyword("CHARACTER"),
3938 Ref::keyword("BINARY")
3939 ]),
3940 one_of(vec_of_erased![
3941 Ref::keyword("VARYING"),
3942 Sequence::new(vec_of_erased![
3943 Ref::keyword("LARGE"),
3944 Ref::keyword("OBJECT"),
3945 ]),
3946 ]),
3947 ]),
3948 Sequence::new(vec_of_erased![
3949 Sequence::new(vec_of_erased![
3950 Ref::new("SingleIdentifierGrammar"),
3951 Ref::new("DotSegment"),
3952 ])
3953 .config(|this| this.optional()),
3954 Ref::new("DatatypeIdentifierSegment"),
3955 ]),
3956 ]),
3957 Ref::new("BracketedArguments").optional(),
3958 one_of(vec_of_erased![
3959 Ref::keyword("UNSIGNED"),
3960 Ref::new("CharCharacterSetGrammar"),
3961 ])
3962 .config(|config| config.optional()),
3963 ]),
3964 ])
3965 .to_matchable(),
3966 )
3967 .to_matchable()
3968 .into(),
3969 ),
3970 (
3971 "AliasExpressionSegment".into(),
3972 NodeMatcher::new(
3973 SyntaxKind::AliasExpression,
3974 Sequence::new(vec_of_erased![
3975 MetaSegment::indent(),
3976 Ref::keyword("AS").optional(),
3977 one_of(vec_of_erased![
3978 Sequence::new(vec_of_erased![
3979 Ref::new("SingleIdentifierGrammar"),
3980 Bracketed::new(vec_of_erased![Ref::new("SingleIdentifierListSegment")])
3981 .config(|this| this.optional())
3982 ]),
3983 Ref::new("SingleQuotedIdentifierSegment")
3984 ]),
3985 MetaSegment::dedent(),
3986 ])
3987 .to_matchable(),
3988 )
3989 .to_matchable()
3990 .into(),
3991 ),
3992 (
3993 "ShorthandCastSegment".into(),
3994 NodeMatcher::new(
3995 SyntaxKind::CastExpression,
3996 Sequence::new(vec_of_erased![
3997 one_of(vec_of_erased![
3998 Ref::new("Expression_D_Grammar"),
3999 Ref::new("CaseExpressionSegment")
4000 ]),
4001 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
4002 Ref::new("CastOperatorSegment"),
4003 Ref::new("DatatypeSegment"),
4004 Ref::new("TimeZoneGrammar").optional()
4005 ]),])
4006 .config(|this| this.min_times(1)),
4007 ])
4008 .to_matchable(),
4009 )
4010 .to_matchable()
4011 .into(),
4012 ),
4013 (
4014 "ArrayAccessorSegment".into(),
4015 NodeMatcher::new(
4016 SyntaxKind::ArrayAccessor,
4017 Bracketed::new(vec![
4018 Delimited::new(vec![
4019 one_of(vec![
4020 Ref::new("NumericLiteralSegment").to_matchable(),
4021 Ref::new("ExpressionSegment").to_matchable(),
4022 ])
4023 .to_matchable(),
4024 ])
4025 .config(|this| this.delimiter(Ref::new("SliceSegment")))
4026 .to_matchable(),
4027 ])
4028 .config(|this| {
4029 this.bracket_type("square");
4030 this.parse_mode(ParseMode::Greedy);
4031 })
4032 .to_matchable(),
4033 )
4034 .to_matchable()
4035 .into(),
4036 ),
4037 (
4038 "ArrayLiteralSegment".into(),
4039 NodeMatcher::new(
4040 SyntaxKind::ArrayLiteral,
4041 Bracketed::new(vec_of_erased![
4042 Delimited::new(vec_of_erased![Ref::new("BaseExpressionElementGrammar")])
4043 .config(|this| {
4044 this.delimiter(Ref::new("CommaSegment"));
4045 this.optional();
4046 }),
4047 ])
4048 .config(|this| {
4049 this.bracket_type("square");
4050 this.parse_mode(ParseMode::Greedy);
4051 })
4052 .to_matchable(),
4053 )
4054 .to_matchable()
4055 .into(),
4056 ),
4057 (
4058 "TypedArrayLiteralSegment".into(),
4059 NodeMatcher::new(
4060 SyntaxKind::TypedArrayLiteral,
4061 Sequence::new(vec![
4062 Ref::new("ArrayTypeSegment").to_matchable(),
4063 Ref::new("ArrayLiteralSegment").to_matchable(),
4064 ])
4065 .to_matchable(),
4066 )
4067 .to_matchable()
4068 .into(),
4069 ),
4070 (
4071 "StructTypeSegment".into(),
4072 NodeMatcher::new(SyntaxKind::StructType, Nothing::new().to_matchable())
4073 .to_matchable()
4074 .into(),
4075 ),
4076 (
4077 "StructLiteralSegment".into(),
4078 NodeMatcher::new(
4079 SyntaxKind::StructLiteral,
4080 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
4081 Sequence::new(vec_of_erased![
4082 Ref::new("BaseExpressionElementGrammar"),
4083 Ref::new("AliasExpressionSegment").optional(),
4084 ])
4085 ])])
4086 .to_matchable(),
4087 )
4088 .to_matchable()
4089 .into(),
4090 ),
4091 (
4092 "TypedStructLiteralSegment".into(),
4093 NodeMatcher::new(
4094 SyntaxKind::TypedStructLiteral,
4095 Sequence::new(vec![
4096 Ref::new("StructTypeSegment").to_matchable(),
4097 Ref::new("StructLiteralSegment").to_matchable(),
4098 ])
4099 .to_matchable(),
4100 )
4101 .to_matchable()
4102 .into(),
4103 ),
4104 (
4105 "IntervalExpressionSegment".into(),
4106 NodeMatcher::new(
4107 SyntaxKind::IntervalExpression,
4108 Sequence::new(vec![
4109 Ref::keyword("INTERVAL").to_matchable(),
4110 one_of(vec![
4111 Sequence::new(vec![
4112 Ref::new("NumericLiteralSegment").to_matchable(),
4113 one_of(vec![
4114 Ref::new("QuotedLiteralSegment").to_matchable(),
4115 Ref::new("DatetimeUnitSegment").to_matchable(),
4116 ])
4117 .to_matchable(),
4118 ])
4119 .to_matchable(),
4120 Ref::new("QuotedLiteralSegment").to_matchable(),
4121 ])
4122 .to_matchable(),
4123 ])
4124 .to_matchable(),
4125 )
4126 .to_matchable()
4127 .into(),
4128 ),
4129 (
4130 "ArrayTypeSegment".into(),
4131 NodeMatcher::new(SyntaxKind::ArrayType, Nothing::new().to_matchable())
4132 .to_matchable()
4133 .into(),
4134 ),
4135 (
4136 "SizedArrayTypeSegment".into(),
4137 NodeMatcher::new(
4138 SyntaxKind::SizedArrayType,
4139 Sequence::new(vec![
4140 Ref::new("ArrayTypeSegment").to_matchable(),
4141 Ref::new("ArrayAccessorSegment").to_matchable(),
4142 ])
4143 .to_matchable(),
4144 )
4145 .to_matchable()
4146 .into(),
4147 ),
4148 (
4149 "UnorderedSelectStatementSegment".into(),
4150 NodeMatcher::new(
4151 SyntaxKind::SelectStatement,
4152 Sequence::new(vec_of_erased![
4153 Ref::new("SelectClauseSegment"),
4154 MetaSegment::dedent(),
4155 Ref::new("FromClauseSegment").optional(),
4156 Ref::new("WhereClauseSegment").optional(),
4157 Ref::new("GroupByClauseSegment").optional(),
4158 Ref::new("HavingClauseSegment").optional(),
4159 Ref::new("OverlapsClauseSegment").optional(),
4160 Ref::new("NamedWindowSegment").optional()
4161 ])
4162 .terminators(vec_of_erased![
4163 Ref::new("SetOperatorSegment"),
4164 Ref::new("WithNoSchemaBindingClauseSegment"),
4165 Ref::new("WithDataClauseSegment"),
4166 Ref::new("OrderByClauseSegment"),
4167 Ref::new("LimitClauseSegment")
4168 ])
4169 .config(|this| {
4170 this.parse_mode(ParseMode::GreedyOnceStarted);
4171 })
4172 .to_matchable(),
4173 )
4174 .to_matchable()
4175 .into(),
4176 ),
4177 (
4178 "OverlapsClauseSegment".into(),
4179 NodeMatcher::new(
4180 SyntaxKind::OverlapsClause,
4181 Sequence::new(vec_of_erased![
4182 Ref::keyword("OVERLAPS"),
4183 one_of(vec_of_erased![
4184 Bracketed::new(vec_of_erased![
4185 Ref::new("DateTimeLiteralGrammar"),
4186 Ref::new("CommaSegment"),
4187 Ref::new("DateTimeLiteralGrammar"),
4188 ]),
4189 Ref::new("ColumnReferenceSegment"),
4190 ]),
4191 ])
4192 .to_matchable(),
4193 )
4194 .to_matchable()
4195 .into(),
4196 ),
4197 ("SelectClauseSegment".into(), {
4198 NodeMatcher::new(SyntaxKind::SelectClause, select_clause_segment())
4199 .to_matchable()
4200 .into()
4201 }),
4202 (
4203 "StatementSegment".into(),
4204 NodeMatcher::new(SyntaxKind::Statement, statement_segment())
4205 .to_matchable()
4206 .into(),
4207 ),
4208 (
4209 "WithNoSchemaBindingClauseSegment".into(),
4210 NodeMatcher::new(
4211 SyntaxKind::WithNoSchemaBindingClause,
4212 Sequence::new(vec_of_erased![
4213 Ref::keyword("WITH"),
4214 Ref::keyword("NO"),
4215 Ref::keyword("SCHEMA"),
4216 Ref::keyword("BINDING"),
4217 ])
4218 .to_matchable(),
4219 )
4220 .to_matchable()
4221 .into(),
4222 ),
4223 (
4224 "WithDataClauseSegment".into(),
4225 NodeMatcher::new(
4226 SyntaxKind::WithDataClause,
4227 Sequence::new(vec_of_erased![
4228 Ref::keyword("WITH"),
4229 Sequence::new(vec_of_erased![Ref::keyword("NO")])
4230 .config(|this| this.optional()),
4231 Ref::keyword("DATA"),
4232 ])
4233 .to_matchable(),
4234 )
4235 .to_matchable()
4236 .into(),
4237 ),
4238 (
4239 "SetExpressionSegment".into(),
4240 NodeMatcher::new(
4241 SyntaxKind::SetExpression,
4242 Sequence::new(vec_of_erased![
4243 Ref::new("NonSetSelectableGrammar"),
4244 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
4245 Ref::new("SetOperatorSegment"),
4246 Ref::new("NonSetSelectableGrammar"),
4247 ])])
4248 .config(|this| this.min_times(1)),
4249 Ref::new("OrderByClauseSegment").optional(),
4250 Ref::new("LimitClauseSegment").optional(),
4251 Ref::new("NamedWindowSegment").optional(),
4252 ])
4253 .to_matchable(),
4254 )
4255 .to_matchable()
4256 .into(),
4257 ),
4258 (
4259 "FromClauseSegment".into(),
4260 NodeMatcher::new(
4261 SyntaxKind::FromClause,
4262 Sequence::new(vec_of_erased![
4263 Ref::keyword("FROM"),
4264 Delimited::new(vec_of_erased![Ref::new("FromExpressionSegment")]),
4265 ])
4266 .to_matchable(),
4267 )
4268 .to_matchable()
4269 .into(),
4270 ),
4271 (
4272 "EmptyStructLiteralBracketsSegment".into(),
4273 NodeMatcher::new(
4274 SyntaxKind::EmptyStructLiteralBrackets,
4275 Bracketed::new(vec![]).to_matchable(),
4276 )
4277 .to_matchable()
4278 .into(),
4279 ),
4280 (
4281 "WildcardExpressionSegment".into(),
4282 NodeMatcher::new(
4283 SyntaxKind::WildcardExpression,
4284 wildcard_expression_segment(),
4285 )
4286 .to_matchable()
4287 .into(),
4288 ),
4289 (
4290 "OrderByClauseSegment".into(),
4291 NodeMatcher::new(
4292 SyntaxKind::OrderbyClause,
4293 Sequence::new(vec_of_erased![
4294 Ref::keyword("ORDER"),
4295 Ref::keyword("BY"),
4296 MetaSegment::indent(),
4297 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
4298 one_of(vec_of_erased![
4299 Ref::new("ColumnReferenceSegment"),
4300 Ref::new("NumericLiteralSegment"),
4301 Ref::new("ExpressionSegment"),
4302 ]),
4303 one_of(vec_of_erased![Ref::keyword("ASC"), Ref::keyword("DESC"),])
4304 .config(|this| this.optional()),
4305 Sequence::new(vec_of_erased![
4306 Ref::keyword("NULLS"),
4307 one_of(vec_of_erased![Ref::keyword("FIRST"), Ref::keyword("LAST"),]),
4308 ])
4309 .config(|this| this.optional()),
4310 ])])
4311 .config(|this| this.terminators =
4312 vec_of_erased![Ref::keyword("LIMIT"), Ref::new("FrameClauseUnitGrammar")]),
4313 MetaSegment::dedent(),
4314 ])
4315 .to_matchable(),
4316 )
4317 .to_matchable()
4318 .into(),
4319 ),
4320 (
4321 "TruncateStatementSegment".into(),
4322 NodeMatcher::new(
4323 SyntaxKind::TruncateStatement,
4324 Sequence::new(vec![
4325 Ref::keyword("TRUNCATE").to_matchable(),
4326 Ref::keyword("TABLE").optional().to_matchable(),
4327 Ref::new("TableReferenceSegment").to_matchable(),
4328 ])
4329 .to_matchable(),
4330 )
4331 .to_matchable()
4332 .into(),
4333 ),
4334 (
4335 "FromExpressionSegment".into(),
4336 NodeMatcher::new(
4337 SyntaxKind::FromExpression,
4338 optionally_bracketed(vec_of_erased![Sequence::new(vec_of_erased![
4339 MetaSegment::indent(),
4340 one_of(vec_of_erased![
4341 Ref::new("FromExpressionElementSegment"),
4342 Bracketed::new(vec_of_erased![Ref::new("FromExpressionSegment")])
4343 ])
4344 .config(|this| this.terminators = vec_of_erased![
4345 Sequence::new(vec_of_erased![Ref::keyword("ORDER"), Ref::keyword("BY")]),
4346 Sequence::new(vec_of_erased![Ref::keyword("GROUP"), Ref::keyword("BY")]),
4347 ]),
4348 MetaSegment::dedent(),
4349 Conditional::new(MetaSegment::indent()).indented_joins(),
4350 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
4351 one_of(vec_of_erased![
4352 Ref::new("JoinClauseSegment"),
4353 Ref::new("JoinLikeClauseGrammar")
4354 ])
4355 .config(|this| {
4356 this.optional();
4357 this.terminators = vec_of_erased![
4358 Sequence::new(vec_of_erased![
4359 Ref::keyword("ORDER"),
4360 Ref::keyword("BY")
4361 ]),
4362 Sequence::new(vec_of_erased![
4363 Ref::keyword("GROUP"),
4364 Ref::keyword("BY")
4365 ]),
4366 ];
4367 })
4368 ])]),
4369 Conditional::new(MetaSegment::dedent()).indented_joins(),
4370 ])])
4371 .to_matchable(),
4372 )
4373 .to_matchable()
4374 .into(),
4375 ),
4376 (
4377 "DatePartFunctionNameSegment".into(),
4378 NodeMatcher::new(
4379 SyntaxKind::FunctionName,
4380 Ref::new("DatePartFunctionName").to_matchable(),
4381 )
4382 .to_matchable()
4383 .into(),
4384 ),
4385 (
4386 "FromExpressionElementSegment".into(),
4387 NodeMatcher::new(
4388 SyntaxKind::FromExpressionElement,
4389 Sequence::new(vec_of_erased![
4390 Ref::new("PreTableFunctionKeywordsGrammar").optional(),
4391 optionally_bracketed(vec_of_erased![Ref::new("TableExpressionSegment")]),
4392 Ref::new("AliasExpressionSegment")
4393 .exclude(one_of(vec_of_erased![
4394 Ref::new("FromClauseTerminatorGrammar"),
4395 Ref::new("SamplingExpressionSegment"),
4396 Ref::new("JoinLikeClauseGrammar")
4397 ]))
4398 .optional(),
4399 Sequence::new(vec_of_erased![
4400 Ref::keyword("WITH"),
4401 Ref::keyword("OFFSET"),
4402 Ref::new("AliasExpressionSegment")
4403 ])
4404 .config(|this| this.optional()),
4405 Ref::new("SamplingExpressionSegment").optional(),
4406 Ref::new("PostTableExpressionGrammar").optional()
4407 ])
4408 .to_matchable(),
4409 )
4410 .to_matchable()
4411 .into(),
4412 ),
4413 (
4414 "SelectStatementSegment".into(),
4415 NodeMatcher::new(SyntaxKind::SelectStatement, select_statement())
4416 .to_matchable()
4417 .into(),
4418 ),
4419 (
4420 "CreateSchemaStatementSegment".into(),
4421 NodeMatcher::new(
4422 SyntaxKind::CreateSchemaStatement,
4423 Sequence::new(vec_of_erased![
4424 Ref::keyword("CREATE"),
4425 Ref::keyword("SCHEMA"),
4426 Ref::new("IfNotExistsGrammar").optional(),
4427 Ref::new("SchemaReferenceSegment")
4428 ])
4429 .to_matchable(),
4430 )
4431 .to_matchable()
4432 .into(),
4433 ),
4434 (
4435 "SelectClauseModifierSegment".into(),
4436 NodeMatcher::new(
4437 SyntaxKind::SelectClauseModifier,
4438 one_of(vec![
4439 Ref::keyword("DISTINCT").to_matchable(),
4440 Ref::keyword("ALL").to_matchable(),
4441 ])
4442 .to_matchable(),
4443 )
4444 .to_matchable()
4445 .into(),
4446 ),
4447 (
4448 "SelectClauseElementSegment".into(),
4449 NodeMatcher::new(SyntaxKind::SelectClauseElement, select_clause_element())
4450 .to_matchable()
4451 .into(),
4452 ),
4453 ]);
4454
4455 ansi_dialect.add([(
4457 "CharCharacterSetGrammar".into(),
4458 Nothing::new().to_matchable().into(),
4459 )]);
4460
4461 ansi_dialect.add([(
4463 "AliasedTableReferenceGrammar".into(),
4464 Sequence::new(vec_of_erased![
4465 Ref::new("TableReferenceSegment"),
4466 Ref::new("AliasExpressionSegment"),
4467 ])
4468 .to_matchable()
4469 .into(),
4470 )]);
4471
4472 ansi_dialect.add([
4473 (
4475 "FunctionContentsExpressionGrammar".into(),
4476 Ref::new("ExpressionSegment").to_matchable().into(),
4477 ),
4478 (
4479 "FunctionContentsGrammar".into(),
4480 AnyNumberOf::new(vec![
4481 Ref::new("ExpressionSegment").to_matchable(),
4482 Sequence::new(vec![
4484 Ref::new("ExpressionSegment").to_matchable(),
4485 Ref::keyword("AS").to_matchable(),
4486 Ref::new("DatatypeSegment").to_matchable(),
4487 ])
4488 .to_matchable(),
4489 Sequence::new(vec![
4491 Ref::new("TrimParametersGrammar").to_matchable(),
4492 Ref::new("ExpressionSegment")
4493 .optional()
4494 .exclude(Ref::keyword("FROM"))
4495 .to_matchable(),
4496 Ref::keyword("FROM").to_matchable(),
4497 Ref::new("ExpressionSegment").to_matchable(),
4498 ])
4499 .to_matchable(),
4500 Sequence::new(vec![
4502 one_of(vec![
4503 Ref::new("DatetimeUnitSegment").to_matchable(),
4504 Ref::new("ExpressionSegment").to_matchable(),
4505 ])
4506 .to_matchable(),
4507 Ref::keyword("FROM").to_matchable(),
4508 Ref::new("ExpressionSegment").to_matchable(),
4509 ])
4510 .to_matchable(),
4511 Sequence::new(vec![
4512 Ref::keyword("DISTINCT").optional().to_matchable(),
4514 one_of(vec![
4515 Ref::new("StarSegment").to_matchable(),
4517 Delimited::new(vec![
4518 Ref::new("FunctionContentsExpressionGrammar").to_matchable(),
4519 ])
4520 .to_matchable(),
4521 ])
4522 .to_matchable(),
4523 ])
4524 .to_matchable(),
4525 Ref::new("AggregateOrderByClause").to_matchable(), Sequence::new(vec![
4527 Ref::keyword("SEPARATOR").to_matchable(),
4528 Ref::new("LiteralGrammar").to_matchable(),
4529 ])
4530 .to_matchable(),
4531 Sequence::new(vec![
4533 one_of(vec![
4534 Ref::new("QuotedLiteralSegment").to_matchable(),
4535 Ref::new("SingleIdentifierGrammar").to_matchable(),
4536 Ref::new("ColumnReferenceSegment").to_matchable(),
4537 ])
4538 .to_matchable(),
4539 Ref::keyword("IN").to_matchable(),
4540 one_of(vec![
4541 Ref::new("QuotedLiteralSegment").to_matchable(),
4542 Ref::new("SingleIdentifierGrammar").to_matchable(),
4543 Ref::new("ColumnReferenceSegment").to_matchable(),
4544 ])
4545 .to_matchable(),
4546 ])
4547 .to_matchable(),
4548 Ref::new("IgnoreRespectNullsGrammar").to_matchable(),
4549 Ref::new("IndexColumnDefinitionSegment").to_matchable(),
4550 Ref::new("EmptyStructLiteralSegment").to_matchable(),
4551 ])
4552 .to_matchable()
4553 .into(),
4554 ),
4555 (
4556 "PostFunctionGrammar".into(),
4557 one_of(vec![
4558 Ref::new("OverClauseSegment").to_matchable(),
4559 Ref::new("FilterClauseGrammar").to_matchable(),
4560 ])
4561 .to_matchable()
4562 .into(),
4563 ),
4564 ]);
4565
4566 ansi_dialect.add([(
4569 "JoinLikeClauseGrammar".into(),
4570 Nothing::new().to_matchable().into(),
4571 )]);
4572
4573 ansi_dialect.add([
4574 (
4575 "AccessStatementSegmentGrantRoleWithOptionGrammar".into(),
4576 one_of(vec_of_erased![
4577 Sequence::new(vec_of_erased![
4578 Ref::keyword("WITH"),
4579 Ref::keyword("GRANT"),
4580 Ref::keyword("OPTION"),
4581 ]),
4582 Sequence::new(vec_of_erased![
4583 Ref::keyword("WITH"),
4584 Ref::keyword("ADMIN"),
4585 Ref::keyword("OPTION"),
4586 ]),
4587 Sequence::new(vec_of_erased![
4588 Ref::keyword("COPY"),
4589 Ref::keyword("CURRENT"),
4590 Ref::keyword("GRANTS"),
4591 ])
4592 ])
4593 .to_matchable()
4594 .into(),
4595 ),
4596 (
4597 "Expression_A_Unary_Operator_Grammar".into(),
4604 one_of(vec![
4605 Ref::new("SignedSegmentGrammar")
4608 .exclude(Sequence::new(vec![
4609 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
4610 ]))
4611 .to_matchable(),
4612 Ref::new("TildeSegment").to_matchable(),
4613 Ref::new("NotOperatorGrammar").to_matchable(),
4614 Ref::keyword("PRIOR").to_matchable(),
4616 ])
4617 .to_matchable()
4618 .into(),
4619 ),
4620 (
4621 "Tail_Recurse_Expression_A_Grammar".into(),
4622 Sequence::new(vec_of_erased![
4623 AnyNumberOf::new(vec_of_erased![Ref::new("Expression_A_Unary_Operator_Grammar")])
4627 .config(
4628 |this| this.terminators = vec_of_erased![Ref::new("BinaryOperatorGrammar")]
4629 ),
4630 Ref::new("Expression_C_Grammar"),
4631 ])
4632 .to_matchable()
4633 .into(),
4634 ),
4635 (
4636 "Expression_A_Grammar".into(),
4637 Sequence::new(vec![
4638 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4639 AnyNumberOf::new(vec![
4640 one_of(vec![
4641 Sequence::new(vec![
4643 Sequence::new(vec![
4644 Ref::keyword("NOT").optional().to_matchable(),
4645 Ref::new("LikeGrammar").to_matchable(),
4646 ])
4647 .to_matchable(),
4648 Ref::new("Expression_A_Grammar").to_matchable(),
4649 Sequence::new(vec![
4650 Ref::keyword("ESCAPE").to_matchable(),
4651 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4652 ])
4653 .config(|this| this.optional())
4654 .to_matchable(),
4655 ])
4656 .to_matchable(),
4657 Sequence::new(vec![
4659 Ref::new("BinaryOperatorGrammar").to_matchable(),
4660 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4661 ])
4662 .to_matchable(),
4663 Sequence::new(vec![
4665 Ref::keyword("NOT").optional().to_matchable(),
4666 Ref::keyword("IN").to_matchable(),
4667 Bracketed::new(vec![
4668 one_of(vec![
4669 Delimited::new(vec![
4670 Ref::new("Expression_A_Grammar").to_matchable(),
4671 ])
4672 .to_matchable(),
4673 Ref::new("SelectableGrammar").to_matchable(),
4674 ])
4675 .to_matchable(),
4676 ])
4677 .config(|this| this.parse_mode(ParseMode::Greedy))
4678 .to_matchable(),
4679 ])
4680 .to_matchable(),
4681 Sequence::new(vec![
4683 Ref::keyword("NOT").optional().to_matchable(),
4684 Ref::keyword("IN").to_matchable(),
4685 Ref::new("FunctionSegment").to_matchable(),
4686 ])
4687 .to_matchable(),
4688 Sequence::new(vec![
4690 Ref::keyword("IS").to_matchable(),
4691 Ref::keyword("NOT").optional().to_matchable(),
4692 Ref::new("IsClauseGrammar").to_matchable(),
4693 ])
4694 .to_matchable(),
4695 Ref::new("IsNullGrammar").to_matchable(),
4697 Ref::new("NotNullGrammar").to_matchable(),
4698 Ref::new("CollateGrammar").to_matchable(),
4700 Sequence::new(vec![
4702 Ref::keyword("NOT").optional().to_matchable(),
4703 Ref::keyword("BETWEEN").to_matchable(),
4704 Ref::new("Expression_B_Grammar").to_matchable(),
4705 Ref::keyword("AND").to_matchable(),
4706 Ref::new("Tail_Recurse_Expression_A_Grammar").to_matchable(),
4707 ])
4708 .to_matchable(),
4709 ])
4711 .to_matchable(),
4712 ])
4713 .to_matchable(),
4714 ])
4715 .to_matchable()
4716 .into(),
4717 ),
4718 (
4725 "Expression_B_Unary_Operator_Grammar".into(),
4726 one_of(vec![
4727 Ref::new("SignedSegmentGrammar")
4728 .exclude(Sequence::new(vec![
4729 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
4730 ]))
4731 .to_matchable(),
4732 Ref::new("TildeSegment").to_matchable(),
4733 ])
4734 .to_matchable()
4735 .into(),
4736 ),
4737 (
4738 "Tail_Recurse_Expression_B_Grammar".into(),
4739 Sequence::new(vec![
4740 AnyNumberOf::new(vec![
4743 Ref::new("Expression_B_Unary_Operator_Grammar").to_matchable(),
4744 ])
4745 .to_matchable(),
4746 Ref::new("Expression_C_Grammar").to_matchable(),
4747 ])
4748 .to_matchable()
4749 .into(),
4750 ),
4751 (
4752 "Expression_B_Grammar".into(),
4753 Sequence::new(vec![
4754 Ref::new("Tail_Recurse_Expression_B_Grammar").to_matchable(),
4756 AnyNumberOf::new(vec![
4757 one_of(vec![
4758 Sequence::new(vec![
4761 one_of(vec![
4762 Ref::new("ArithmeticBinaryOperatorGrammar").to_matchable(),
4763 Ref::new("StringBinaryOperatorGrammar").to_matchable(),
4764 Ref::new("ComparisonOperatorGrammar").to_matchable(),
4765 ])
4766 .to_matchable(),
4767 Ref::new("Tail_Recurse_Expression_B_Grammar").to_matchable(),
4768 ])
4769 .to_matchable(),
4770 ])
4772 .to_matchable(),
4773 ])
4774 .to_matchable(),
4775 ])
4776 .to_matchable()
4777 .into(),
4778 ),
4779 (
4780 "Expression_C_Grammar".into(),
4781 one_of(vec![
4782 Sequence::new(vec![
4784 Ref::keyword("EXISTS").to_matchable(),
4785 Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
4786 .to_matchable(),
4787 ])
4788 .to_matchable(),
4789 Sequence::new(vec![
4792 one_of(vec![
4793 Ref::new("Expression_D_Grammar").to_matchable(),
4794 Ref::new("CaseExpressionSegment").to_matchable(),
4795 ])
4796 .to_matchable(),
4797 AnyNumberOf::new(vec![Ref::new("TimeZoneGrammar").to_matchable()])
4798 .config(|this| this.optional())
4799 .to_matchable(),
4800 ])
4801 .to_matchable(),
4802 Ref::new("ShorthandCastSegment").to_matchable(),
4803 ])
4804 .config(|this| this.terminators = vec_of_erased![Ref::new("CommaSegment")])
4805 .to_matchable()
4806 .into(),
4807 ),
4808 (
4809 "Expression_D_Grammar".into(),
4810 Sequence::new(vec![
4811 one_of(vec![
4812 Ref::new("BareFunctionSegment").to_matchable(),
4813 Ref::new("FunctionSegment").to_matchable(),
4814 Bracketed::new(vec![
4815 one_of(vec![
4816 Ref::new("ExpressionSegment").to_matchable(),
4817 Ref::new("SelectableGrammar").to_matchable(),
4818 Delimited::new(vec![
4819 Ref::new("ColumnReferenceSegment").to_matchable(),
4820 Ref::new("FunctionSegment").to_matchable(),
4821 Ref::new("LiteralGrammar").to_matchable(),
4822 Ref::new("LocalAliasSegment").to_matchable(),
4823 ])
4824 .to_matchable(),
4825 ])
4826 .to_matchable(),
4827 ])
4828 .config(|this| this.parse_mode(ParseMode::Greedy))
4829 .to_matchable(),
4830 Ref::new("SelectStatementSegment").to_matchable(),
4831 Ref::new("LiteralGrammar").to_matchable(),
4832 Ref::new("IntervalExpressionSegment").to_matchable(),
4833 Ref::new("TypedStructLiteralSegment").to_matchable(),
4834 Ref::new("ArrayExpressionSegment").to_matchable(),
4835 Ref::new("ColumnReferenceSegment").to_matchable(),
4836 Sequence::new(vec![
4837 Ref::new("SingleIdentifierGrammar").to_matchable(),
4838 Ref::new("ObjectReferenceDelimiterGrammar").to_matchable(),
4839 Ref::new("StarSegment").to_matchable(),
4840 ])
4841 .to_matchable(),
4842 Sequence::new(vec![
4843 Ref::new("StructTypeSegment").to_matchable(),
4844 Bracketed::new(vec![
4845 Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4846 .to_matchable(),
4847 ])
4848 .to_matchable(),
4849 ])
4850 .to_matchable(),
4851 Sequence::new(vec![
4852 Ref::new("DatatypeSegment").to_matchable(),
4853 one_of(vec![
4854 Ref::new("QuotedLiteralSegment").to_matchable(),
4855 Ref::new("NumericLiteralSegment").to_matchable(),
4856 Ref::new("BooleanLiteralGrammar").to_matchable(),
4857 Ref::new("NullLiteralSegment").to_matchable(),
4858 Ref::new("DateTimeLiteralGrammar").to_matchable(),
4859 ])
4860 .to_matchable(),
4861 ])
4862 .to_matchable(),
4863 Ref::new("LocalAliasSegment").to_matchable(),
4864 ])
4865 .config(|this| this.terminators = vec_of_erased![Ref::new("CommaSegment")])
4866 .to_matchable(),
4867 Ref::new("AccessorGrammar").optional().to_matchable(),
4868 ])
4869 .allow_gaps(true)
4870 .to_matchable()
4871 .into(),
4872 ),
4873 (
4874 "AccessorGrammar".into(),
4875 AnyNumberOf::new(vec![Ref::new("ArrayAccessorSegment").to_matchable()])
4876 .to_matchable()
4877 .into(),
4878 ),
4879 ]);
4880
4881 ansi_dialect.add([
4882 (
4883 "SelectableGrammar".into(),
4884 one_of(vec_of_erased![
4885 optionally_bracketed(vec_of_erased![Ref::new("WithCompoundStatementSegment")]),
4886 optionally_bracketed(vec_of_erased![Ref::new(
4887 "WithCompoundNonSelectStatementSegment"
4888 )]),
4889 Ref::new("NonWithSelectableGrammar"),
4890 Bracketed::new(vec_of_erased![Ref::new("SelectableGrammar")]),
4891 ])
4892 .to_matchable()
4893 .into(),
4894 ),
4895 (
4896 "NonWithSelectableGrammar".into(),
4897 one_of(vec![
4898 Ref::new("SetExpressionSegment").to_matchable(),
4899 optionally_bracketed(vec![Ref::new("SelectStatementSegment").to_matchable()])
4900 .to_matchable(),
4901 Ref::new("NonSetSelectableGrammar").to_matchable(),
4902 ])
4903 .to_matchable()
4904 .into(),
4905 ),
4906 (
4907 "NonWithNonSelectableGrammar".into(),
4908 one_of(vec![
4909 Ref::new("UpdateStatementSegment").to_matchable(),
4910 Ref::new("InsertStatementSegment").to_matchable(),
4911 Ref::new("DeleteStatementSegment").to_matchable(),
4912 ])
4913 .to_matchable()
4914 .into(),
4915 ),
4916 (
4917 "NonSetSelectableGrammar".into(),
4918 one_of(vec![
4919 Ref::new("ValuesClauseSegment").to_matchable(),
4920 Ref::new("UnorderedSelectStatementSegment").to_matchable(),
4921 Bracketed::new(vec![Ref::new("SelectStatementSegment").to_matchable()])
4922 .to_matchable(),
4923 Bracketed::new(vec![
4924 Ref::new("WithCompoundStatementSegment").to_matchable(),
4925 ])
4926 .to_matchable(),
4927 Bracketed::new(vec![Ref::new("NonSetSelectableGrammar").to_matchable()])
4928 .to_matchable(),
4929 ])
4930 .to_matchable()
4931 .into(),
4932 ),
4933 ]);
4934
4935 ansi_dialect.add([
4937 (
4938 "PostTableExpressionGrammar".into(),
4939 Nothing::new().to_matchable().into(),
4940 ),
4941 (
4942 "BracketedSegment".into(),
4943 BracketedSegmentMatcher::new().to_matchable().into(),
4944 ),
4945 ]);
4946
4947 ansi_dialect
4948}
4949
4950pub fn select_clause_element() -> Matchable {
4951 one_of(vec_of_erased![
4952 Ref::new("WildcardExpressionSegment"),
4954 Sequence::new(vec_of_erased![
4955 Ref::new("BaseExpressionElementGrammar"),
4956 Ref::new("AliasExpressionSegment").optional(),
4957 ]),
4958 ])
4959 .to_matchable()
4960}
4961
4962fn lexer_matchers() -> Vec<Matcher> {
4963 vec![
4964 Matcher::regex("whitespace", r"[^\S\r\n]+", SyntaxKind::Whitespace),
4965 Matcher::regex("inline_comment", r"(--|#)[^\n]*", SyntaxKind::InlineComment),
4966 Matcher::native("block_comment", block_comment, SyntaxKind::BlockComment)
4967 .subdivider(Pattern::legacy(
4968 "newline",
4969 |_| true,
4970 r"\r\n|\n",
4971 SyntaxKind::Newline,
4972 ))
4973 .post_subdivide(Pattern::legacy(
4974 "whitespace",
4975 |_| true,
4976 r"[^\S\r\n]+",
4977 SyntaxKind::Whitespace,
4978 )),
4979 Matcher::regex(
4980 "single_quote",
4981 r"'([^'\\]|\\.|'')*'",
4982 SyntaxKind::SingleQuote,
4983 ),
4984 Matcher::regex(
4985 "double_quote",
4986 r#""([^"\\]|\\.)*""#,
4987 SyntaxKind::DoubleQuote,
4988 ),
4989 Matcher::regex("back_quote", r"`[^`]*`", SyntaxKind::BackQuote),
4990 Matcher::legacy(
4991 "dollar_quote",
4992 |s| s.starts_with("$"),
4993 r"\$(\w*)\$[\s\S]*?\$\1\$",
4994 SyntaxKind::DollarQuote,
4995 ),
4996 Matcher::native(
4997 "numeric_literal",
4998 numeric_literal,
4999 SyntaxKind::NumericLiteral,
5000 ),
5001 Matcher::regex("like_operator", r"!?~~?\*?", SyntaxKind::LikeOperator),
5002 Matcher::regex("newline", r"(\r\n|\n)", SyntaxKind::Newline),
5003 Matcher::string("casting_operator", "::", SyntaxKind::CastingOperator),
5004 Matcher::string("equals", "=", SyntaxKind::RawComparisonOperator),
5005 Matcher::string("greater_than", ">", SyntaxKind::RawComparisonOperator),
5006 Matcher::string("less_than", "<", SyntaxKind::RawComparisonOperator),
5007 Matcher::string("not", "!", SyntaxKind::RawComparisonOperator),
5008 Matcher::string("dot", ".", SyntaxKind::Dot),
5009 Matcher::string("comma", ",", SyntaxKind::Comma),
5010 Matcher::string("plus", "+", SyntaxKind::Plus),
5011 Matcher::string("minus", "-", SyntaxKind::Minus),
5012 Matcher::string("divide", "/", SyntaxKind::Divide),
5013 Matcher::string("percent", "%", SyntaxKind::Percent),
5014 Matcher::string("question", "?", SyntaxKind::Question),
5015 Matcher::string("ampersand", "&", SyntaxKind::Ampersand),
5016 Matcher::string("vertical_bar", "|", SyntaxKind::VerticalBar),
5017 Matcher::string("caret", "^", SyntaxKind::Caret),
5018 Matcher::string("star", "*", SyntaxKind::Star),
5019 Matcher::string("start_bracket", "(", SyntaxKind::StartBracket),
5020 Matcher::string("end_bracket", ")", SyntaxKind::EndBracket),
5021 Matcher::string("start_square_bracket", "[", SyntaxKind::StartSquareBracket),
5022 Matcher::string("end_square_bracket", "]", SyntaxKind::EndSquareBracket),
5023 Matcher::string("start_curly_bracket", "{", SyntaxKind::StartCurlyBracket),
5024 Matcher::string("end_curly_bracket", "}", SyntaxKind::EndCurlyBracket),
5025 Matcher::string("colon", ":", SyntaxKind::Colon),
5026 Matcher::string("semicolon", ";", SyntaxKind::Semicolon),
5027 Matcher::regex("word", "[0-9a-zA-Z_]+", SyntaxKind::Word),
5028 ]
5029}
5030
5031pub fn frame_extent() -> AnyNumberOf {
5032 one_of(vec_of_erased![
5033 Sequence::new(vec_of_erased![Ref::keyword("CURRENT"), Ref::keyword("ROW")]),
5034 Sequence::new(vec_of_erased![
5035 one_of(vec_of_erased![
5036 Ref::new("NumericLiteralSegment"),
5037 Sequence::new(vec_of_erased![
5038 Ref::keyword("INTERVAL"),
5039 Ref::new("QuotedLiteralSegment")
5040 ]),
5041 Ref::keyword("UNBOUNDED")
5042 ]),
5043 one_of(vec_of_erased![
5044 Ref::keyword("PRECEDING"),
5045 Ref::keyword("FOLLOWING")
5046 ])
5047 ])
5048 ])
5049}
5050
5051pub fn explainable_stmt() -> AnyNumberOf {
5052 one_of(vec_of_erased![
5053 Ref::new("SelectableGrammar"),
5054 Ref::new("InsertStatementSegment"),
5055 Ref::new("UpdateStatementSegment"),
5056 Ref::new("DeleteStatementSegment")
5057 ])
5058}
5059
5060pub fn get_unordered_select_statement_segment_grammar() -> Matchable {
5061 Sequence::new(vec_of_erased![
5062 Ref::new("SelectClauseSegment"),
5063 MetaSegment::dedent(),
5064 Ref::new("FromClauseSegment").optional(),
5065 Ref::new("WhereClauseSegment").optional(),
5066 Ref::new("GroupByClauseSegment").optional(),
5067 Ref::new("HavingClauseSegment").optional(),
5068 Ref::new("OverlapsClauseSegment").optional(),
5069 Ref::new("NamedWindowSegment").optional()
5070 ])
5071 .terminators(vec_of_erased![
5072 Ref::new("SetOperatorSegment"),
5073 Ref::new("WithNoSchemaBindingClauseSegment"),
5074 Ref::new("WithDataClauseSegment"),
5075 Ref::new("OrderByClauseSegment"),
5076 Ref::new("LimitClauseSegment")
5077 ])
5078 .config(|this| {
5079 this.parse_mode(ParseMode::GreedyOnceStarted);
5080 })
5081 .to_matchable()
5082}
5083
5084pub fn select_statement() -> Matchable {
5085 get_unordered_select_statement_segment_grammar().copy(
5086 Some(vec_of_erased![
5087 Ref::new("OrderByClauseSegment").optional(),
5088 Ref::new("FetchClauseSegment").optional(),
5089 Ref::new("LimitClauseSegment").optional(),
5090 Ref::new("NamedWindowSegment").optional()
5091 ]),
5092 None,
5093 None,
5094 None,
5095 vec_of_erased![
5096 Ref::new("SetOperatorSegment"),
5097 Ref::new("WithNoSchemaBindingClauseSegment"),
5098 Ref::new("WithDataClauseSegment")
5099 ],
5100 true,
5101 )
5102}
5103
5104pub fn select_clause_segment() -> Matchable {
5105 Sequence::new(vec_of_erased![
5106 Ref::keyword("SELECT"),
5107 Ref::new("SelectClauseModifierSegment").optional(),
5108 MetaSegment::indent(),
5109 Delimited::new(vec_of_erased![Ref::new("SelectClauseElementSegment")])
5110 .config(|this| this.allow_trailing()),
5111 ])
5112 .terminators(vec_of_erased![Ref::new("SelectClauseTerminatorGrammar")])
5113 .config(|this| {
5114 this.parse_mode(ParseMode::GreedyOnceStarted);
5115 })
5116 .to_matchable()
5117}
5118
5119pub fn statement_segment() -> Matchable {
5120 one_of(vec![
5121 Ref::new("SelectableGrammar").to_matchable(),
5122 Ref::new("MergeStatementSegment").to_matchable(),
5123 Ref::new("InsertStatementSegment").to_matchable(),
5124 Ref::new("TransactionStatementSegment").to_matchable(),
5125 Ref::new("DropTableStatementSegment").to_matchable(),
5126 Ref::new("DropViewStatementSegment").to_matchable(),
5127 Ref::new("CreateUserStatementSegment").to_matchable(),
5128 Ref::new("DropUserStatementSegment").to_matchable(),
5129 Ref::new("TruncateStatementSegment").to_matchable(),
5130 Ref::new("AccessStatementSegment").to_matchable(),
5131 Ref::new("CreateTableStatementSegment").to_matchable(),
5132 Ref::new("CreateRoleStatementSegment").to_matchable(),
5133 Ref::new("DropRoleStatementSegment").to_matchable(),
5134 Ref::new("AlterTableStatementSegment").to_matchable(),
5135 Ref::new("CreateSchemaStatementSegment").to_matchable(),
5136 Ref::new("SetSchemaStatementSegment").to_matchable(),
5137 Ref::new("DropSchemaStatementSegment").to_matchable(),
5138 Ref::new("DropTypeStatementSegment").to_matchable(),
5139 Ref::new("CreateDatabaseStatementSegment").to_matchable(),
5140 Ref::new("DropDatabaseStatementSegment").to_matchable(),
5141 Ref::new("CreateIndexStatementSegment").to_matchable(),
5142 Ref::new("DropIndexStatementSegment").to_matchable(),
5143 Ref::new("CreateViewStatementSegment").to_matchable(),
5144 Ref::new("DeleteStatementSegment").to_matchable(),
5145 Ref::new("UpdateStatementSegment").to_matchable(),
5146 Ref::new("CreateCastStatementSegment").to_matchable(),
5147 Ref::new("DropCastStatementSegment").to_matchable(),
5148 Ref::new("CreateFunctionStatementSegment").to_matchable(),
5149 Ref::new("DropFunctionStatementSegment").to_matchable(),
5150 Ref::new("CreateModelStatementSegment").to_matchable(),
5151 Ref::new("DropModelStatementSegment").to_matchable(),
5152 Ref::new("DescribeStatementSegment").to_matchable(),
5153 Ref::new("UseStatementSegment").to_matchable(),
5154 Ref::new("ExplainStatementSegment").to_matchable(),
5155 Ref::new("CreateSequenceStatementSegment").to_matchable(),
5156 Ref::new("AlterSequenceStatementSegment").to_matchable(),
5157 Ref::new("DropSequenceStatementSegment").to_matchable(),
5158 Ref::new("CreateTriggerStatementSegment").to_matchable(),
5159 Ref::new("DropTriggerStatementSegment").to_matchable(),
5160 ])
5161 .config(|this| this.terminators = vec_of_erased![Ref::new("DelimiterGrammar")])
5162 .to_matchable()
5163}
5164
5165pub fn wildcard_expression_segment() -> Matchable {
5166 Sequence::new(vec![Ref::new("WildcardIdentifierSegment").to_matchable()]).to_matchable()
5167}
5168
5169fn numeric_literal(cursor: &mut Cursor) -> bool {
5170 let first_char = cursor.shift();
5171 match first_char {
5172 '0'..='9' | '.' => {
5173 let has_decimal = first_char == '.';
5174
5175 if has_decimal {
5176 if cursor.peek().is_ascii_digit() {
5177 cursor.shift_while(|c| c.is_ascii_digit());
5178 } else {
5179 return false;
5180 }
5181 } else {
5182 cursor.shift_while(|c| c.is_ascii_digit());
5183 if cursor.peek() == '.' {
5184 cursor.shift();
5185 cursor.shift_while(|c| c.is_ascii_digit());
5186 }
5187 }
5188
5189 if let 'e' | 'E' = cursor.peek() {
5190 cursor.shift();
5191 if let '+' | '-' = cursor.peek() {
5192 cursor.shift();
5193 }
5194 let mut exp_digits = false;
5195 while cursor.peek().is_ascii_digit() {
5196 cursor.shift();
5197 exp_digits = true;
5198 }
5199 if !exp_digits {
5200 return false;
5201 }
5202 }
5203
5204 let next_char = cursor.peek();
5205 if next_char == '.' || next_char.is_ascii_alphanumeric() || next_char == '_' {
5206 return false;
5207 }
5208
5209 true
5210 }
5211 _ => false,
5212 }
5213}
5214
5215fn block_comment(cursor: &mut Cursor) -> bool {
5216 if cursor.shift() != '/' {
5217 return false;
5218 }
5219
5220 if cursor.shift() != '*' {
5221 return false;
5222 }
5223
5224 let mut depth = 1usize;
5225
5226 loop {
5227 match cursor.shift() {
5228 '\0' => return false,
5229 '/' if cursor.peek() == '*' => {
5230 cursor.shift();
5231 depth += 1;
5232 }
5233 '*' if cursor.peek() == '/' => {
5234 cursor.shift();
5235 depth -= 1;
5236 if depth == 0 {
5237 break true;
5238 }
5239 }
5240 _ => {}
5241 }
5242 }
5243}
5244
5245pub(crate) fn select_clause_terminators() -> Vec<Matchable> {
5246 vec_of_erased![
5247 Ref::keyword("FROM"),
5248 Ref::keyword("WHERE"),
5249 Sequence::new(vec_of_erased![Ref::keyword("ORDER"), Ref::keyword("BY")]),
5250 Ref::keyword("LIMIT"),
5251 Ref::keyword("OVERLAPS"),
5252 Ref::new("SetOperatorSegment"),
5253 Ref::keyword("FETCH"),
5254 ]
5255}