@@ -34,14 +34,6 @@ macro_rules! parser_err {
34
34
} ;
35
35
}
36
36
37
- macro_rules! maybe {
38
- ( $e: expr) => { {
39
- if let Some ( v) = $e {
40
- return Ok ( v) ;
41
- }
42
- } } ;
43
- }
44
-
45
37
#[ derive( PartialEq ) ]
46
38
pub enum IsOptional {
47
39
Optional ,
@@ -198,19 +190,19 @@ impl Parser {
198
190
// INTERVAL '7' DAY
199
191
//
200
192
// Note also that naively `SELECT date` looks like a syntax error because the `date` type
201
- // name is not followed by a string literal, but in fact in PostgreSQL it is a valid
193
+ // name is not followed by a string literal, but in fact in PostgreSQL it is a valid
202
194
// expression that should parse as the column name "date".
203
- maybe ! ( self . maybe_parse( |parser| {
204
- match parser. parse_data_type ( ) ? {
205
- DataType :: Interval => parser . parse_literal_interval ( ) ,
206
- data_type => Ok ( Expr :: Cast {
207
- expr : Box :: new ( Expr :: Value ( Value :: SingleQuotedString (
208
- parser . parse_literal_string ( ) ? ,
209
- ) ) ) ,
210
- data_type ,
211
- } ) ,
212
- }
213
- } ) ) ;
195
+ if let Some ( parsed ) = self . maybe_parse ( |parser| match parser . parse_data_type ( ) ? {
196
+ DataType :: Interval => parser. parse_literal_interval ( ) ,
197
+ data_type => Ok ( Expr :: Cast {
198
+ expr : Box :: new ( Expr :: Value ( Value :: SingleQuotedString (
199
+ parser . parse_literal_string ( ) ? ,
200
+ ) ) ) ,
201
+ data_type ,
202
+ } ) ,
203
+ } ) {
204
+ return Ok ( parsed ) ;
205
+ }
214
206
215
207
let tok = self
216
208
. next_token ( )
@@ -1975,7 +1967,11 @@ impl Parser {
1975
1967
// Check if the recently consumed '(' started a derived table, in which case we've
1976
1968
// parsed the subquery, followed by the closing ')', and the alias of the derived
1977
1969
// table. In the example above this is case (3), or another nested join (2).
1978
- maybe ! ( self . maybe_parse( |parser| parser. parse_derived_table_factor( NotLateral ) ) ) ;
1970
+ if let Some ( parsed) =
1971
+ self . maybe_parse ( |parser| parser. parse_derived_table_factor ( NotLateral ) )
1972
+ {
1973
+ return Ok ( parsed) ;
1974
+ }
1979
1975
1980
1976
// Inside the parentheses we expect to find a table factor
1981
1977
// followed by some joins or another level of nesting.
0 commit comments