@@ -2,11 +2,12 @@ use nom::{
22 branch:: alt,
33 bytes:: complete:: { tag, take_till, take_while, take_while1} ,
44 combinator:: { complete, eof, map, recognize} ,
5- error:: { context, VerboseError , VerboseErrorKind } ,
5+ error:: context,
66 multi:: separated_list0,
7- sequence:: { delimited, preceded, terminated, tuple } ,
8- IResult , Offset ,
7+ sequence:: { delimited, preceded, terminated} ,
8+ IResult , Offset , Parser ,
99} ;
10+ use nom_language:: error:: { VerboseError , VerboseErrorKind } ;
1011use nu_protocol:: { LabeledError , Span , Value } ;
1112use prometheus_http_query:: Selector ;
1213
@@ -128,25 +129,27 @@ fn label(input: &str) -> IResult<&str, LabelMatcher, VerboseError<&str>> {
128129 context (
129130 "label" ,
130131 map (
131- tuple ( ( metric_label, operation, label_value) ) ,
132+ ( metric_label, operation, label_value) ,
132133 |( label, operation, value) | LabelMatcher {
133134 label,
134135 operation,
135136 value,
136137 } ,
137138 ) ,
138- ) ( input)
139+ )
140+ . parse ( input)
139141}
140142
141143fn labels ( input : & str ) -> IResult < & str , Vec < LabelMatcher > , VerboseError < & str > > {
142144 context (
143145 "labels" ,
144146 delimited ( tag ( "{" ) , separated_list0 ( tag ( "," ) , label) , tag ( "}" ) ) ,
145- ) ( input)
147+ )
148+ . parse ( input)
146149}
147150
148151fn label_value ( input : & str ) -> IResult < & str , & str , VerboseError < & str > > {
149- delimited ( tag ( "\" " ) , take_till ( |c| c == '"' ) , tag ( "\" " ) ) ( input)
152+ delimited ( tag ( "\" " ) , take_till ( |c| c == '"' ) , tag ( "\" " ) ) . parse ( input)
150153}
151154
152155/// Matches a metric name `[a-zA-Z_][a-zA-Z0-9_]*`
@@ -157,7 +160,8 @@ fn metric_label(input: &str) -> IResult<&str, &str, VerboseError<&str>> {
157160 take_while1 ( is_metric_label_start) ,
158161 take_while ( is_metric_label_end) ,
159162 ) ) ,
160- ) ( input)
163+ )
164+ . parse ( input)
161165}
162166
163167/// Matches a metric name `[a-zA-Z_:][a-zA-Z0-9_:]*`
@@ -168,7 +172,8 @@ fn metric_name(input: &str) -> IResult<&str, &str, VerboseError<&str>> {
168172 take_while1 ( is_metric_name_start) ,
169173 take_while ( is_metric_name_end) ,
170174 ) ) ,
171- ) ( input)
175+ )
176+ . parse ( input)
172177}
173178
174179fn operation ( input : & str ) -> IResult < & str , Operation , VerboseError < & str > > {
@@ -180,7 +185,8 @@ fn operation(input: &str) -> IResult<&str, Operation, VerboseError<&str>> {
180185 map ( tag ( "!~" ) , |_| Operation :: RegexNe ) ,
181186 map ( tag ( "=" ) , |_| Operation :: Eq ) ,
182187 ) ) ,
183- ) ( input)
188+ )
189+ . parse ( input)
184190}
185191
186192fn selector ( input : & str ) -> IResult < & str , Selector , VerboseError < & str > > {
@@ -198,7 +204,7 @@ fn selector(input: &str) -> IResult<&str, Selector, VerboseError<&str>> {
198204 selector
199205 } ) ,
200206 map ( label, |label_matcher| label_matcher. apply ( Selector :: new ( ) ) ) ,
201- map ( tuple ( ( metric_name, labels) ) , |( metric, labels) | {
207+ map ( ( metric_name, labels) , |( metric, labels) | {
202208 let mut selector = Selector :: new ( ) . metric ( metric) ;
203209
204210 for label_matcher in labels {
@@ -211,13 +217,14 @@ fn selector(input: &str) -> IResult<&str, Selector, VerboseError<&str>> {
211217 ) ) ,
212218 eof,
213219 ) ) ,
214- ) ( input)
220+ )
221+ . parse ( input)
215222}
216223
217224#[ cfg( test) ]
218225mod test {
219226 use super :: * ;
220- use nom :: error:: VerboseErrorKind ;
227+ use nom_language :: error:: VerboseErrorKind ;
221228 use nu_protocol:: {
222229 engine:: { EngineState , StateWorkingSet } ,
223230 Span ,
0 commit comments