1use itertools::Itertools;
2use sqruff_lib_core::dialects::base::Dialect;
3use sqruff_lib_core::dialects::init::DialectKind;
4use sqruff_lib_core::dialects::syntax::SyntaxKind;
5use sqruff_lib_core::helpers::{Config, ToMatchable};
6use sqruff_lib_core::parser::grammar::anyof::{AnyNumberOf, one_of, optionally_bracketed};
7use sqruff_lib_core::parser::grammar::base::{Anything, Nothing, Ref};
8use sqruff_lib_core::parser::grammar::delimited::Delimited;
9use sqruff_lib_core::parser::grammar::sequence::{Bracketed, Sequence};
10use sqruff_lib_core::parser::lexer::Matcher;
11use sqruff_lib_core::parser::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::generator::SegmentGenerator;
15use sqruff_lib_core::parser::segments::meta::MetaSegment;
16use sqruff_lib_core::parser::types::ParseMode;
17use sqruff_lib_core::vec_of_erased;
18
19use super::ansi::{self, raw_dialect};
20use super::bigquery_keywords::{BIGQUERY_RESERVED_KEYWORDS, BIGQUERY_UNRESERVED_KEYWORDS};
21
22pub fn dialect() -> Dialect {
23 let mut dialect = raw_dialect();
24 dialect.name = DialectKind::Bigquery;
25
26 dialect.insert_lexer_matchers(
27 vec![
28 Matcher::string("right_arrow", "=>", SyntaxKind::RightArrow),
29 Matcher::string("question_mark", "?", SyntaxKind::QuestionMark),
30 Matcher::regex(
31 "at_sign_literal",
32 r"@[a-zA-Z_][\w]*",
33 SyntaxKind::AtSignLiteral,
34 ),
35 ],
36 "equals",
37 );
38
39 dialect.patch_lexer_matchers(vec![
40 Matcher::legacy(
41 "single_quote",
42 |s| s.starts_with(['\'', 'R', 'r', 'B', 'b'].as_ref()),
43 r"([rR]?[bB]?|[bB]?[rR]?)?('''((?<!\\)(\\{2})*\\'|'{,2}(?!')|[^'])*(?<!\\)(\\{2})*'''|'((?<!\\)(\\{2})*\\'|[^'])*(?<!\\)(\\{2})*')",
44 SyntaxKind::SingleQuote
45 ),
46 Matcher::legacy(
47 "double_quote",
48 |s| s.starts_with(['"', 'R', 'r', 'B', 'b']),
49 r#"([rR]?[bB]?|[bB]?[rR]?)?(\"\"\"((?<!\\)(\\{2})*\\\"|\"{,2}(?!\")|[^\"])*(?<!\\)(\\{2})*\"\"\"|"((?<!\\)(\\{2})*\\"|[^"])*(?<!\\)(\\{2})*")"#,
50 SyntaxKind::DoubleQuote
51 ),
52 ]);
53
54 dialect.add([
55 (
56 "DoubleQuotedLiteralSegment".into(),
57 TypedParser::new(SyntaxKind::DoubleQuote, SyntaxKind::QuotedLiteral)
58 .to_matchable()
59 .into(),
60 ),
61 (
62 "SingleQuotedLiteralSegment".into(),
63 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::QuotedLiteral)
64 .to_matchable()
65 .into(),
66 ),
67 (
68 "DoubleQuotedUDFBody".into(),
69 TypedParser::new(SyntaxKind::DoubleQuote, SyntaxKind::UdfBody)
70 .to_matchable()
71 .into(),
72 ),
73 (
74 "SingleQuotedUDFBody".into(),
75 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::UdfBody)
76 .to_matchable()
77 .into(),
78 ),
79 (
80 "StartAngleBracketSegment".into(),
81 StringParser::new("<", SyntaxKind::StartAngleBracket)
82 .to_matchable()
83 .into(),
84 ),
85 (
86 "EndAngleBracketSegment".into(),
87 StringParser::new(">", SyntaxKind::EndAngleBracket)
88 .to_matchable()
89 .into(),
90 ),
91 (
92 "RightArrowSegment".into(),
93 StringParser::new("=>", SyntaxKind::RightArrow)
94 .to_matchable()
95 .into(),
96 ),
97 (
98 "DashSegment".into(),
99 StringParser::new("-", SyntaxKind::Dash)
100 .to_matchable()
101 .into(),
102 ),
103 (
104 "SingleIdentifierFullGrammar".into(),
105 one_of(vec_of_erased![
106 Ref::new("NakedIdentifierSegment"),
107 Ref::new("QuotedIdentifierSegment"),
108 Ref::new("NakedIdentifierFullSegment"),
109 ])
110 .to_matchable()
111 .into(),
112 ),
113 (
114 "QuestionMarkSegment".into(),
115 StringParser::new("?", SyntaxKind::QuestionMark)
116 .to_matchable()
117 .into(),
118 ),
119 (
120 "AtSignLiteralSegment".into(),
121 TypedParser::new(SyntaxKind::AtSignLiteral, SyntaxKind::AtSignLiteral)
122 .to_matchable()
123 .into(),
124 ),
125 (
126 "DefaultDeclareOptionsGrammar".into(),
127 Sequence::new(vec_of_erased![
128 Ref::keyword("DEFAULT"),
129 one_of(vec_of_erased![
130 Ref::new("LiteralGrammar"),
131 Bracketed::new(vec_of_erased![Ref::new("SelectStatementSegment")]),
132 Ref::new("BareFunctionSegment"),
133 Ref::new("FunctionSegment"),
134 Ref::new("ArrayLiteralSegment"),
135 Ref::new("TupleSegment"),
136 Ref::new("BaseExpressionElementGrammar")
137 ])
138 .config(|this| {
139 this.terminators = vec_of_erased![Ref::new("SemicolonSegment")];
140 })
141 ])
142 .to_matchable()
143 .into(),
144 ),
145 (
146 "ExtendedDatetimeUnitSegment".into(),
147 SegmentGenerator::new(|dialect| {
148 MultiStringParser::new(
149 dialect
150 .sets("extended_datetime_units")
151 .into_iter()
152 .map_into()
153 .collect_vec(),
154 SyntaxKind::DatePart,
155 )
156 .to_matchable()
157 })
158 .into(),
159 ),
160 (
161 "NakedIdentifierFullSegment".into(),
162 RegexParser::new("[A-Z_][A-Z0-9_]*", SyntaxKind::NakedIdentifierAll)
163 .to_matchable()
164 .into(),
165 ),
166 (
167 "NakedIdentifierPart".into(),
168 RegexParser::new("[A-Z0-9_]+", SyntaxKind::NakedIdentifier)
169 .to_matchable()
170 .into(),
171 ),
172 (
173 "ProcedureNameIdentifierSegment".into(),
174 one_of(vec_of_erased![
175 RegexParser::new("[A-Z_][A-Z0-9_]*", SyntaxKind::ProcedureNameIdentifier)
176 .anti_template("STRUCT"),
177 RegexParser::new("`[^`]*`", SyntaxKind::ProcedureNameIdentifier),
178 ])
179 .to_matchable()
180 .into(),
181 ),
182 (
183 "ProcedureParameterGrammar".into(),
184 one_of(vec_of_erased![
185 Sequence::new(vec_of_erased![
186 one_of(vec_of_erased![
187 Ref::keyword("IN"),
188 Ref::keyword("OUT"),
189 Ref::keyword("INOUT"),
190 ])
191 .config(|this| this.optional()),
192 Ref::new("ParameterNameSegment").optional(),
193 one_of(vec_of_erased![
194 Sequence::new(vec_of_erased![Ref::keyword("ANY"), Ref::keyword("TYPE")]),
195 Ref::new("DatatypeSegment")
196 ])
197 ]),
198 one_of(vec_of_erased![
199 Sequence::new(vec_of_erased![Ref::keyword("ANY"), Ref::keyword("TYPE")]),
200 Ref::new("DatatypeSegment")
201 ])
202 ])
203 .to_matchable()
204 .into(),
205 ),
206 ]);
207
208 dialect.add([
209 (
210 "NakedIdentifierSegment".into(),
211 SegmentGenerator::new(|dialect| {
212 let reserved_keywords = dialect.sets("reserved_keywords");
214 let pattern = reserved_keywords.iter().join("|");
215 let anti_template = format!("^({})$", pattern);
216
217 RegexParser::new("[A-Z_][A-Z0-9_]*", SyntaxKind::NakedIdentifier)
218 .anti_template(&anti_template)
219 .to_matchable()
220 })
221 .into(),
222 ),
223 (
224 "FunctionContentsExpressionGrammar".into(),
225 one_of(vec_of_erased![
226 Ref::new("DatetimeUnitSegment"),
227 Ref::new("DatePartWeekSegment"),
228 Sequence::new(vec_of_erased![
229 Ref::new("ExpressionSegment"),
230 Sequence::new(vec_of_erased![
231 one_of(vec_of_erased![
232 Ref::keyword("IGNORE"),
233 Ref::keyword("RESPECT")
234 ]),
235 Ref::keyword("NULLS")
236 ])
237 .config(|this| this.optional())
238 ]),
239 Ref::new("NamedArgumentSegment")
240 ])
241 .to_matchable()
242 .into(),
243 ),
244 (
245 "TrimParametersGrammar".into(),
246 Nothing::new().to_matchable().into(),
247 ),
248 (
249 "ParameterNameSegment".into(),
250 one_of(vec_of_erased![
251 RegexParser::new("[A-Z_][A-Z0-9_]*", SyntaxKind::Parameter),
252 RegexParser::new("`[^`]*`", SyntaxKind::Parameter)
253 ])
254 .to_matchable()
255 .into(),
256 ),
257 (
258 "DateTimeLiteralGrammar".into(),
259 Sequence::new(vec_of_erased![
260 one_of(vec_of_erased![
261 Ref::keyword("DATE"),
262 Ref::keyword("DATETIME"),
263 Ref::keyword("TIME"),
264 Ref::keyword("TIMESTAMP")
265 ]),
266 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::DateConstructorLiteral)
267 ])
268 .to_matchable()
269 .into(),
270 ),
271 (
272 "JoinLikeClauseGrammar".into(),
273 Sequence::new(vec_of_erased![
274 AnyNumberOf::new(vec_of_erased![
275 Ref::new("FromPivotExpressionSegment"),
276 Ref::new("FromUnpivotExpressionSegment")
277 ])
278 .config(|this| this.min_times = 1),
279 Ref::new("AliasExpressionSegment").optional()
280 ])
281 .to_matchable()
282 .into(),
283 ),
284 (
285 "NaturalJoinKeywordsGrammar".into(),
286 Nothing::new().to_matchable().into(),
287 ),
288 (
289 "AccessorGrammar".into(),
290 AnyNumberOf::new(vec_of_erased![
291 Ref::new("ArrayAccessorSegment"),
292 Ref::new("SemiStructuredAccessorSegment")
293 ])
294 .to_matchable()
295 .into(),
296 ),
297 (
298 "MergeIntoLiteralGrammar".into(),
299 Sequence::new(vec_of_erased![
300 Ref::keyword("MERGE"),
301 Ref::keyword("INTO").optional()
302 ])
303 .to_matchable()
304 .into(),
305 ),
306 (
307 "PrimaryKeyGrammar".into(),
308 Nothing::new().to_matchable().into(),
309 ),
310 (
311 "ForeignKeyGrammar".into(),
312 Nothing::new().to_matchable().into(),
313 ),
314 ]);
315
316 dialect.sets_mut("unreserved_keywords").clear();
318 dialect.update_keywords_set_from_multiline_string(
319 "unreserved_keywords",
320 BIGQUERY_UNRESERVED_KEYWORDS,
321 );
322
323 dialect.sets_mut("reserved_keywords").clear();
324 dialect
325 .update_keywords_set_from_multiline_string("reserved_keywords", BIGQUERY_RESERVED_KEYWORDS);
326
327 dialect.sets_mut("datetime_units").extend([
330 "MICROSECOND",
331 "MILLISECOND",
332 "SECOND",
333 "MINUTE",
334 "HOUR",
335 "DAY",
336 "DAYOFWEEK",
337 "DAYOFYEAR",
338 "WEEK",
339 "ISOWEEK",
340 "MONTH",
341 "QUARTER",
342 "YEAR",
343 "ISOYEAR",
344 ]);
345
346 dialect
349 .sets_mut("extended_datetime_units")
350 .extend(["DATE", "DATETIME", "TIME"]);
351
352 dialect.sets_mut("date_part_function_name").clear();
353 dialect.sets_mut("date_part_function_name").extend([
354 "DATE_DIFF",
355 "DATE_TRUNC",
356 "DATETIME_DIFF",
357 "DATETIME_TRUNC",
358 "EXTRACT",
359 "LAST_DAY",
360 "TIME_DIFF",
361 "TIME_TRUNC",
362 "TIMESTAMP_DIFF",
363 "TIMESTAMP_TRUNC",
364 ]);
365
366 dialect.sets_mut("value_table_functions").extend(["UNNEST"]);
368
369 dialect.bracket_sets_mut("angle_bracket_pairs").extend([(
371 "angle",
372 "StartAngleBracketSegment",
373 "EndAngleBracketSegment",
374 false,
375 )]);
376
377 dialect.add([
378 (
379 "ProcedureParameterListSegment".into(),
380 NodeMatcher::new(
381 SyntaxKind::ProcedureParameterList,
382 Bracketed::new(vec_of_erased![
383 Delimited::new(vec_of_erased![Ref::new("ProcedureParameterGrammar")])
384 .config(|this| this.optional())
385 ])
386 .to_matchable(),
387 )
388 .to_matchable()
389 .into(),
390 ),
391 (
392 "ProcedureStatements".into(),
393 NodeMatcher::new(
394 SyntaxKind::ProcedureStatements,
395 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
396 Ref::new("StatementSegment"),
397 Ref::new("DelimiterGrammar")
398 ])])
399 .config(|this| {
400 this.terminators = vec_of_erased![Ref::keyword("END")];
401 this.parse_mode = ParseMode::Greedy;
402 })
403 .to_matchable(),
404 )
405 .to_matchable()
406 .into(),
407 ),
408 (
409 "CreateProcedureStatementSegment".into(),
410 NodeMatcher::new(
411 SyntaxKind::CreateProcedureStatement,
412 Sequence::new(vec_of_erased![
413 Ref::keyword("CREATE"),
414 Ref::new("OrReplaceGrammar").optional(),
415 Ref::keyword("PROCEDURE"),
416 Ref::new("IfNotExistsGrammar").optional(),
417 Ref::new("ProcedureNameSegment"),
418 Ref::new("ProcedureParameterListSegment"),
419 Sequence::new(vec_of_erased![
420 Ref::keyword("OPTIONS"),
421 Ref::keyword("strict_mode"),
422 StringParser::new("strict_mode", SyntaxKind::ProcedureOption),
423 Ref::new("EqualsSegment"),
424 Ref::new("BooleanLiteralGrammar").optional(),
425 ])
426 .config(|this| this.optional()),
427 Ref::keyword("BEGIN"),
428 MetaSegment::indent(),
429 Ref::new("ProcedureStatements"),
430 MetaSegment::dedent(),
431 Ref::keyword("END")
432 ])
433 .to_matchable(),
434 )
435 .to_matchable()
436 .into(),
437 ),
438 (
439 "CallStatementSegment".into(),
440 NodeMatcher::new(
441 SyntaxKind::CallStatement,
442 Sequence::new(vec_of_erased![
443 Ref::keyword("CALL"),
444 Ref::new("ProcedureNameSegment"),
445 Bracketed::new(vec_of_erased![
446 Delimited::new(vec_of_erased![Ref::new("ExpressionSegment")])
447 .config(|this| this.optional())
448 ])
449 ])
450 .to_matchable(),
451 )
452 .to_matchable()
453 .into(),
454 ),
455 (
456 "ReturnStatementSegment".into(),
457 NodeMatcher::new(
458 SyntaxKind::ReturnStatement,
459 Sequence::new(vec_of_erased![Ref::keyword("RETURN")]).to_matchable(),
460 )
461 .to_matchable()
462 .into(),
463 ),
464 (
465 "BreakStatementSegment".into(),
466 NodeMatcher::new(
467 SyntaxKind::BreakStatement,
468 Sequence::new(vec_of_erased![Ref::keyword("BREAK")]).to_matchable(),
469 )
470 .to_matchable()
471 .into(),
472 ),
473 (
474 "LeaveStatementSegment".into(),
475 NodeMatcher::new(
476 SyntaxKind::LeaveStatement,
477 Sequence::new(vec_of_erased![Ref::keyword("LEAVE")]).to_matchable(),
478 )
479 .to_matchable()
480 .into(),
481 ),
482 (
483 "ContinueStatementSegment".into(),
484 NodeMatcher::new(
485 SyntaxKind::ContinueStatement,
486 one_of(vec_of_erased![
487 Ref::keyword("CONTINUE"),
488 Ref::keyword("ITERATE")
489 ])
490 .to_matchable(),
491 )
492 .to_matchable()
493 .into(),
494 ),
495 (
496 "RaiseStatementSegment".into(),
497 NodeMatcher::new(
498 SyntaxKind::RaiseStatement,
499 Sequence::new(vec_of_erased![
500 Ref::keyword("RAISE"),
501 Sequence::new(vec_of_erased![
502 Ref::keyword("USING"),
503 Ref::keyword("MESSAGE"),
504 Ref::new("EqualsSegment"),
505 Ref::new("ExpressionSegment").optional(),
506 ])
507 .config(|this| this.optional())
508 ])
509 .to_matchable(),
510 )
511 .to_matchable()
512 .into(),
513 ),
514 ]);
515
516 dialect.replace_grammar(
517 "ArrayTypeSegment",
518 Sequence::new(vec_of_erased![
519 Ref::keyword("ARRAY"),
520 Bracketed::new(vec_of_erased![Ref::new("DatatypeSegment")]).config(|this| {
521 this.bracket_type = "angle";
522 this.bracket_pairs_set = "angle_bracket_pairs";
523 })
524 ])
525 .to_matchable(),
526 );
527
528 dialect.add([
529 (
530 "QualifyClauseSegment".into(),
531 NodeMatcher::new(
532 SyntaxKind::QualifyClause,
533 Sequence::new(vec_of_erased![
534 Ref::keyword("QUALIFY"),
535 MetaSegment::indent(),
536 optionally_bracketed(vec_of_erased![Ref::new("ExpressionSegment")]),
537 MetaSegment::dedent(),
538 ])
539 .to_matchable(),
540 )
541 .to_matchable()
542 .into(),
543 ),
544 (
545 "SetOperatorSegment".into(),
546 NodeMatcher::new(SyntaxKind::SetOperator, {
547 one_of(vec_of_erased![
548 Sequence::new(vec_of_erased![
549 Ref::keyword("UNION"),
550 one_of(vec_of_erased![
551 Ref::keyword("DISTINCT"),
552 Ref::keyword("ALL")
553 ]),
554 ]),
555 Sequence::new(vec_of_erased![
556 Ref::keyword("INTERSECT"),
557 Ref::keyword("DISTINCT")
558 ]),
559 Sequence::new(vec_of_erased![
560 Ref::keyword("EXCEPT"),
561 Ref::keyword("DISTINCT")
562 ]),
563 ])
564 .to_matchable()
565 })
566 .to_matchable()
567 .into(),
568 ),
569 ]);
570
571 dialect.replace_grammar("SetExpressionSegment", {
572 Sequence::new(vec_of_erased![
573 one_of(vec_of_erased![
574 Ref::new("NonSetSelectableGrammar"),
575 Bracketed::new(vec_of_erased![Ref::new("SetExpressionSegment")]),
576 ]),
577 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
578 Ref::new("SetOperatorSegment"),
579 one_of(vec_of_erased![
580 Ref::new("NonSetSelectableGrammar"),
581 Bracketed::new(vec_of_erased![Ref::new("SetExpressionSegment")]),
582 ]),
583 ])])
584 .config(|this| this.min_times = 1),
585 Ref::new("OrderByClauseSegment").optional(),
586 Ref::new("LimitClauseSegment").optional(),
587 Ref::new("NamedWindowSegment").optional(),
588 ])
589 .to_matchable()
590 });
591
592 dialect.replace_grammar("SelectStatementSegment", {
593 ansi::select_statement().copy(
594 Some(vec_of_erased![Ref::new("QualifyClauseSegment").optional()]),
595 None,
596 Some(Ref::new("OrderByClauseSegment").optional().to_matchable()),
597 None,
598 Vec::new(),
599 false,
600 )
601 });
602
603 dialect.replace_grammar(
604 "UnorderedSelectStatementSegment",
605 ansi::get_unordered_select_statement_segment_grammar().copy(
606 Some(vec![
607 Ref::new("QualifyClauseSegment").optional().to_matchable(),
608 ]),
609 None,
610 Some(Ref::new("OverlapsClauseSegment").optional().to_matchable()),
611 None,
612 Vec::new(),
613 false,
614 ),
615 );
616
617 dialect.add([(
618 "MultiStatementSegment".into(),
619 NodeMatcher::new(SyntaxKind::MultiStatementSegment, {
620 one_of(vec_of_erased![
621 Ref::new("ForInStatementSegment"),
622 Ref::new("RepeatStatementSegment"),
623 Ref::new("WhileStatementSegment"),
624 Ref::new("LoopStatementSegment"),
625 Ref::new("IfStatementSegment"),
626 Ref::new("CreateProcedureStatementSegment"),
627 ])
628 .to_matchable()
629 })
630 .to_matchable()
631 .into(),
632 )]);
633
634 dialect.replace_grammar(
635 "FileSegment",
636 Sequence::new(vec_of_erased![
637 Sequence::new(vec_of_erased![one_of(vec_of_erased![
638 Ref::new("MultiStatementSegment"),
639 Ref::new("StatementSegment")
640 ])]),
641 AnyNumberOf::new(vec_of_erased![
642 Ref::new("DelimiterGrammar"),
643 one_of(vec_of_erased![
644 Ref::new("MultiStatementSegment"),
645 Ref::new("StatementSegment")
646 ])
647 ]),
648 Ref::new("DelimiterGrammar").optional()
649 ])
650 .to_matchable(),
651 );
652
653 dialect.replace_grammar(
654 "StatementSegment",
655 ansi::statement_segment().copy(
656 Some(vec_of_erased![
657 Ref::new("DeclareStatementSegment"),
658 Ref::new("SetStatementSegment"),
659 Ref::new("ExportStatementSegment"),
660 Ref::new("CreateExternalTableStatementSegment"),
661 Ref::new("AssertStatementSegment"),
662 Ref::new("CallStatementSegment"),
663 Ref::new("ReturnStatementSegment"),
664 Ref::new("BreakStatementSegment"),
665 Ref::new("LeaveStatementSegment"),
666 Ref::new("ContinueStatementSegment"),
667 Ref::new("RaiseStatementSegment"),
668 Ref::new("AlterViewStatementSegment"),
669 Ref::new("CreateMaterializedViewStatementSegment"),
670 Ref::new("AlterMaterializedViewStatementSegment"),
671 Ref::new("DropMaterializedViewStatementSegment"),
672 ]),
673 None,
674 None,
675 None,
676 Vec::new(),
677 false,
678 ),
679 );
680
681 dialect.add([(
682 "AssertStatementSegment".into(),
683 NodeMatcher::new(
684 SyntaxKind::AssertStatement,
685 Sequence::new(vec_of_erased![
686 Ref::keyword("ASSERT"),
687 Ref::new("ExpressionSegment"),
688 Sequence::new(vec_of_erased![
689 Ref::keyword("AS"),
690 Ref::new("QuotedLiteralSegment")
691 ])
692 .config(|this| this.optional())
693 ])
694 .to_matchable(),
695 )
696 .to_matchable()
697 .into(),
698 )]);
699
700 dialect.add([(
701 "ForInStatementsSegment".into(),
702 NodeMatcher::new(
703 SyntaxKind::ForInStatements,
704 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
705 one_of(vec_of_erased![
706 Ref::new("StatementSegment"),
707 Ref::new("MultiStatementSegment")
708 ]),
709 Ref::new("DelimiterGrammar")
710 ])])
711 .config(|this| {
712 this.terminators = vec_of_erased![Sequence::new(vec_of_erased![
713 Ref::keyword("END"),
714 Ref::keyword("FOR")
715 ])];
716 this.parse_mode = ParseMode::Greedy;
717 })
718 .to_matchable(),
719 )
720 .to_matchable()
721 .into(),
722 )]);
723
724 dialect.add([(
725 "ForInStatementSegment".into(),
726 NodeMatcher::new(
727 SyntaxKind::ForInStatement,
728 Sequence::new(vec_of_erased![
729 Ref::keyword("FOR"),
730 Ref::new("SingleIdentifierGrammar"),
731 Ref::keyword("IN"),
732 MetaSegment::indent(),
733 Ref::new("SelectableGrammar"),
734 MetaSegment::dedent(),
735 Ref::keyword("DO"),
736 MetaSegment::indent(),
737 Ref::new("ForInStatementsSegment"),
738 MetaSegment::dedent(),
739 Ref::keyword("END"),
740 Ref::keyword("FOR")
741 ])
742 .to_matchable(),
743 )
744 .to_matchable()
745 .into(),
746 )]);
747
748 dialect.add([
749 (
750 "RepeatStatementsSegment".into(),
751 NodeMatcher::new(
752 SyntaxKind::RepeatStatements,
753 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
754 one_of(vec_of_erased![
755 Ref::new("StatementSegment"),
756 Ref::new("MultiStatementSegment")
757 ]),
758 Ref::new("DelimiterGrammar")
759 ])])
760 .config(|this| {
761 this.terminators = vec_of_erased![Ref::keyword("UNTIL")];
762 this.parse_mode = ParseMode::Greedy;
763 })
764 .to_matchable(),
765 )
766 .to_matchable()
767 .into(),
768 ),
769 (
770 "RepeatStatementSegment".into(),
771 NodeMatcher::new(
772 SyntaxKind::RepeatStatement,
773 Sequence::new(vec_of_erased![
774 Ref::keyword("REPEAT"),
775 MetaSegment::indent(),
776 Ref::new("RepeatStatementsSegment"),
777 Ref::keyword("UNTIL"),
778 Ref::new("ExpressionSegment"),
779 MetaSegment::dedent(),
780 Ref::keyword("END"),
781 Ref::keyword("REPEAT")
782 ])
783 .to_matchable(),
784 )
785 .to_matchable()
786 .into(),
787 ),
788 (
789 "IfStatementsSegment".into(),
790 NodeMatcher::new(
791 SyntaxKind::IfStatements,
792 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
793 one_of(vec_of_erased![
794 Ref::new("StatementSegment"),
795 Ref::new("MultiStatementSegment")
796 ]),
797 Ref::new("DelimiterGrammar")
798 ])])
799 .config(|this| {
800 this.terminators = vec_of_erased![
801 Ref::keyword("ELSE"),
802 Ref::keyword("ELSEIF"),
803 Sequence::new(vec_of_erased![Ref::keyword("END"), Ref::keyword("IF")])
804 ];
805 this.parse_mode = ParseMode::Greedy;
806 })
807 .to_matchable(),
808 )
809 .to_matchable()
810 .into(),
811 ),
812 (
813 "IfStatementSegment".into(),
814 NodeMatcher::new(
815 SyntaxKind::IfStatement,
816 Sequence::new(vec_of_erased![
817 Ref::keyword("IF"),
818 Ref::new("ExpressionSegment"),
819 Ref::keyword("THEN"),
820 MetaSegment::indent(),
821 Ref::new("IfStatementsSegment"),
822 MetaSegment::dedent(),
823 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
824 Ref::keyword("ELSEIF"),
825 Ref::new("ExpressionSegment"),
826 Ref::keyword("THEN"),
827 MetaSegment::indent(),
828 Ref::new("IfStatementsSegment"),
829 MetaSegment::dedent()
830 ])]),
831 Sequence::new(vec_of_erased![
832 Ref::keyword("ELSE"),
833 MetaSegment::indent(),
834 Ref::new("IfStatementsSegment"),
835 MetaSegment::dedent()
836 ])
837 .config(|this| this.optional()),
838 Ref::keyword("END"),
839 Ref::keyword("IF")
840 ])
841 .to_matchable(),
842 )
843 .to_matchable()
844 .into(),
845 ),
846 (
847 "LoopStatementsSegment".into(),
848 NodeMatcher::new(
849 SyntaxKind::LoopStatements,
850 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
851 one_of(vec_of_erased![
852 Ref::new("StatementSegment"),
853 Ref::new("MultiStatementSegment")
854 ]),
855 Ref::new("DelimiterGrammar")
856 ])])
857 .config(|this| {
858 this.terminators = vec_of_erased![Sequence::new(vec_of_erased![
859 Ref::keyword("END"),
860 Ref::keyword("LOOP")
861 ])];
862 this.parse_mode = ParseMode::Greedy;
863 })
864 .to_matchable(),
865 )
866 .to_matchable()
867 .into(),
868 ),
869 (
870 "LoopStatementSegment".into(),
871 NodeMatcher::new(
872 SyntaxKind::LoopStatement,
873 Sequence::new(vec_of_erased![
874 Ref::keyword("LOOP"),
875 MetaSegment::indent(),
876 Ref::new("LoopStatementsSegment"),
877 MetaSegment::dedent(),
878 Ref::keyword("END"),
879 Ref::keyword("LOOP")
880 ])
881 .to_matchable(),
882 )
883 .to_matchable()
884 .into(),
885 ),
886 (
887 "WhileStatementsSegment".into(),
888 NodeMatcher::new(
889 SyntaxKind::WhileStatements,
890 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
891 Ref::new("StatementSegment"),
892 Ref::new("DelimiterGrammar")
893 ])])
894 .config(|this| {
895 this.terminators = vec_of_erased![Sequence::new(vec_of_erased![
896 Ref::keyword("END"),
897 Ref::keyword("WHILE")
898 ])];
899 this.parse_mode = ParseMode::Greedy;
900 })
901 .to_matchable(),
902 )
903 .to_matchable()
904 .into(),
905 ),
906 (
907 "WhileStatementSegment".into(),
908 NodeMatcher::new(
909 SyntaxKind::WhileStatement,
910 Sequence::new(vec_of_erased![
911 Ref::keyword("WHILE"),
912 Ref::new("ExpressionSegment"),
913 Ref::keyword("DO"),
914 MetaSegment::indent(),
915 Ref::new("WhileStatementsSegment"),
916 MetaSegment::dedent(),
917 Ref::keyword("END"),
918 Ref::keyword("WHILE")
919 ])
920 .to_matchable(),
921 )
922 .to_matchable()
923 .into(),
924 ),
925 ]);
926
927 dialect.replace_grammar(
928 "SelectClauseModifierSegment",
929 Sequence::new(vec_of_erased![
930 one_of(vec_of_erased![
931 Ref::keyword("DISTINCT"),
932 Ref::keyword("ALL")
933 ])
934 .config(|this| this.optional()),
935 Sequence::new(vec_of_erased![
936 Ref::keyword("AS"),
937 one_of(vec_of_erased![
938 Ref::keyword("STRUCT"),
939 Ref::keyword("VALUE")
940 ])
941 ])
942 .config(|this| this.optional())
943 ])
944 .to_matchable(),
945 );
946
947 dialect.replace_grammar(
948 "IntervalExpressionSegment",
949 Sequence::new(vec_of_erased![
950 Ref::keyword("INTERVAL"),
951 Ref::new("ExpressionSegment"),
952 one_of(vec_of_erased![
953 Ref::new("QuotedLiteralSegment"),
954 Ref::new("DatetimeUnitSegment"),
955 Sequence::new(vec_of_erased![
956 Ref::new("DatetimeUnitSegment"),
957 Ref::keyword("TO"),
958 Ref::new("DatetimeUnitSegment")
959 ])
960 ])
961 ])
962 .to_matchable(),
963 );
964
965 dialect.add([
966 (
967 "ExtractFunctionNameSegment".into(),
968 NodeMatcher::new(
969 SyntaxKind::FunctionName,
970 StringParser::new("EXTRACT", SyntaxKind::FunctionNameIdentifier).to_matchable(),
971 )
972 .to_matchable()
973 .into(),
974 ),
975 (
976 "ArrayFunctionNameSegment".into(),
977 NodeMatcher::new(
978 SyntaxKind::FunctionName,
979 StringParser::new("ARRAY", SyntaxKind::FunctionNameIdentifier).to_matchable(),
980 )
981 .to_matchable()
982 .into(),
983 ),
984 (
985 "DatePartWeekSegment".into(),
986 NodeMatcher::new(
987 SyntaxKind::DatePartWeek,
988 Sequence::new(vec_of_erased![
989 Ref::keyword("WEEK"),
990 Bracketed::new(vec_of_erased![one_of(vec_of_erased![
991 Ref::keyword("SUNDAY"),
992 Ref::keyword("MONDAY"),
993 Ref::keyword("TUESDAY"),
994 Ref::keyword("WEDNESDAY"),
995 Ref::keyword("THURSDAY"),
996 Ref::keyword("FRIDAY"),
997 Ref::keyword("SATURDAY")
998 ])])
999 ])
1000 .to_matchable(),
1001 )
1002 .to_matchable()
1003 .into(),
1004 ),
1005 (
1006 "NormalizeFunctionNameSegment".into(),
1007 NodeMatcher::new(
1008 SyntaxKind::FunctionName,
1009 one_of(vec_of_erased![
1010 StringParser::new("NORMALIZE", SyntaxKind::FunctionNameIdentifier),
1011 StringParser::new("NORMALIZE_AND_CASEFOLD", SyntaxKind::FunctionNameIdentifier),
1012 ])
1013 .to_matchable(),
1014 )
1015 .to_matchable()
1016 .into(),
1017 ),
1018 ]);
1019
1020 dialect.replace_grammar(
1021 "FunctionNameSegment",
1022 Sequence::new(vec_of_erased![
1023 AnyNumberOf::new(vec_of_erased![
1025 Sequence::new(vec_of_erased![
1026 one_of(vec_of_erased![
1027 Ref::keyword("SAFE"),
1028 Ref::new("SingleIdentifierGrammar")
1029 ]),
1030 Ref::new("DotSegment"),
1031 ])
1032 .terminators(vec_of_erased![Ref::new("BracketedSegment")])
1033 ]),
1034 one_of(vec_of_erased![
1036 Ref::new("FunctionNameIdentifierSegment"),
1037 Ref::new("QuotedIdentifierSegment")
1038 ])
1039 .config(|this| this.terminators = vec_of_erased![Ref::new("BracketedSegment")]),
1040 ])
1041 .allow_gaps(true)
1042 .to_matchable(),
1043 );
1044
1045 dialect.replace_grammar(
1046 "FunctionSegment",
1047 Sequence::new(vec_of_erased![one_of(vec_of_erased![
1048 Sequence::new(vec_of_erased![
1049 Ref::new("ExtractFunctionNameSegment"),
1051 Bracketed::new(vec_of_erased![
1052 one_of(vec_of_erased![
1053 Ref::new("DatetimeUnitSegment"),
1054 Ref::new("DatePartWeekSegment"),
1055 Ref::new("ExtendedDatetimeUnitSegment")
1056 ]),
1057 Ref::keyword("FROM"),
1058 Ref::new("ExpressionSegment")
1059 ])
1060 ]),
1061 Sequence::new(vec_of_erased![
1062 Ref::new("NormalizeFunctionNameSegment"),
1063 Bracketed::new(vec_of_erased![
1064 Ref::new("ExpressionSegment"),
1065 Sequence::new(vec_of_erased![
1066 Ref::new("CommaSegment"),
1067 one_of(vec_of_erased![
1068 Ref::keyword("NFC"),
1069 Ref::keyword("NFKC"),
1070 Ref::keyword("NFD"),
1071 Ref::keyword("NFKD")
1072 ])
1073 ])
1074 .config(|this| this.optional())
1075 ])
1076 ]),
1077 Sequence::new(vec_of_erased![
1078 Ref::new("DatePartFunctionNameSegment")
1079 .exclude(Ref::new("ExtractFunctionNameSegment")),
1080 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1081 Ref::new("DatetimeUnitSegment"),
1082 Ref::new("DatePartWeekSegment"),
1083 Ref::new("FunctionContentsGrammar")
1084 ])])
1085 .config(|this| this.parse_mode(ParseMode::Greedy))
1086 ]),
1087 Sequence::new(vec_of_erased![
1088 Sequence::new(vec_of_erased![
1089 Ref::new("FunctionNameSegment").exclude(one_of(vec_of_erased![
1090 Ref::new("DatePartFunctionNameSegment"),
1091 Ref::new("NormalizeFunctionNameSegment"),
1092 Ref::new("ValuesClauseSegment"),
1093 ])),
1094 Bracketed::new(vec_of_erased![
1095 Ref::new("FunctionContentsGrammar").optional()
1096 ])
1097 .config(|this| this.parse_mode(ParseMode::Greedy))
1098 ]),
1099 Ref::new("ArrayAccessorSegment").optional(),
1100 Ref::new("SemiStructuredAccessorSegment").optional(),
1101 Ref::new("PostFunctionGrammar").optional()
1102 ]),
1103 ])])
1104 .config(|this| this.allow_gaps = false)
1105 .to_matchable(),
1106 );
1107
1108 dialect.replace_grammar(
1109 "FunctionDefinitionGrammar",
1110 Sequence::new(vec_of_erased![AnyNumberOf::new(vec_of_erased![
1111 Sequence::new(vec_of_erased![one_of(vec_of_erased![
1112 Ref::keyword("DETERMINISTIC"),
1113 Sequence::new(vec_of_erased![
1114 Ref::keyword("NOT"),
1115 Ref::keyword("DETERMINISTIC")
1116 ])
1117 ])])
1118 .config(|this| this.optional()),
1119 Sequence::new(vec_of_erased![
1120 Ref::keyword("LANGUAGE"),
1121 Ref::new("NakedIdentifierSegment"),
1122 Sequence::new(vec_of_erased![
1123 Ref::keyword("OPTIONS"),
1124 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1125 Sequence::new(vec_of_erased![
1126 Ref::new("ParameterNameSegment"),
1127 Ref::new("EqualsSegment"),
1128 Anything::new()
1129 ]),
1130 Ref::new("CommaSegment")
1131 ])])
1132 ])
1133 .config(|this| this.optional())
1134 ]),
1135 Sequence::new(vec_of_erased![
1136 Ref::keyword("AS"),
1137 one_of(vec_of_erased![
1138 Ref::new("DoubleQuotedUDFBody"),
1139 Ref::new("SingleQuotedUDFBody"),
1140 Bracketed::new(vec_of_erased![one_of(vec_of_erased![
1141 Ref::new("ExpressionSegment"),
1142 Ref::new("SelectStatementSegment")
1143 ])])
1144 ])
1145 ]),
1146 ])])
1147 .to_matchable(),
1148 );
1149
1150 dialect.replace_grammar(
1151 "WildcardExpressionSegment",
1152 ansi::wildcard_expression_segment().copy(
1153 Some(vec_of_erased![
1154 Ref::new("ExceptClauseSegment").optional(),
1155 Ref::new("ReplaceClauseSegment").optional(),
1156 ]),
1157 None,
1158 None,
1159 None,
1160 Vec::new(),
1161 false,
1162 ),
1163 );
1164
1165 dialect.add([
1166 (
1167 "ExceptClauseSegment".into(),
1168 NodeMatcher::new(
1169 SyntaxKind::SelectExceptClause,
1170 Sequence::new(vec_of_erased![
1171 Ref::keyword("EXCEPT"),
1172 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![Ref::new(
1173 "SingleIdentifierGrammar"
1174 )])])
1175 ])
1176 .to_matchable(),
1177 )
1178 .to_matchable()
1179 .into(),
1180 ),
1181 (
1182 "ReplaceClauseSegment".into(),
1183 NodeMatcher::new(
1184 SyntaxKind::SelectReplaceClause,
1185 Sequence::new(vec_of_erased![
1186 Ref::keyword("REPLACE"),
1187 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![Ref::new(
1188 "SelectClauseElementSegment"
1189 )])])
1190 ])
1191 .to_matchable(),
1192 )
1193 .to_matchable()
1194 .into(),
1195 ),
1196 ]);
1197
1198 dialect.replace_grammar("DatatypeSegment", {
1199 one_of(vec_of_erased![
1200 Sequence::new(vec_of_erased![
1201 Ref::new("DatatypeIdentifierSegment"),
1202 Ref::new("BracketedArguments").optional(),
1203 ]),
1204 Sequence::new(vec_of_erased![Ref::keyword("ANY"), Ref::keyword("TYPE")]),
1205 Ref::new("ArrayTypeSegment"),
1206 Ref::new("StructTypeSegment"),
1207 ])
1208 .to_matchable()
1209 });
1210
1211 dialect.replace_grammar(
1212 "StructTypeSegment",
1213 Sequence::new(vec_of_erased![
1214 Ref::keyword("STRUCT"),
1215 Ref::new("StructTypeSchemaSegment").optional(),
1216 ])
1217 .to_matchable(),
1218 );
1219
1220 dialect.add([(
1221 "StructTypeSchemaSegment".into(),
1222 NodeMatcher::new(
1223 SyntaxKind::StructTypeSchema,
1224 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1225 Sequence::new(vec_of_erased![
1226 one_of(vec_of_erased![
1227 Ref::new("DatatypeSegment"),
1228 Sequence::new(vec_of_erased![
1229 Ref::new("ParameterNameSegment"),
1230 Ref::new("DatatypeSegment"),
1231 ]),
1232 ]),
1233 AnyNumberOf::new(vec_of_erased![Ref::new("ColumnConstraintSegment")]),
1234 Ref::new("OptionsSegment").optional(),
1235 ])
1236 ])])
1237 .config(|this| {
1238 this.bracket_type = "angle";
1239 this.bracket_pairs_set = "angle_bracket_pairs";
1240 })
1241 .to_matchable(),
1242 )
1243 .to_matchable()
1244 .into(),
1245 )]);
1246
1247 dialect.replace_grammar(
1248 "ArrayExpressionSegment",
1249 Sequence::new(vec_of_erased![
1250 Ref::new("ArrayFunctionNameSegment"),
1251 Bracketed::new(vec_of_erased![Ref::new("SelectableGrammar")]),
1252 ])
1253 .to_matchable(),
1254 );
1255
1256 dialect.add([
1257 (
1258 "TupleSegment".into(),
1259 NodeMatcher::new(
1260 SyntaxKind::Tuple,
1261 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![Ref::new(
1262 "BaseExpressionElementGrammar"
1263 )])])
1264 .to_matchable(),
1265 )
1266 .to_matchable()
1267 .into(),
1268 ),
1269 (
1270 "NamedArgumentSegment".into(),
1271 NodeMatcher::new(
1272 SyntaxKind::NamedArgument,
1273 Sequence::new(vec_of_erased![
1274 Ref::new("NakedIdentifierSegment"),
1275 Ref::new("RightArrowSegment"),
1276 Ref::new("ExpressionSegment"),
1277 ])
1278 .to_matchable(),
1279 )
1280 .to_matchable()
1281 .into(),
1282 ),
1283 ]);
1284
1285 dialect.add([(
1286 "SemiStructuredAccessorSegment".into(),
1287 NodeMatcher::new(
1288 SyntaxKind::SemiStructuredExpression,
1289 Sequence::new(vec_of_erased![
1290 AnyNumberOf::new(vec_of_erased![
1291 Sequence::new(vec_of_erased![
1292 Ref::new("DotSegment"),
1293 one_of(vec_of_erased![
1294 Ref::new("SingleIdentifierGrammar"),
1295 Ref::new("StarSegment")
1296 ])
1297 ])
1298 .config(|this| this.allow_gaps = true),
1299 Ref::new("ArrayAccessorSegment").optional()
1300 ])
1301 .config(|this| {
1302 this.allow_gaps = true;
1303 this.min_times = 1;
1304 })
1305 ])
1306 .config(|this| this.allow_gaps = true)
1307 .to_matchable(),
1308 )
1309 .to_matchable()
1310 .into(),
1311 )]);
1312
1313 dialect.replace_grammar(
1314 "ColumnReferenceSegment",
1315 Sequence::new(vec_of_erased![
1316 Ref::new("SingleIdentifierGrammar"),
1317 Sequence::new(vec_of_erased![
1318 Ref::new("ObjectReferenceDelimiterGrammar"),
1319 Delimited::new(vec_of_erased![Ref::new("SingleIdentifierFullGrammar")]).config(
1320 |this| {
1321 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
1322 this.terminators = vec_of_erased![
1323 Ref::keyword("ON"),
1324 Ref::keyword("AS"),
1325 Ref::keyword("USING"),
1326 Ref::new("CommaSegment"),
1327 Ref::new("CastOperatorSegment"),
1328 Ref::new("StartSquareBracketSegment"),
1329 Ref::new("StartBracketSegment"),
1330 Ref::new("BinaryOperatorGrammar"),
1331 Ref::new("ColonSegment"),
1332 Ref::new("DelimiterGrammar"),
1333 Ref::new("BracketedSegment")
1334 ];
1335 this.allow_gaps = false;
1336 }
1337 )
1338 ])
1339 .allow_gaps(false)
1340 .config(|this| this.optional())
1341 ])
1342 .allow_gaps(false)
1343 .to_matchable(),
1344 );
1345
1346 dialect.replace_grammar("TableReferenceSegment", {
1347 Delimited::new(vec_of_erased![
1348 Sequence::new(vec_of_erased![
1349 Ref::new("SingleIdentifierGrammar"),
1350 AnyNumberOf::new(vec_of_erased![
1351 Sequence::new(vec_of_erased![
1352 Ref::new("DashSegment"),
1353 Ref::new("NakedIdentifierPart")
1354 ])
1355 .config(|this| this.allow_gaps = false)
1356 ])
1357 .config(|this| this.optional())
1358 ])
1359 .config(|this| this.allow_gaps = false)
1360 ])
1361 .config(|this| {
1362 this.delimiter(Ref::new("ObjectReferenceDelimiterGrammar"));
1363 this.terminators = vec_of_erased![
1364 Ref::keyword("ON"),
1365 Ref::keyword("AS"),
1366 Ref::keyword("USING"),
1367 Ref::new("CommaSegment"),
1368 Ref::new("CastOperatorSegment"),
1369 Ref::new("StartSquareBracketSegment"),
1370 Ref::new("StartBracketSegment"),
1371 Ref::new("ColonSegment"),
1372 Ref::new("DelimiterGrammar"),
1373 Ref::new("JoinLikeClauseGrammar"),
1374 Ref::new("BracketedSegment")
1375 ];
1376 this.allow_gaps = false;
1377 })
1378 .to_matchable()
1379 });
1380
1381 dialect.add([
1382 (
1383 "DeclareStatementSegment".into(),
1384 NodeMatcher::new(
1385 SyntaxKind::DeclareSegment,
1386 Sequence::new(vec_of_erased![
1387 Ref::keyword("DECLARE"),
1388 Delimited::new(vec_of_erased![Ref::new("SingleIdentifierFullGrammar")]),
1389 one_of(vec_of_erased![
1390 Ref::new("DefaultDeclareOptionsGrammar"),
1391 Sequence::new(vec_of_erased![
1392 Ref::new("DatatypeSegment"),
1393 Ref::new("DefaultDeclareOptionsGrammar").optional()
1394 ])
1395 ])
1396 ])
1397 .to_matchable(),
1398 )
1399 .to_matchable()
1400 .into(),
1401 ),
1402 (
1403 "SetStatementSegment".into(),
1404 NodeMatcher::new(
1405 SyntaxKind::SetSegment,
1406 Sequence::new(vec_of_erased![
1407 Ref::keyword("SET"),
1408 one_of(vec_of_erased![
1409 Ref::new("NakedIdentifierSegment"),
1410 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![Ref::new(
1411 "NakedIdentifierSegment"
1412 )])])
1413 ]),
1414 Ref::new("EqualsSegment"),
1415 Delimited::new(vec_of_erased![one_of(vec_of_erased![
1416 Ref::new("LiteralGrammar"),
1417 Bracketed::new(vec_of_erased![Ref::new("SelectStatementSegment")]),
1418 Ref::new("BareFunctionSegment"),
1419 Ref::new("FunctionSegment"),
1420 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![one_of(
1421 vec_of_erased![
1422 Ref::new("LiteralGrammar"),
1423 Bracketed::new(vec_of_erased![Ref::new("SelectStatementSegment")]),
1424 Ref::new("BareFunctionSegment"),
1425 Ref::new("FunctionSegment")
1426 ]
1427 )])]),
1428 Ref::new("ArrayLiteralSegment"),
1429 Ref::new("ExpressionSegment")
1430 ])])
1431 ])
1432 .to_matchable(),
1433 )
1434 .to_matchable()
1435 .into(),
1436 ),
1437 (
1438 "PartitionBySegment".into(),
1439 NodeMatcher::new(
1440 SyntaxKind::PartitionBySegment,
1441 Sequence::new(vec_of_erased![
1442 Ref::keyword("PARTITION"),
1443 Ref::keyword("BY"),
1444 Ref::new("ExpressionSegment")
1445 ])
1446 .to_matchable(),
1447 )
1448 .to_matchable()
1449 .into(),
1450 ),
1451 (
1452 "ClusterBySegment".into(),
1453 NodeMatcher::new(
1454 SyntaxKind::ClusterBySegment,
1455 Sequence::new(vec_of_erased![
1456 Ref::keyword("CLUSTER"),
1457 Ref::keyword("BY"),
1458 Delimited::new(vec_of_erased![Ref::new("ExpressionSegment")])
1459 ])
1460 .to_matchable(),
1461 )
1462 .to_matchable()
1463 .into(),
1464 ),
1465 (
1466 "OptionsSegment".into(),
1467 NodeMatcher::new(
1468 SyntaxKind::OptionsSegment,
1469 Sequence::new(vec_of_erased![
1470 Ref::keyword("OPTIONS"),
1471 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1472 Sequence::new(vec_of_erased![
1473 Ref::new("ParameterNameSegment"),
1474 Ref::new("EqualsSegment"),
1475 Ref::new("BaseExpressionElementGrammar")
1476 ])
1477 ])])
1478 ])
1479 .to_matchable(),
1480 )
1481 .to_matchable()
1482 .into(),
1483 ),
1484 ]);
1485
1486 dialect.replace_grammar(
1487 "ColumnDefinitionSegment",
1488 Sequence::new(vec_of_erased![
1489 Ref::new("SingleIdentifierGrammar"), Ref::new("DatatypeSegment"), AnyNumberOf::new(vec_of_erased![Ref::new("ColumnConstraintSegment")]),
1492 Ref::new("OptionsSegment").optional()
1493 ])
1494 .to_matchable(),
1495 );
1496
1497 dialect.replace_grammar(
1498 "CreateTableStatementSegment",
1499 Sequence::new(vec_of_erased![
1500 Ref::keyword("CREATE"),
1501 Ref::new("OrReplaceGrammar").optional(),
1502 Ref::new("TemporaryTransientGrammar").optional(),
1503 Ref::keyword("TABLE"),
1504 Ref::new("IfNotExistsGrammar").optional(),
1505 Ref::new("TableReferenceSegment"),
1506 Sequence::new(vec_of_erased![
1507 one_of(vec_of_erased![
1508 Ref::keyword("COPY"),
1509 Ref::keyword("LIKE"),
1510 Ref::keyword("CLONE")
1511 ]),
1512 Ref::new("TableReferenceSegment"),
1513 ])
1514 .config(|this| this.optional()),
1515 Sequence::new(vec_of_erased![Bracketed::new(vec_of_erased![
1516 Delimited::new(vec_of_erased![Ref::new("ColumnDefinitionSegment")],)
1517 .config(|this| this.allow_trailing())
1518 ])])
1519 .config(|this| this.optional()),
1520 Ref::new("PartitionBySegment").optional(),
1521 Ref::new("ClusterBySegment").optional(),
1522 Ref::new("OptionsSegment").optional(),
1523 Sequence::new(vec_of_erased![
1524 Ref::keyword("AS"),
1525 optionally_bracketed(vec_of_erased![Ref::new("SelectableGrammar")])
1526 ])
1527 .config(|this| this.optional()),
1528 ])
1529 .to_matchable(),
1530 );
1531
1532 dialect.replace_grammar(
1533 "AlterTableStatementSegment",
1534 Sequence::new(vec_of_erased![
1535 Ref::keyword("ALTER"),
1536 Ref::keyword("TABLE"),
1537 Ref::new("IfExistsGrammar").optional(),
1538 Ref::new("TableReferenceSegment"),
1539 one_of(vec_of_erased![
1540 Sequence::new(vec_of_erased![
1542 Ref::keyword("SET"),
1543 Ref::new("OptionsSegment")
1544 ]),
1545 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
1547 Ref::keyword("ADD"),
1548 Ref::keyword("COLUMN"),
1549 Ref::new("IfNotExistsGrammar").optional(),
1550 Ref::new("ColumnDefinitionSegment"),
1551 ])])
1552 .config(|this| this.allow_trailing = true),
1553 Sequence::new(vec_of_erased![
1555 Ref::keyword("RENAME"),
1556 Ref::keyword("TO"),
1557 Ref::new("TableReferenceSegment"),
1558 ]),
1559 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
1561 Ref::keyword("RENAME"),
1562 Ref::keyword("COLUMN"),
1563 Ref::new("IfExistsGrammar").optional(),
1564 Ref::new("SingleIdentifierGrammar"),
1565 Ref::keyword("TO"),
1566 Ref::new("SingleIdentifierGrammar"),
1567 ])])
1568 .config(|this| this.allow_trailing = true),
1569 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
1571 Ref::keyword("DROP"),
1572 Ref::keyword("COLUMN"),
1573 Ref::new("IfExistsGrammar").optional(),
1574 Ref::new("SingleIdentifierGrammar"),
1575 ])]),
1576 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
1578 Ref::keyword("ALTER"),
1579 Ref::keyword("COLUMN"),
1580 Ref::new("IfExistsGrammar").optional(),
1581 Ref::new("SingleIdentifierGrammar"),
1582 one_of(vec_of_erased![
1583 Sequence::new(vec_of_erased![
1584 Ref::keyword("SET"),
1585 one_of(vec_of_erased![
1586 Ref::new("OptionsSegment"),
1587 Sequence::new(vec_of_erased![
1588 Ref::keyword("DATA"),
1589 Ref::keyword("TYPE"),
1590 Ref::new("DatatypeSegment"),
1591 ]),
1592 Sequence::new(vec_of_erased![
1593 Ref::keyword("DEFAULT"),
1594 one_of(vec_of_erased![
1595 Ref::new("LiteralGrammar"),
1596 Ref::new("FunctionSegment"),
1597 ]),
1598 ]),
1599 ])
1600 ]),
1601 Sequence::new(vec_of_erased![
1602 Ref::keyword("DROP"),
1603 one_of(vec_of_erased![
1604 Ref::keyword("DEFAULT"),
1605 Sequence::new(vec_of_erased![
1606 Ref::keyword("NOT"),
1607 Ref::keyword("NULL"),
1608 ]),
1609 ]),
1610 ]),
1611 ]),
1612 ])])
1613 ])
1614 ])
1615 .to_matchable(),
1616 );
1617
1618 dialect.add([(
1619 "CreateExternalTableStatementSegment".into(),
1620 NodeMatcher::new(
1621 SyntaxKind::CreateExternalTableStatement,
1622 Sequence::new(vec_of_erased![
1623 Ref::keyword("CREATE"),
1624 Sequence::new(vec_of_erased![
1625 Ref::keyword("OR").optional(),
1626 Ref::keyword("REPLACE").optional()
1627 ])
1628 .config(|this| this.optional()),
1629 Ref::keyword("EXTERNAL"),
1630 Ref::keyword("TABLE"),
1631 Sequence::new(vec_of_erased![
1632 Ref::keyword("IF").optional(),
1633 Ref::keyword("NOT").optional(),
1634 Ref::keyword("EXISTS").optional()
1635 ])
1636 .config(|this| this.optional()),
1637 Ref::new("TableReferenceSegment"),
1638 Bracketed::new(vec_of_erased![
1639 Delimited::new(vec_of_erased![Ref::new("ColumnDefinitionSegment")])
1640 .config(|this| this.allow_trailing = true)
1641 ])
1642 .config(|this| this.optional()),
1643 AnyNumberOf::new(vec_of_erased![
1644 Sequence::new(vec_of_erased![
1645 Ref::keyword("WITH"),
1646 Ref::keyword("CONNECTION"),
1647 Ref::new("TableReferenceSegment")
1648 ])
1649 .config(|this| this.optional()),
1650 Sequence::new(vec_of_erased![
1651 Ref::keyword("WITH"),
1652 Ref::keyword("PARTITION"),
1653 Ref::keyword("COLUMNS"),
1654 Bracketed::new(vec_of_erased![
1655 Delimited::new(vec_of_erased![Ref::new("ColumnDefinitionSegment")])
1656 .config(|this| this.allow_trailing = true)
1657 ])
1658 .config(|this| this.optional())
1659 ])
1660 .config(|this| this.optional()),
1661 Ref::new("OptionsSegment").optional()
1662 ])
1663 ])
1664 .to_matchable(),
1665 )
1666 .to_matchable()
1667 .into(),
1668 )]);
1669
1670 dialect.add([(
1671 "CreateExternalTableStatementSegment".into(),
1672 NodeMatcher::new(
1673 SyntaxKind::CreateExternalTableStatement,
1674 Sequence::new(vec_of_erased![
1675 Ref::keyword("CREATE"),
1676 Sequence::new(vec_of_erased![
1677 Ref::keyword("OR").optional(),
1678 Ref::keyword("REPLACE").optional()
1679 ])
1680 .config(|this| this.optional()),
1681 Ref::keyword("EXTERNAL"),
1682 Ref::keyword("TABLE"),
1683 Sequence::new(vec_of_erased![
1684 Ref::keyword("IF").optional(),
1685 Ref::keyword("NOT").optional(),
1686 Ref::keyword("EXISTS").optional()
1687 ])
1688 .config(|this| this.optional()),
1689 Ref::new("TableReferenceSegment"),
1690 Bracketed::new(vec_of_erased![
1691 Delimited::new(vec_of_erased![Ref::new("ColumnDefinitionSegment")])
1692 .config(|this| this.allow_trailing = true)
1693 ])
1694 .config(|this| this.optional()),
1695 AnyNumberOf::new(vec_of_erased![
1696 Sequence::new(vec_of_erased![
1697 Ref::keyword("WITH"),
1698 Ref::keyword("CONNECTION"),
1699 Ref::new("TableReferenceSegment")
1700 ])
1701 .config(|this| this.optional()),
1702 Sequence::new(vec_of_erased![
1703 Ref::keyword("WITH"),
1704 Ref::keyword("PARTITION"),
1705 Ref::keyword("COLUMNS"),
1706 Bracketed::new(vec_of_erased![
1707 Delimited::new(vec_of_erased![Ref::new("ColumnDefinitionSegment")])
1708 .config(|this| this.allow_trailing = true)
1709 ])
1710 .config(|this| this.optional())
1711 ])
1712 .config(|this| this.optional()),
1713 Ref::new("OptionsSegment").optional()
1714 ])
1715 ])
1716 .to_matchable(),
1717 )
1718 .to_matchable()
1719 .into(),
1720 )]);
1721
1722 dialect.replace_grammar(
1723 "CreateViewStatementSegment",
1724 Sequence::new(vec_of_erased![
1725 Ref::keyword("CREATE"),
1726 Ref::new("OrReplaceGrammar").optional(),
1727 Ref::keyword("VIEW"),
1728 Ref::new("IfNotExistsGrammar").optional(),
1729 Ref::new("TableReferenceSegment"),
1730 Ref::new("BracketedColumnReferenceListGrammar").optional(),
1731 Ref::new("OptionsSegment").optional(),
1732 Ref::keyword("AS"),
1733 optionally_bracketed(vec_of_erased![Ref::new("SelectableGrammar")])
1734 ])
1735 .to_matchable(),
1736 );
1737
1738 dialect.add([
1739 (
1740 "AlterViewStatementSegment".into(),
1741 NodeMatcher::new(
1742 SyntaxKind::AlterViewStatement,
1743 Sequence::new(vec_of_erased![
1744 Ref::keyword("ALTER"),
1745 Ref::keyword("VIEW"),
1746 Ref::new("IfExistsGrammar").optional(),
1747 Ref::new("TableReferenceSegment"),
1748 Ref::keyword("SET"),
1749 Ref::new("OptionsSegment"),
1750 ])
1751 .to_matchable(),
1752 )
1753 .to_matchable()
1754 .into(),
1755 ),
1756 (
1757 "CreateMaterializedViewStatementSegment".into(),
1758 NodeMatcher::new(
1759 SyntaxKind::CreateMaterializedViewStatement,
1760 Sequence::new(vec_of_erased![
1761 Ref::keyword("CREATE"),
1762 Ref::new("OrReplaceGrammar").optional(),
1763 Ref::keyword("MATERIALIZED"),
1764 Ref::keyword("VIEW"),
1765 Ref::new("IfNotExistsGrammar").optional(),
1766 Ref::new("TableReferenceSegment"),
1767 Ref::new("PartitionBySegment").optional(),
1768 Ref::new("ClusterBySegment").optional(),
1769 Ref::new("OptionsSegment").optional(),
1770 Ref::keyword("AS"),
1771 optionally_bracketed(vec_of_erased![Ref::new("SelectableGrammar")]),
1772 ])
1773 .to_matchable(),
1774 )
1775 .to_matchable()
1776 .into(),
1777 ),
1778 (
1779 "AlterMaterializedViewStatementSegment".into(),
1780 NodeMatcher::new(
1781 SyntaxKind::AlterMaterializedViewSetOptionsStatement,
1782 Sequence::new(vec_of_erased![
1783 Ref::keyword("ALTER"),
1784 Ref::keyword("MATERIALIZED"),
1785 Ref::keyword("VIEW"),
1786 Ref::new("IfExistsGrammar").optional(),
1787 Ref::new("TableReferenceSegment"),
1788 Ref::keyword("SET"),
1789 Ref::new("OptionsSegment"),
1790 ])
1791 .to_matchable(),
1792 )
1793 .to_matchable()
1794 .into(),
1795 ),
1796 (
1797 "DropMaterializedViewStatementSegment".into(),
1798 NodeMatcher::new(
1799 SyntaxKind::DropMaterializedViewStatement,
1800 Sequence::new(vec_of_erased![
1801 Ref::keyword("DROP"),
1802 Ref::keyword("MATERIALIZED"),
1803 Ref::keyword("VIEW"),
1804 Ref::new("IfExistsGrammar").optional(),
1805 Ref::new("TableReferenceSegment"),
1806 ])
1807 .to_matchable(),
1808 )
1809 .to_matchable()
1810 .into(),
1811 ),
1812 (
1813 "ParameterizedSegment".into(),
1814 NodeMatcher::new(
1815 SyntaxKind::ParameterizedExpression,
1816 one_of(vec_of_erased![
1817 Ref::new("AtSignLiteralSegment"),
1818 Ref::new("QuestionMarkSegment"),
1819 ])
1820 .to_matchable(),
1821 )
1822 .to_matchable()
1823 .into(),
1824 ),
1825 (
1826 "PivotForClauseSegment".into(),
1827 NodeMatcher::new(
1828 SyntaxKind::PivotForClause,
1829 Sequence::new(vec_of_erased![Ref::new("BaseExpressionElementGrammar")])
1830 .config(|this| {
1831 this.terminators = vec_of_erased![Ref::keyword("IN")];
1832 this.parse_mode(ParseMode::Greedy);
1833 })
1834 .to_matchable(),
1835 )
1836 .to_matchable()
1837 .into(),
1838 ),
1839 (
1840 "FromPivotExpressionSegment".into(),
1841 NodeMatcher::new(
1842 SyntaxKind::FromPivotExpression,
1843 Sequence::new(vec_of_erased![
1844 Ref::keyword("PIVOT"),
1845 Bracketed::new(vec_of_erased![
1846 Delimited::new(vec_of_erased![Sequence::new(vec_of_erased![
1847 Ref::new("FunctionSegment"),
1848 Ref::new("AliasExpressionSegment").optional(),
1849 ])]),
1850 Ref::keyword("FOR"),
1851 Ref::new("PivotForClauseSegment"),
1852 Ref::keyword("IN"),
1853 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1854 Sequence::new(vec_of_erased![
1855 Ref::new("LiteralGrammar"),
1856 Ref::new("AliasExpressionSegment").optional(),
1857 ])
1858 ])])
1859 ]),
1860 ])
1861 .to_matchable(),
1862 )
1863 .to_matchable()
1864 .into(),
1865 ),
1866 (
1867 "UnpivotAliasExpressionSegment".into(),
1868 NodeMatcher::new(
1869 SyntaxKind::AliasExpression,
1870 Sequence::new(vec_of_erased![
1871 MetaSegment::indent(),
1872 Ref::keyword("AS").optional(),
1873 one_of(vec_of_erased![
1874 Ref::new("QuotedLiteralSegment"),
1875 Ref::new("NumericLiteralSegment"),
1876 ]),
1877 MetaSegment::dedent(),
1878 ])
1879 .to_matchable(),
1880 )
1881 .to_matchable()
1882 .into(),
1883 ),
1884 ]);
1885
1886 dialect.add([(
1887 "FromUnpivotExpressionSegment".into(),
1888 NodeMatcher::new(
1889 SyntaxKind::FromUnpivotExpression,
1890 Sequence::new(vec_of_erased![
1891 Ref::keyword("UNPIVOT"),
1892 Sequence::new(vec_of_erased![
1893 one_of(vec_of_erased![
1894 Ref::keyword("INCLUDE"),
1895 Ref::keyword("EXCLUDE"),
1896 ]),
1897 Ref::keyword("NULLS"),
1898 ])
1899 .config(|this| this.optional()),
1900 one_of(vec_of_erased![
1901 Bracketed::new(vec_of_erased![
1903 Ref::new("SingleIdentifierGrammar"),
1904 Ref::keyword("FOR"),
1905 Ref::new("SingleIdentifierGrammar"),
1906 Ref::keyword("IN"),
1907 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1908 Sequence::new(vec_of_erased![
1909 Delimited::new(vec_of_erased![Ref::new("SingleIdentifierGrammar")]),
1910 Ref::new("UnpivotAliasExpressionSegment").optional(),
1911 ]),
1912 ])]),
1913 ]),
1914 Bracketed::new(vec_of_erased![
1916 Bracketed::new(vec_of_erased![
1917 Delimited::new(vec_of_erased![Ref::new("SingleIdentifierGrammar"),])
1918 .config(|this| this.min_delimiters = 1)
1919 ]),
1920 Ref::keyword("FOR"),
1921 Ref::new("SingleIdentifierGrammar"),
1922 Ref::keyword("IN"),
1923 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
1924 Sequence::new(vec_of_erased![
1925 Bracketed::new(vec_of_erased![
1926 Delimited::new(vec_of_erased![Ref::new(
1927 "SingleIdentifierGrammar"
1928 ),])
1929 .config(|this| this.min_delimiters = 1)
1930 ]),
1931 Ref::new("UnpivotAliasExpressionSegment").optional(),
1932 ]),
1933 ])]),
1934 ]),
1935 ]),
1936 ])
1937 .to_matchable(),
1938 )
1939 .to_matchable()
1940 .into(),
1941 )]);
1942
1943 dialect.add([
1944 (
1945 "InsertStatementSegment".into(),
1946 NodeMatcher::new(
1947 SyntaxKind::InsertStatement,
1948 Sequence::new(vec_of_erased![
1949 Ref::keyword("INSERT"),
1950 Ref::keyword("INTO").optional(),
1951 Ref::new("TableReferenceSegment"),
1952 Ref::new("BracketedColumnReferenceListGrammar").optional(),
1953 Ref::new("SelectableGrammar")
1954 ])
1955 .to_matchable(),
1956 )
1957 .to_matchable()
1958 .into(),
1959 ),
1960 (
1961 "SamplingExpressionSegment".into(),
1962 NodeMatcher::new(
1963 SyntaxKind::SampleExpression,
1964 Sequence::new(vec_of_erased![
1965 Ref::keyword("TABLESAMPLE"),
1966 Ref::keyword("SYSTEM"),
1967 Bracketed::new(vec_of_erased![
1968 Ref::new("NumericLiteralSegment"),
1969 Ref::keyword("PERCENT")
1970 ]),
1971 ])
1972 .to_matchable(),
1973 )
1974 .to_matchable()
1975 .into(),
1976 ),
1977 (
1978 "MergeMatchSegment".into(),
1979 NodeMatcher::new(
1980 SyntaxKind::MergeMatch,
1981 AnyNumberOf::new(vec_of_erased![
1982 Ref::new("MergeMatchedClauseSegment"),
1983 Ref::new("MergeNotMatchedByTargetClauseSegment"),
1984 Ref::new("MergeNotMatchedBySourceClauseSegment"),
1985 ])
1986 .config(|this| this.min_times = 1)
1987 .to_matchable(),
1988 )
1989 .to_matchable()
1990 .into(),
1991 ),
1992 (
1993 "MergeNotMatchedByTargetClauseSegment".into(),
1994 NodeMatcher::new(
1995 SyntaxKind::NotMatchedByTargetClause,
1996 Sequence::new(vec_of_erased![
1997 Ref::keyword("WHEN"),
1998 Ref::keyword("NOT"),
1999 Ref::keyword("MATCHED"),
2000 Sequence::new(vec_of_erased![Ref::keyword("BY"), Ref::keyword("TARGET")])
2001 .config(|this| this.optional()),
2002 Sequence::new(vec_of_erased![
2003 Ref::keyword("AND"),
2004 Ref::new("ExpressionSegment"),
2005 ])
2006 .config(|this| this.optional()),
2007 Ref::keyword("THEN"),
2008 MetaSegment::indent(),
2009 Ref::new("MergeInsertClauseSegment"),
2010 MetaSegment::dedent()
2011 ])
2012 .to_matchable(),
2013 )
2014 .to_matchable()
2015 .into(),
2016 ),
2017 (
2018 "MergeNotMatchedBySourceClauseSegment".into(),
2019 NodeMatcher::new(
2020 SyntaxKind::MergeWhenMatchedClause,
2021 Sequence::new(vec_of_erased![
2022 Ref::keyword("WHEN"),
2023 Ref::keyword("NOT"),
2024 Ref::keyword("MATCHED"),
2025 Ref::keyword("BY"),
2026 Ref::keyword("SOURCE"),
2027 Sequence::new(vec_of_erased![
2028 Ref::keyword("AND"),
2029 Ref::new("ExpressionSegment")
2030 ])
2031 .config(|this| this.optional()),
2032 Ref::keyword("THEN"),
2033 MetaSegment::indent(),
2034 one_of(vec_of_erased![
2035 Ref::new("MergeUpdateClauseSegment"),
2036 Ref::new("MergeDeleteClauseSegment")
2037 ]),
2038 MetaSegment::dedent()
2039 ])
2040 .to_matchable(),
2041 )
2042 .to_matchable()
2043 .into(),
2044 ),
2045 (
2046 "MergeInsertClauseSegment".into(),
2047 NodeMatcher::new(
2048 SyntaxKind::MergeInsertClause,
2049 one_of(vec_of_erased![
2050 Sequence::new(vec_of_erased![
2051 Ref::keyword("INSERT"),
2052 MetaSegment::indent(),
2053 Ref::new("BracketedColumnReferenceListGrammar").optional(),
2054 MetaSegment::dedent(),
2055 Ref::new("ValuesClauseSegment").optional(),
2056 ]),
2057 Sequence::new(vec_of_erased![Ref::keyword("INSERT"), Ref::keyword("ROW"),]),
2058 ])
2059 .to_matchable(),
2060 )
2061 .to_matchable()
2062 .into(),
2063 ),
2064 ]);
2065
2066 dialect.add([
2067 (
2068 "DeleteStatementSegment".into(),
2069 NodeMatcher::new(
2070 SyntaxKind::DeleteStatement,
2071 Sequence::new(vec_of_erased![
2072 Ref::keyword("DELETE"),
2073 Ref::keyword("FROM").optional(),
2074 Ref::new("TableReferenceSegment"),
2075 Ref::new("AliasExpressionSegment").optional(),
2076 Ref::new("WhereClauseSegment").optional(),
2077 ])
2078 .to_matchable(),
2079 )
2080 .to_matchable()
2081 .into(),
2082 ),
2083 (
2084 "ExportStatementSegment".into(),
2085 NodeMatcher::new(
2086 SyntaxKind::ExportStatement,
2087 Sequence::new(vec_of_erased![
2088 Ref::keyword("EXPORT"),
2089 Ref::keyword("DATA"),
2090 Sequence::new(vec_of_erased![
2091 Ref::keyword("WITH"),
2092 Ref::keyword("CONNECTION"),
2093 Ref::new("ObjectReferenceSegment")
2094 ])
2095 .config(|this| this.optional()),
2096 Ref::keyword("OPTIONS"),
2097 Bracketed::new(vec_of_erased![Delimited::new(vec_of_erased![
2098 Sequence::new(vec_of_erased![
2099 one_of(vec_of_erased![
2100 StringParser::new("compression", SyntaxKind::ExportOption),
2101 StringParser::new("field_delimiter", SyntaxKind::ExportOption),
2102 StringParser::new("format", SyntaxKind::ExportOption),
2103 StringParser::new("uri", SyntaxKind::ExportOption),
2104 ]),
2105 Ref::new("EqualsSegment"),
2106 Ref::new("QuotedLiteralSegment"),
2107 ]),
2108 Sequence::new(vec_of_erased![
2109 one_of(vec_of_erased![
2110 StringParser::new("header", SyntaxKind::ExportOption),
2111 StringParser::new("overwrite", SyntaxKind::ExportOption),
2112 StringParser::new(
2113 "use_avro_logical_types",
2114 SyntaxKind::ExportOption
2115 ),
2116 ]),
2117 Ref::new("EqualsSegment"),
2118 one_of(vec_of_erased![Ref::keyword("TRUE"), Ref::keyword("FALSE"),]),
2119 ]),
2120 ])]),
2121 Ref::keyword("AS"),
2122 Ref::new("SelectableGrammar")
2123 ])
2124 .to_matchable(),
2125 )
2126 .to_matchable()
2127 .into(),
2128 ),
2129 (
2130 "ProcedureNameSegment".into(),
2131 NodeMatcher::new(
2132 SyntaxKind::ProcedureName,
2133 Sequence::new(vec_of_erased![
2134 AnyNumberOf::new(vec_of_erased![Sequence::new(vec_of_erased![
2135 Ref::new("SingleIdentifierGrammar"),
2136 Ref::new("DotSegment"),
2137 ])]),
2138 one_of(vec_of_erased![
2139 Ref::new("ProcedureNameIdentifierSegment"),
2140 Ref::new("QuotedIdentifierSegment"),
2141 ])
2142 ])
2143 .config(|this| this.allow_gaps = false)
2144 .to_matchable(),
2145 )
2146 .to_matchable()
2147 .into(),
2148 ),
2149 ]);
2150
2151 dialect.add([
2152 (
2153 "QuotedIdentifierSegment".into(),
2154 TypedParser::new(SyntaxKind::BackQuote, SyntaxKind::QuotedIdentifier)
2155 .to_matchable()
2156 .into(),
2157 ),
2158 (
2159 "NumericLiteralSegment".into(),
2160 one_of(vec_of_erased![
2161 TypedParser::new(SyntaxKind::NumericLiteral, SyntaxKind::NumericLiteral),
2162 Ref::new("ParameterizedSegment")
2163 ])
2164 .to_matchable()
2165 .into(),
2166 ),
2167 (
2168 "QuotedLiteralSegment".into(),
2169 one_of(vec_of_erased![
2170 Ref::new("SingleQuotedLiteralSegment"),
2171 Ref::new("DoubleQuotedLiteralSegment")
2172 ])
2173 .to_matchable()
2174 .into(),
2175 ),
2176 (
2177 "LiteralGrammar".into(),
2178 dialect
2179 .grammar("LiteralGrammar")
2180 .copy(
2181 Some(vec_of_erased![Ref::new("ParameterizedSegment")]),
2182 None,
2183 None,
2184 None,
2185 Vec::new(),
2186 false,
2187 )
2188 .into(),
2189 ),
2190 (
2191 "PostTableExpressionGrammar".into(),
2192 Sequence::new(vec_of_erased![
2193 Sequence::new(vec_of_erased![
2194 Ref::keyword("FOR"),
2195 one_of(vec_of_erased![
2196 Ref::keyword("SYSTEM_TIME"),
2197 Sequence::new(vec_of_erased![Ref::keyword("SYSTEM"), Ref::keyword("TIME")]),
2198 ]),
2199 Ref::keyword("AS"),
2200 Ref::keyword("OF"),
2201 Ref::new("ExpressionSegment")
2202 ])
2203 .config(|this| this.optional()),
2204 Sequence::new(vec_of_erased![
2205 Ref::keyword("WITH"),
2206 Ref::keyword("OFFSET"),
2207 Sequence::new(vec_of_erased![
2208 Ref::keyword("AS"),
2209 Ref::new("SingleIdentifierGrammar")
2210 ])
2211 .config(|this| this.optional()),
2212 ])
2213 .config(|this| this.optional()),
2214 ])
2215 .to_matchable()
2216 .into(),
2217 ),
2218 (
2219 "FunctionNameIdentifierSegment".into(),
2220 one_of(vec_of_erased![
2221 RegexParser::new("[A-Z_][A-Z0-9_]*", SyntaxKind::FunctionNameIdentifier)
2222 .anti_template("^(STRUCT|ARRAY)$"),
2223 RegexParser::new("`[^`]*`", SyntaxKind::FunctionNameIdentifier),
2224 ])
2225 .to_matchable()
2226 .into(),
2227 ),
2228 ]);
2229
2230 dialect.expand();
2231 dialect
2232}