Пример #1
0
static chunk_t *chunk_search_typelevel(chunk_t *cur, c_token_t type, scope_e scope, direction_e dir, int level)
{
   /*
    * Depending on the parameter dir the search function searches
    * in forward or backward direction
    */
   search_t search_function = select_search_fct(dir);
   chunk_t  *pc             = cur;

   do                                  // loop over the chunk list
   {
      pc = search_function(pc, scope); // in either direction while
#if DEBUG
      if (pc != nullptr)
      {
         if (pc->type == CT_NEWLINE)
         {
            LOG_FMT(LCHUNK, "%s(%d): orig_line is %zu, orig_col is %zu, NEWLINE\n",
                    __func__, __LINE__, pc->orig_line, pc->orig_col);
         }
         else
         {
            LOG_FMT(LCHUNK, "%s(%d): orig_line is %zu, orig_col is %zu, pc->text() '%s', type is %s\n",
                    __func__, __LINE__, pc->orig_line, pc->orig_col, pc->text(), get_token_name(pc->type));
         }
      }
#endif
   } while (  pc != nullptr        // the end of the list was not reached yet
           && (is_expected_type_and_level(pc, type, level) == false));
   return(pc);                     // the latest chunk is the searched one
}
Пример #2
0
static chunk_t *chunk_search_typelevel(chunk_t *cur, c_token_t type, nav_t nav, loc_t dir, int level)
{
   /* Depending on the parameter dir the search function searches
    * in forward or backward direction */
   search_t search_function = select_search_fct(dir);
   chunk_t  *pc             = cur;

   do                                /* loop over the chunk list */
   {
      pc = search_function(pc, nav); /* in either direction while */
#if DEBUG
      if (pc != NULL)
      {
         LOG_FMT(LCHUNK, "%s(%d): pc: %s, type is %s, orig_line=%zu, orig_col=%zu\n",
                 __func__, __LINE__, pc->text(), get_token_name(pc->type), pc->orig_line, pc->orig_col);
      }
#endif
   } while ((pc != NULL) &&          /* the end of the list was not reached yet */
            (is_expected_type_and_level(pc, type, level) == false));
   return(pc);                       /* the latest chunk is the searched one */
}