Ejemplo n.º 1
0
void set_chunk_real(chunk_t *pc, c_token_t token, log_sev_t what, const char *str)
{
   LOG_FUNC_ENTRY();

   c_token_t *where;
   c_token_t *type;
   c_token_t *parent_type;

   switch (what)
   {
   case (LSETTYP): where = &pc->type;
      type               = &token;
      parent_type        = &pc->parent_type;
      break;

   case (LSETPAR): where = &pc->parent_type;
      type               = &pc->type;
      parent_type        = &token;
      break;

   default:
      return;
   }

   if ((pc != NULL) && (*where != token))
   {
      LOG_FMT(what, "%s: %zu:%zu '%s' %s:%s => %s:%s",
              str, pc->orig_line, pc->orig_col, pc->text(),
              get_token_name(pc->type), get_token_name(pc->parent_type),
              get_token_name(*type), get_token_name(*parent_type));
      log_func_stack_inline(what);
      *where = token;
   }
}
Ejemplo n.º 2
0
static void chunk_log(chunk_t *pc, const char *text)
{
   if ((pc != NULL) && (cpd.unc_stage != US_TOKENIZE) && (cpd.unc_stage != US_CLEANUP))
   {
      const log_sev_t log   = LCHUNK;
      chunk_t         *prev = chunk_get_prev(pc);
      chunk_t         *next = chunk_get_next(pc);

      chunk_log_msg(pc, log, text);

      if (prev && next)
      {
         chunk_log_msg(prev, log, " @ between");
         chunk_log_msg(next, log, " and");
      }
      else if (next)
      {
         chunk_log_msg(next, log, " @ before");
      }
      else if (prev)
      {
         chunk_log_msg(prev, log, " @ after");
      }
      LOG_FMT(log, " stage=%d", cpd.unc_stage);
      log_func_stack_inline(log);
   }
}
Ejemplo n.º 3
0
static void chunk_log(chunk_t *pc, const char *text)
{
   if (pc && (cpd.unc_stage != US_TOKENIZE) && (cpd.unc_stage != US_CLEANUP))
   {
      chunk_t *prev = chunk_get_prev(pc);
      chunk_t *next = chunk_get_next(pc);

      LOG_FMT(LCHUNK, " -- %s: %lu:%lu '%s' [%s]",
              text, pc->orig_line, pc->orig_col, pc->text(),
              get_token_name(pc->type));

      if (prev && next)
      {
         LOG_FMT(LCHUNK, " @ between %lu:%lu '%s' [%s] and %lu:%lu '%s' [%s]",
                 prev->orig_line, prev->orig_col, prev->text(),
                 get_token_name(prev->type),
                 next->orig_line, next->orig_col, next->text(),
                 get_token_name(next->type));
      }
      else if (next)
      {
         LOG_FMT(LCHUNK, " @ before %lu:%lu '%s' [%s]",
                 next->orig_line, next->orig_col, next->text(),
                 get_token_name(next->type));
      }
      else if (prev)
      {
         LOG_FMT(LCHUNK, " @ after %lu:%lu '%s' [%s]",
                 prev->orig_line, prev->orig_col, prev->text(),
                 get_token_name(prev->type));
      }
      LOG_FMT(LCHUNK, " stage=%d", cpd.unc_stage);
      log_func_stack_inline(LCHUNK);
   }
}
Ejemplo n.º 4
0
static void remove_semicolon(chunk_t *pc)
{
   LOG_FUNC_ENTRY();
   LOG_FMT(LDELSEMI, "%s: Removed semicolon at line %lu, col %lu",
           __func__, pc->orig_line, pc->orig_col);
   log_func_stack_inline(LDELSEMI);
   /* TODO: do we want to shift stuff back a column? */
   chunk_del(pc);
}
Ejemplo n.º 5
0
void set_chunk_parent_real(chunk_t *pc, c_token_t pt)
{
   LOG_FUNC_ENTRY();
   if (pc && (pc->parent_type != pt))
   {
      LOG_FMT(LSETPAR, "set_chunk_parent: %lu:%lu '%s' %s:%s => %s:%s",
              pc->orig_line, pc->orig_col, pc->text(),
              get_token_name(pc->type), get_token_name(pc->parent_type),
              get_token_name(pc->type), get_token_name(pt));
      log_func_stack_inline(LSETPAR);
      pc->parent_type = pt;
   }
}
Ejemplo n.º 6
0
void set_chunk_type_real(chunk_t *pc, c_token_t tt)
{
   LOG_FUNC_ENTRY();
   if (pc && (pc->type != tt))
   {
      LOG_FMT(LSETTYP, "set_chunk_type: %lu:%lu '%s' %s:%s => %s:%s",
              pc->orig_line, pc->orig_col, pc->text(),
              get_token_name(pc->type), get_token_name(pc->parent_type),
              get_token_name(tt), get_token_name(pc->parent_type));
      log_func_stack_inline(LSETTYP);
      pc->type = tt;
   }
}
Ejemplo n.º 7
0
void chunk_flags_set_real(chunk_t *pc, UINT64 clr_bits, UINT64 set_bits)
{
   if (pc != NULL)
   {
      LOG_FUNC_ENTRY();
      UINT64 nflags = (pc->flags & ~clr_bits) | set_bits;
      if (pc->flags != nflags)
      {
         LOG_FMT(LSETFLG, "set_chunk_flags: %016" PRIx64 "^%016" PRIx64 "=%016" PRIx64 " %zu:%zu '%s' %s:%s",
                 pc->flags, pc->flags ^ nflags, nflags,
                 pc->orig_line, pc->orig_col, pc->text(),
                 get_token_name(pc->type), get_token_name(pc->parent_type));
         log_func_stack_inline(LSETFLG);
         pc->flags = nflags;
      }
   }
}
Ejemplo n.º 8
0
void set_chunk_real(chunk_t *pc, c_token_t token, log_sev_t what, const char *str)
{
   LOG_FUNC_ENTRY();

   c_token_t *where;
   c_token_t *type;
   c_token_t *parent_type;

   switch (what)
   {
   case (LSETTYP):
      where       = &pc->type;
      type        = &token;
      parent_type = &pc->parent_type;
      break;

   case (LSETPAR):
      where       = &pc->parent_type;
      type        = &pc->type;
      parent_type = &token;
      break;

   default:
      return;
   }

   if (pc != nullptr && *where != token)
   {
      LOG_FMT(what, "%s(%d): orig_line is %zu, orig_col is %zu, pc->text() '%s'\n",
              str, __LINE__, pc->orig_line, pc->orig_col, pc->text());
      LOG_FMT(what, "   pc->type is %s, pc->parent_type is %s => *type is %s, *parent_type is %s",
              get_token_name(pc->type), get_token_name(pc->parent_type),
              get_token_name(*type), get_token_name(*parent_type));
      log_func_stack_inline(what);
      *where = token;
   }
}