@@ -53,7 +53,7 @@ re_append_char_class (void *re_ctx_p, /**< RegExp compiler context */
5353/**
5454 * Insert simple atom iterator
5555 */
56- static void
56+ static ecma_value_t
5757re_insert_simple_iterator (re_compiler_ctx_t * re_ctx_p , /**< RegExp compiler context */
5858 uint32_t new_atom_start_offset ) /**< atom start offset */
5959{
@@ -63,7 +63,14 @@ re_insert_simple_iterator (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler con
6363
6464 qmin = re_ctx_p -> current_token .qmin ;
6565 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+ }
6774
6875 /* TODO: optimize bytecode length. Store 0 rather than INF */
6976
@@ -83,6 +90,8 @@ re_insert_simple_iterator (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler con
8390 {
8491 re_insert_opcode (re_ctx_p -> bytecode_ctx_p , offset , RE_OP_NON_GREEDY_ITERATOR );
8592 }
93+
94+ return ECMA_VALUE_EMPTY ;
8695} /* re_insert_simple_iterator */
8796
8897/**
@@ -271,21 +280,15 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
271280 re_append_char (bc_ctx_p , re_canonicalize ((ecma_char_t ) re_ctx_p -> current_token .value ,
272281 re_ctx_p -> flags & RE_FLAG_IGNORE_CASE ));
273282
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 );
278284 break ;
279285 }
280286 case RE_TOK_PERIOD :
281287 {
282288 JERRY_TRACE_MSG ("Compile a period\n" );
283289 re_append_opcode (bc_ctx_p , RE_OP_PERIOD );
284290
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 );
289292 break ;
290293 }
291294 case RE_TOK_ALTERNATIVE :
@@ -387,21 +390,16 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
387390 : RE_OP_CHAR_CLASS );
388391 uint32_t offset = re_get_bytecode_length (re_ctx_p -> bytecode_ctx_p );
389392
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 ));
397397
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 );
401401 }
402402
403- ECMA_FINALIZE (empty_value );
404-
405403 break ;
406404 }
407405 case RE_TOK_END_GROUP :
0 commit comments