Skip to content

Commit 8eed145

Browse files
committed
making progress [ci skip]
1 parent 87718ed commit 8eed145

File tree

1 file changed

+61
-16
lines changed

1 file changed

+61
-16
lines changed

crates/lib-dialects/src/mysql.rs

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use sqruff_lib_core::dialects::syntax::SyntaxKind;
44
use sqruff_lib_core::helpers::{Config, ToMatchable};
55
use sqruff_lib_core::parser::grammar::anyof::one_of;
66
use sqruff_lib_core::parser::grammar::base::Ref;
7+
use sqruff_lib_core::parser::grammar::delimited::Delimited;
78
use sqruff_lib_core::parser::segments::meta::MetaSegment;
89
use sqruff_lib_core::vec_of_erased;
910
use sqruff_lib_core::{parser::grammar::sequence::Sequence, parser::lexer::Matcher};
@@ -71,23 +72,67 @@ pub fn raw_dialect() -> Dialect {
7172
"TIMESTAMPDIFF",
7273
]);
7374

74-
mysql.add([(
75-
// A reference to an object with an `AS` clause.
76-
// The optional AS keyword allows both implicit and explicit aliasing.
77-
"AliasExpressionSegment".into(),
78-
Sequence::new(vec_of_erased![
79-
MetaSegment::indent(),
80-
Ref::keyword("AS").optional(),
81-
one_of(vec_of_erased![
75+
mysql.add([
76+
(
77+
// A reference to an object with an `AS` clause.
78+
// The optional AS keyword allows both implicit and explicit aliasing.
79+
"AliasExpressionSegment".into(),
80+
Sequence::new(vec_of_erased![
81+
MetaSegment::indent(),
82+
Ref::keyword("AS").optional(),
83+
one_of(vec_of_erased![
84+
Ref::new("SingleIdentifierGrammar"),
85+
Ref::new("SingleQuotedIdentifierSegment"),
86+
Ref::new("DoubleQuotedIdentifierSegment"),
87+
]),
88+
MetaSegment::dedent(),
89+
])
90+
.to_matchable()
91+
.into(),
92+
),
93+
(
94+
// This is a CLOSE or Open statement.
95+
// https://dev.mysql.com/doc/refman/8.0/en/close.html
96+
// https://dev.mysql.com/doc/refman/8.0/en/open.html
97+
"CursorOpenCloseSegment".into(),
98+
Sequence::new(vec_of_erased![
99+
one_of(vec_of_erased![Ref::keyword("CLOSE"), Ref::keyword("OPEN"),]),
100+
one_of(vec_of_erased![
101+
Ref::new("SingleIdentifierGrammar"),
102+
Ref::new("QuotedIdentifierSegment"),
103+
]),
104+
])
105+
.to_matchable()
106+
.into(),
107+
),
108+
(
109+
// A `ITERATE` statement.
110+
// https://dev.mysql.com/doc/refman/8.0/en/iterate.html
111+
"IterateStatementSegment".into(),
112+
Sequence::new(vec_of_erased![
113+
Ref::keyword("ITERATE"),
82114
Ref::new("SingleIdentifierGrammar"),
83-
Ref::new("SingleQuotedIdentifierSegment"),
84-
Ref::new("DoubleQuotedIdentifierSegment"),
85-
]),
86-
MetaSegment::dedent(),
87-
])
88-
.to_matchable()
89-
.into(),
90-
)]);
115+
])
116+
.to_matchable()
117+
.into(),
118+
),
119+
(
120+
// This is the body of a `EXECUTE` statement.
121+
// https://dev.mysql.com/doc/refman/8.0/en/execute.html
122+
"ExecuteSegment".into(),
123+
Sequence::new(vec_of_erased![
124+
Ref::keyword("EXECUTE"),
125+
Ref::new("NakedIdentifierSegment"),
126+
Sequence::new(vec_of_erased![
127+
Ref::keyword("USING"),
128+
Delimited::new(vec_of_erased![Ref::new("SessionVariableNameSegment")]),
129+
])
130+
.config(|delimited| delimited.optional()),
131+
])
132+
.to_matchable()
133+
.into(),
134+
),
135+
]);
91136

92137
mysql
93138
}

0 commit comments

Comments
 (0)