@@ -113,8 +113,6 @@ pub(crate) struct TextBufferView<'a> {
113
113
offset : usize ,
114
114
}
115
115
116
- pub ( crate ) type ParseResult < ' a , T > = IonResult < ( T , TextBufferView < ' a > ) > ;
117
-
118
116
impl < ' data > TextBufferView < ' data > {
119
117
/// Constructs a new `TextBufferView` that wraps `data`, setting the view's `offset` to zero.
120
118
#[ inline]
@@ -432,10 +430,10 @@ impl<'data> TextBufferView<'data> {
432
430
alt ( (
433
431
// For `null` and `bool`, we use `read_` instead of `match_` because there's no additional
434
432
// parsing to be done.
435
- map ( match_and_length ( Self :: read_null ) , |( ion_type, length) | {
433
+ map ( match_and_length ( Self :: match_null ) , |( ion_type, length) | {
436
434
EncodedTextValue :: new ( MatchedValue :: Null ( ion_type) , self . offset ( ) , length)
437
435
} ) ,
438
- map ( match_and_length ( Self :: read_bool ) , |( value, length) | {
436
+ map ( match_and_length ( Self :: match_bool ) , |( value, length) | {
439
437
EncodedTextValue :: new ( MatchedValue :: Bool ( value) , self . offset ( ) , length)
440
438
} ) ,
441
439
// For `int` and the other types, we use `match` and store the partially-processed input in the
@@ -662,37 +660,27 @@ impl<'data> TextBufferView<'data> {
662
660
Ok ( ( remaining, matched) )
663
661
}
664
662
665
- /// Matches a boolean value.
666
- pub fn match_bool ( self ) -> IonMatchResult < ' data > {
667
- recognize ( Self :: read_bool) ( self )
668
- }
669
-
670
663
/// Matches and returns a boolean value.
671
- pub fn read_bool ( self ) -> IonParseResult < ' data , bool > {
664
+ pub fn match_bool ( self ) -> IonParseResult < ' data , bool > {
672
665
terminated (
673
666
alt ( ( value ( true , tag ( "true" ) ) , value ( false , tag ( "false" ) ) ) ) ,
674
667
Self :: peek_stop_character,
675
668
) ( self )
676
669
}
677
670
678
- /// Matches any type of null. (`null`, `null.null`, `null.int`, etc)
679
- pub fn match_null ( self ) -> IonMatchResult < ' data > {
680
- recognize ( Self :: read_null) ( self )
681
- }
682
-
683
- /// Matches and returns a null value.
684
- pub fn read_null ( self ) -> IonParseResult < ' data , IonType > {
671
+ /// Matches and returns any type of null. (`null`, `null.null`, `null.int`, etc)
672
+ pub fn match_null ( self ) -> IonParseResult < ' data , IonType > {
685
673
delimited (
686
674
complete_tag ( "null" ) ,
687
- opt ( preceded ( complete_char ( '.' ) , Self :: read_ion_type ) ) ,
675
+ opt ( preceded ( complete_char ( '.' ) , Self :: match_ion_type ) ) ,
688
676
Self :: peek_stop_character,
689
677
)
690
678
. map ( |explicit_ion_type| explicit_ion_type. unwrap_or ( IonType :: Null ) )
691
679
. parse ( self )
692
680
}
693
681
694
682
/// Matches and returns an Ion type.
695
- fn read_ion_type ( self ) -> IonParseResult < ' data , IonType > {
683
+ fn match_ion_type ( self ) -> IonParseResult < ' data , IonType > {
696
684
alt ( (
697
685
value ( IonType :: Null , complete_tag ( "null" ) ) ,
698
686
value ( IonType :: Bool , complete_tag ( "bool" ) ) ,
@@ -1929,6 +1917,7 @@ mod tests {
1929
1917
1930
1918
mismatch_ivm ( "ion_1_0" ) ;
1931
1919
mismatch_ivm ( "$ion__1_0" ) ;
1920
+ mismatch_ivm ( "$ion_1_0_0" ) ;
1932
1921
mismatch_ivm ( "$$ion_1_0" ) ;
1933
1922
mismatch_ivm ( "$ion_FF_FF" ) ;
1934
1923
}
@@ -2199,8 +2188,6 @@ mod tests {
2199
2188
MatchTest :: new ( input) . expect_mismatch ( match_length ( TextBufferView :: match_symbol) ) ;
2200
2189
}
2201
2190
2202
- // These inputs have leading/trailing whitespace to make them more readable, but the string
2203
- // matcher doesn't accept whitespace. We'll trim each one before testing it.
2204
2191
let good_inputs = & [
2205
2192
"'hello'" ,
2206
2193
"'😀😀😀'" ,
@@ -2264,7 +2251,8 @@ mod tests {
2264
2251
MatchTest :: new ( input) . expect_mismatch ( match_length ( TextBufferView :: match_decimal) ) ;
2265
2252
}
2266
2253
let good_inputs = & [
2267
- "5." , "-5." , "5.0" , "-5.0" , "5.0d0" , "-5.0d0" , "5.0D0" , "-5.0D0" , "5.0d+1" , "-5.0d-1" ,
2254
+ "5." , "-5." , "5.0" , "-5.0" , "5d0" , "5.d0" , "5.0d0" , "-5.0d0" , "5.0D0" , "-5.0D0" ,
2255
+ "5.0d+1" , "-5.0d-1" ,
2268
2256
] ;
2269
2257
for input in good_inputs {
2270
2258
match_decimal ( input) ;
@@ -2295,6 +2283,7 @@ mod tests {
2295
2283
"(a b)" ,
2296
2284
"(a++)" ,
2297
2285
"(++a)" ,
2286
+ "(a+=b)" ,
2298
2287
"(())" ,
2299
2288
"((()))" ,
2300
2289
"(1 (2 (3 4) 5) 6)" ,
0 commit comments