@@ -53,7 +53,7 @@ re_append_char_class (void *re_ctx_p, /**< RegExp compiler context */
53
53
/**
54
54
* Insert simple atom iterator
55
55
*/
56
- static void
56
+ static ecma_value_t
57
57
re_insert_simple_iterator (re_compiler_ctx_t * re_ctx_p , /**< RegExp compiler context */
58
58
uint32_t new_atom_start_offset ) /**< atom start offset */
59
59
{
@@ -63,7 +63,14 @@ re_insert_simple_iterator (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler con
63
63
64
64
qmin = re_ctx_p -> current_token .qmin ;
65
65
qmax = re_ctx_p -> current_token .qmax ;
66
- JERRY_ASSERT (qmin <= qmax );
66
+
67
+ if (qmin == 1 && qmax == 1 ) {
68
+ return ECMA_VALUE_EMPTY ;
69
+ }
70
+ else if (qmin > qmax )
71
+ {
72
+ return ecma_raise_syntax_error (ECMA_ERR_MSG ("RegExp quantifier error: qmin > qmax." ));
73
+ }
67
74
68
75
/* TODO: optimize bytecode length. Store 0 rather than INF */
69
76
@@ -83,6 +90,8 @@ re_insert_simple_iterator (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler con
83
90
{
84
91
re_insert_opcode (re_ctx_p -> bytecode_ctx_p , offset , RE_OP_NON_GREEDY_ITERATOR );
85
92
}
93
+
94
+ return ECMA_VALUE_EMPTY ;
86
95
} /* re_insert_simple_iterator */
87
96
88
97
/**
@@ -271,21 +280,15 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
271
280
re_append_char (bc_ctx_p , re_canonicalize ((ecma_char_t ) re_ctx_p -> current_token .value ,
272
281
re_ctx_p -> flags & RE_FLAG_IGNORE_CASE ));
273
282
274
- if ((re_ctx_p -> current_token .qmin != 1 ) || (re_ctx_p -> current_token .qmax != 1 ))
275
- {
276
- re_insert_simple_iterator (re_ctx_p , new_atom_start_offset );
277
- }
283
+ ret_value = re_insert_simple_iterator (re_ctx_p , new_atom_start_offset );
278
284
break ;
279
285
}
280
286
case RE_TOK_PERIOD :
281
287
{
282
288
JERRY_TRACE_MSG ("Compile a period\n" );
283
289
re_append_opcode (bc_ctx_p , RE_OP_PERIOD );
284
290
285
- if ((re_ctx_p -> current_token .qmin != 1 ) || (re_ctx_p -> current_token .qmax != 1 ))
286
- {
287
- re_insert_simple_iterator (re_ctx_p , new_atom_start_offset );
288
- }
291
+ ret_value = re_insert_simple_iterator (re_ctx_p , new_atom_start_offset );
289
292
break ;
290
293
}
291
294
case RE_TOK_ALTERNATIVE :
@@ -387,21 +390,16 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
387
390
: RE_OP_CHAR_CLASS );
388
391
uint32_t offset = re_get_bytecode_length (re_ctx_p -> bytecode_ctx_p );
389
392
390
- ECMA_TRY_CATCH (empty_value ,
391
- re_parse_char_class (re_ctx_p -> parser_ctx_p ,
392
- re_append_char_class ,
393
- re_ctx_p ,
394
- & (re_ctx_p -> current_token )),
395
- ret_value );
396
- re_insert_u32 (bc_ctx_p , offset , re_ctx_p -> parser_ctx_p -> num_of_classes );
393
+ ret_value = re_parse_char_class (re_ctx_p -> parser_ctx_p ,
394
+ re_append_char_class ,
395
+ re_ctx_p ,
396
+ & (re_ctx_p -> current_token ));
397
397
398
- if (( re_ctx_p -> current_token . qmin != 1 ) || ( re_ctx_p -> current_token . qmax != 1 ))
399
- {
400
- re_insert_simple_iterator (re_ctx_p , new_atom_start_offset );
398
+ if (! ECMA_IS_VALUE_ERROR ( ret_value )) {
399
+ re_insert_u32 ( bc_ctx_p , offset , re_ctx_p -> parser_ctx_p -> num_of_classes );
400
+ ret_value = re_insert_simple_iterator (re_ctx_p , new_atom_start_offset );
401
401
}
402
402
403
- ECMA_FINALIZE (empty_value );
404
-
405
403
break ;
406
404
}
407
405
case RE_TOK_END_GROUP :
0 commit comments