@@ -2,7 +2,7 @@ use nom::branch::alt;
22use nom:: character:: complete:: { alphanumeric1, digit1, line_ending, multispace0, multispace1} ;
33use nom:: character:: is_alphanumeric;
44use nom:: combinator:: { map, not, peek} ;
5- use nom:: { IResult , InputLength } ;
5+ use nom:: { IResult , InputLength , Parser } ;
66use std:: fmt:: { self , Display } ;
77use std:: str;
88use std:: str:: FromStr ;
@@ -14,7 +14,7 @@ use keywords::{escape_if_keyword, sql_keyword};
1414use nom:: bytes:: complete:: { is_not, tag, tag_no_case, take, take_until, take_while1} ;
1515use nom:: combinator:: opt;
1616use nom:: error:: { ErrorKind , ParseError } ;
17- use nom:: multi:: { fold_many0, many0, many1, separated_list } ;
17+ use nom:: multi:: { fold_many0, many0, many1, separated_list0 } ;
1818use nom:: sequence:: { delimited, pair, preceded, separated_pair, terminated, tuple} ;
1919use table:: Table ;
2020
@@ -371,24 +371,24 @@ fn len_as_u16(len: &[u8]) -> u16 {
371371}
372372
373373pub ( crate ) fn opt_delimited < I : Clone , O1 , O2 , O3 , E : ParseError < I > , F , G , H > (
374- first : F ,
375- second : G ,
376- third : H ,
377- ) -> impl Fn ( I ) -> IResult < I , O2 , E >
374+ mut first : F ,
375+ mut second : G ,
376+ mut third : H ,
377+ ) -> impl FnMut ( I ) -> IResult < I , O2 , E >
378378where
379- F : Fn ( I ) -> IResult < I , O1 , E > ,
380- G : Fn ( I ) -> IResult < I , O2 , E > ,
381- H : Fn ( I ) -> IResult < I , O3 , E > ,
379+ F : Parser < I , O1 , E > ,
380+ G : Parser < I , O2 , E > ,
381+ H : Parser < I , O3 , E > ,
382382{
383383 move |input : I | {
384- let first_ = & first;
385- let second_ = & second;
386- let third_ = & third;
387-
388384 let inp = input. clone ( ) ;
389- match second ( input) {
385+ match second. parse ( input) {
390386 Ok ( ( i, o) ) => Ok ( ( i, o) ) ,
391- _ => delimited ( first_, second_, third_) ( inp) ,
387+ _ => {
388+ let ( inp, _) = first. parse ( inp) ?;
389+ let ( inp, o2) = second. parse ( inp) ?;
390+ third. parse ( inp) . map ( |( i, _) | ( i, o2) )
391+ } ,
392392 }
393393 }
394394}
@@ -695,7 +695,7 @@ pub fn column_function(i: &[u8]) -> IResult<&[u8], FunctionExpression> {
695695 FunctionExpression :: GroupConcat ( FunctionArgument :: Column ( col. clone ( ) ) , sep)
696696 } ,
697697 ) ,
698- map ( tuple ( ( sql_identifier, multispace0, tag ( "(" ) , separated_list ( tag ( "," ) , delimited ( multispace0, function_argument_parser, multispace0) ) , tag ( ")" ) ) ) , |tuple| {
698+ map ( tuple ( ( sql_identifier, multispace0, tag ( "(" ) , separated_list0 ( tag ( "," ) , delimited ( multispace0, function_argument_parser, multispace0) ) , tag ( ")" ) ) ) , |tuple| {
699699 let ( name, _, _, arguments, _) = tuple;
700700 FunctionExpression :: Generic (
701701 str:: from_utf8 ( name) . unwrap ( ) . to_string ( ) ,
0 commit comments