parser_pattern_process_nested_pattern (parser_context_t *context_p, /**< context */
                                       parser_pattern_flags_t flags, /**< flags */
                                       uint16_t rhs_opcode, /**< opcode to process the rhs value */
                                       uint16_t literal_index) /**< literal index for object pattern */
{
  JERRY_ASSERT (context_p->token.type == LEXER_LEFT_BRACE || context_p->token.type == LEXER_LEFT_SQUARE);

  parser_pattern_flags_t options = (PARSER_PATTERN_NESTED_PATTERN
                                    | PARSER_PATTERN_TARGET_ON_STACK
                                    | (flags & (PARSER_PATTERN_BINDING
                                                | PARSER_PATTERN_LET
                                                | PARSER_PATTERN_CONST
                                                | PARSER_PATTERN_LOCAL
                                                | PARSER_PATTERN_ARGUMENTS)));

  JERRY_ASSERT (context_p->next_scanner_info_p->source_p != context_p->source_p
                || context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER
                || context_p->next_scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS);

  if (context_p->next_scanner_info_p->source_p == context_p->source_p)
  {
    if (context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER)
    {
      if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)
      {
        options |= PARSER_PATTERN_HAS_REST_ELEMENT;
      }

      if (!(flags & PARSER_PATTERN_REST_ELEMENT))
      {
        options |= PARSER_PATTERN_TARGET_DEFAULT;
      }
      else
      {
        scanner_release_next (context_p, sizeof (scanner_location_info_t));
      }
    }
    else
    {
      if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)
      {
        options |= PARSER_PATTERN_HAS_REST_ELEMENT;
      }
      scanner_release_next (context_p, sizeof (scanner_info_t));
    }
  }

  parser_pattern_emit_rhs (context_p, rhs_opcode, literal_index);

  if (context_p->token.type == LEXER_LEFT_BRACE)
  {
    parser_parse_object_initializer (context_p, options);
  }
  else
  {
    parser_parse_array_initializer (context_p, options);
  }

  parser_emit_cbc (context_p, CBC_POP);
} /* parser_pattern_process_nested_pattern */
parser_pattern_process_nested_pattern (parser_context_t *context_p,  
                                       parser_pattern_flags_t flags,  
                                       uint16_t rhs_opcode,  
                                       uint16_t literal_index)  
{
  JERRY_ASSERT (context_p->token.type == LEXER_LEFT_BRACE || context_p->token.type == LEXER_LEFT_SQUARE);

  parser_pattern_flags_t options = (PARSER_PATTERN_NESTED_PATTERN
                                    | PARSER_PATTERN_TARGET_ON_STACK
                                    | (flags & (PARSER_PATTERN_BINDING
                                                | PARSER_PATTERN_LET
                                                | PARSER_PATTERN_CONST
                                                | PARSER_PATTERN_LOCAL
                                                | PARSER_PATTERN_ARGUMENTS)));

  JERRY_ASSERT (context_p->next_scanner_info_p->source_p != context_p->source_p
                || context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER
                || context_p->next_scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS);

  if (context_p->next_scanner_info_p->source_p == context_p->source_p)
  {
    if (context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER)
    {
      if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)
      {
        options |= PARSER_PATTERN_HAS_REST_ELEMENT;
      }

      if (!(flags & PARSER_PATTERN_REST_ELEMENT))
      {
        options |= PARSER_PATTERN_TARGET_DEFAULT;
      }
      else
      {
        scanner_release_next (context_p, sizeof (scanner_location_info_t));
      }
    }
    else
    {
      if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)
      {
        options |= PARSER_PATTERN_HAS_REST_ELEMENT;
      }
      scanner_release_next (context_p, sizeof (scanner_info_t));
    }
  }

  parser_pattern_emit_rhs (context_p, rhs_opcode, literal_index);

  if (context_p->token.type == LEXER_LEFT_BRACE)
  {
    parser_parse_object_initializer (context_p, options);
  }
  else
  {
    parser_parse_array_initializer (context_p, options);
  }

  parser_emit_cbc (context_p, CBC_POP);
}  