1
1
use nom:: character:: complete:: { alphanumeric1, multispace0, multispace1} ;
2
2
3
- use common:: { integer_literal, sql_identifier, string_literal, ws_sep_comma,
4
- ws_sep_equals} ;
3
+ use common:: { integer_literal, sql_identifier, string_literal, ws_sep_comma, ws_sep_equals} ;
5
4
use nom:: branch:: alt;
6
5
use nom:: bytes:: complete:: { tag, tag_no_case} ;
7
6
use nom:: combinator:: { map, opt} ;
@@ -10,6 +9,7 @@ use nom::sequence::tuple;
10
9
use nom:: IResult ;
11
10
12
11
pub fn table_options ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
12
+ // TODO: make the create options accessible
13
13
map (
14
14
separated_list ( table_options_separator, create_option) ,
15
15
|_| ( ) ,
@@ -36,50 +36,40 @@ fn create_option(i: &[u8]) -> IResult<&[u8], ()> {
36
36
) ) ( i)
37
37
}
38
38
39
-
40
39
/// Helper to parse equals-separated create option pairs.
41
40
/// Throws away the create option and value
42
- pub fn create_option_equals_pair < ' a , I , O1 , O2 , F , G > ( first : F , second : G ) -> impl Fn ( I ) -> IResult < I , ( ) >
41
+ pub fn create_option_equals_pair < ' a , I , O1 , O2 , F , G > (
42
+ first : F ,
43
+ second : G ,
44
+ ) -> impl Fn ( I ) -> IResult < I , ( ) >
43
45
where
44
- F : Fn ( I ) -> IResult < I , O1 > ,
45
- G : Fn ( I ) -> IResult < I , O2 > ,
46
- I : nom:: InputTakeAtPosition + nom:: InputTake + nom:: Compare < & ' a str > ,
47
- <I as nom:: InputTakeAtPosition >:: Item : nom:: AsChar + Clone ,
46
+ F : Fn ( I ) -> IResult < I , O1 > ,
47
+ G : Fn ( I ) -> IResult < I , O2 > ,
48
+ I : nom:: InputTakeAtPosition + nom:: InputTake + nom:: Compare < & ' a str > ,
49
+ <I as nom:: InputTakeAtPosition >:: Item : nom:: AsChar + Clone ,
48
50
{
49
51
move |i : I | {
50
52
let ( i, _o1) = first ( i) ?;
51
53
let ( i, _) = ws_sep_equals ( i) ?;
52
54
let ( i, _o2) = second ( i) ?;
53
- Ok ( ( i, ( ) ) )
55
+ Ok ( ( i, ( ) ) )
54
56
}
55
57
}
56
58
57
59
fn create_option_type ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
58
- create_option_equals_pair (
59
- tag_no_case ( "type" ) ,
60
- alphanumeric1
61
- ) ( i)
60
+ create_option_equals_pair ( tag_no_case ( "type" ) , alphanumeric1) ( i)
62
61
}
63
62
64
63
fn create_option_pack_keys ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
65
- create_option_equals_pair (
66
- tag_no_case ( "pack_keys" ) ,
67
- alt ( ( tag ( "0" ) , tag ( "1" ) ) )
68
- ) ( i)
64
+ create_option_equals_pair ( tag_no_case ( "pack_keys" ) , alt ( ( tag ( "0" ) , tag ( "1" ) ) ) ) ( i)
69
65
}
70
66
71
67
fn create_option_engine ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
72
- create_option_equals_pair (
73
- tag_no_case ( "engine" ) ,
74
- opt ( alphanumeric1)
75
- ) ( i)
68
+ create_option_equals_pair ( tag_no_case ( "engine" ) , opt ( alphanumeric1) ) ( i)
76
69
}
77
70
78
71
fn create_option_auto_increment ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
79
- create_option_equals_pair (
80
- tag_no_case ( "auto_increment" ) ,
81
- integer_literal,
82
- ) ( i)
72
+ create_option_equals_pair ( tag_no_case ( "auto_increment" ) , integer_literal) ( i)
83
73
}
84
74
85
75
fn create_option_default_charset ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
@@ -105,27 +95,17 @@ fn create_option_collate(i: &[u8]) -> IResult<&[u8], ()> {
105
95
}
106
96
107
97
fn create_option_comment ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
108
- create_option_equals_pair (
109
- tag_no_case ( "comment" ) ,
110
- string_literal,
111
- ) ( i)
98
+ create_option_equals_pair ( tag_no_case ( "comment" ) , string_literal) ( i)
112
99
}
113
100
114
101
fn create_option_max_rows ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
115
- create_option_equals_pair (
116
- tag_no_case ( "max_rows" ) ,
117
- integer_literal
118
- ) ( i)
102
+ create_option_equals_pair ( tag_no_case ( "max_rows" ) , integer_literal) ( i)
119
103
}
120
104
121
105
fn create_option_avg_row_length ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
122
- create_option_equals_pair (
123
- tag_no_case ( "avg_row_length" ) ,
124
- integer_literal
125
- ) ( i)
106
+ create_option_equals_pair ( tag_no_case ( "avg_row_length" ) , integer_literal) ( i)
126
107
}
127
108
128
-
129
109
fn create_option_row_format ( i : & [ u8 ] ) -> IResult < & [ u8 ] , ( ) > {
130
110
let ( remaining_input, ( _, _, _, _, _) ) = tuple ( (
131
111
tag_no_case ( "row_format" ) ,
0 commit comments