@@ -1113,7 +1113,15 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1113
1113
ast:: ErrorKind :: RepetitionCountUnclosed ,
1114
1114
) ) ;
1115
1115
}
1116
- let count_start = self . parse_decimal ( ) ?;
1116
+ let count_start = match self . parse_decimal ( ) {
1117
+ Err ( ast:: Error { kind : ast:: ErrorKind :: DecimalEmpty , span, pattern} ) => return Err ( ast:: Error {
1118
+ kind : ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
1119
+ pattern,
1120
+ span,
1121
+ } ) ,
1122
+ Err ( e) => return Err ( e) ,
1123
+ Ok ( value) => value,
1124
+ } ;
1117
1125
let mut range = ast:: RepetitionRange :: Exactly ( count_start) ;
1118
1126
if self . is_eof ( ) {
1119
1127
return Err ( self . error (
@@ -1129,7 +1137,15 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1129
1137
) ) ;
1130
1138
}
1131
1139
if self . char ( ) != '}' {
1132
- let count_end = self . parse_decimal ( ) ?;
1140
+ let count_end = match self . parse_decimal ( ) {
1141
+ Err ( ast:: Error { kind : ast:: ErrorKind :: DecimalEmpty , span, pattern} ) => return Err ( ast:: Error {
1142
+ kind : ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
1143
+ pattern,
1144
+ span,
1145
+ } ) ,
1146
+ Err ( e) => return Err ( e) ,
1147
+ Ok ( value) => value,
1148
+ } ;
1133
1149
range = ast:: RepetitionRange :: Bounded ( count_start, count_end) ;
1134
1150
} else {
1135
1151
range = ast:: RepetitionRange :: AtLeast ( count_start) ;
@@ -3143,6 +3159,18 @@ bar
3143
3159
span: span( 4 ..4 ) ,
3144
3160
kind: ast:: ErrorKind :: RepetitionMissing ,
3145
3161
} ) ;
3162
+ assert_eq ! (
3163
+ parser( r"a{]}" ) . parse( ) . unwrap_err( ) ,
3164
+ TestError {
3165
+ span: span( 2 ..2 ) ,
3166
+ kind: ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
3167
+ } ) ;
3168
+ assert_eq ! (
3169
+ parser( r"a{1,]}" ) . parse( ) . unwrap_err( ) ,
3170
+ TestError {
3171
+ span: span( 4 ..4 ) ,
3172
+ kind: ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
3173
+ } ) ;
3146
3174
assert_eq ! (
3147
3175
parser( r"a{" ) . parse( ) . unwrap_err( ) ,
3148
3176
TestError {
@@ -3153,13 +3181,13 @@ bar
3153
3181
parser( r"a{}" ) . parse( ) . unwrap_err( ) ,
3154
3182
TestError {
3155
3183
span: span( 2 ..2 ) ,
3156
- kind: ast:: ErrorKind :: DecimalEmpty ,
3184
+ kind: ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
3157
3185
} ) ;
3158
3186
assert_eq ! (
3159
3187
parser( r"a{a" ) . parse( ) . unwrap_err( ) ,
3160
3188
TestError {
3161
3189
span: span( 2 ..2 ) ,
3162
- kind: ast:: ErrorKind :: DecimalEmpty ,
3190
+ kind: ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
3163
3191
} ) ;
3164
3192
assert_eq ! (
3165
3193
parser( r"a{9999999999}" ) . parse( ) . unwrap_err( ) ,
@@ -3177,7 +3205,7 @@ bar
3177
3205
parser( r"a{9,a" ) . parse( ) . unwrap_err( ) ,
3178
3206
TestError {
3179
3207
span: span( 4 ..4 ) ,
3180
- kind: ast:: ErrorKind :: DecimalEmpty ,
3208
+ kind: ast:: ErrorKind :: RepetitionQuantifierDecimalMissing ,
3181
3209
} ) ;
3182
3210
assert_eq ! (
3183
3211
parser( r"a{9,9999999999}" ) . parse( ) . unwrap_err( ) ,
0 commit comments