Exemplo n.º 1
0
/**
 * We are in a virtual brace and hit a newline.
 * If this should end the vbrace, then insert a VSEMICOLON and return that.
 *
 * @param pc   The newline (CT_NEWLINE)
 * @return     Either the newline or the newly inserted virtual semicolon
 */
chunk_t *pawn_check_vsemicolon(chunk_t *pc)
{
   chunk_t *vb_open;
   chunk_t *prev;

   /* Grab the open VBrace */
   vb_open = chunk_get_prev_type(pc, CT_VBRACE_OPEN, -1);

   /**
    * Grab the item before the newline
    * Don't do anything if:
    *  - the only thing previous is the V-Brace open
    *  - in a preprocessor
    *  - level > (vb_open->level + 1) -- ie, in () or []
    *  - it is something that needs a continuation
    *    + arith, assign, bool, comma, compare
    */
   prev = chunk_get_prev_ncnl(pc);
   if ((prev == NULL) ||
       (prev == vb_open) ||
       ((prev->flags & PCF_IN_PREPROC) != 0) ||
       pawn_continued(prev, vb_open->level + 1))
   {
      if (prev != NULL)
      {
         LOG_FMT(LPVSEMI, "%s:  no  VSEMI on line %d, prev='%s' [%s]\n",
                 __func__, prev->orig_line, prev->str.c_str(), get_token_name(prev->type));
      }
      return(pc);
   }

   return(pawn_add_vsemi_after(prev));
}
Exemplo n.º 2
0
void pawn_add_virtual_semicolons(void)
{
   LOG_FUNC_ENTRY();
   chunk_t *prev;
   chunk_t *pc;

   /** Add Pawn virtual semicolons */
   prev = NULL;
   if (cpd.lang_flags & LANG_PAWN)
   {
      pc = chunk_get_head();
      while ((pc = chunk_get_next(pc)) != NULL)
      {
         if (!chunk_is_comment(pc) &&
             !chunk_is_newline(pc) &&
             (pc->type != CT_VBRACE_CLOSE) &&
             (pc->type != CT_VBRACE_OPEN))
         {
            prev = pc;
         }
         if ((prev == NULL) ||
             ((pc->type != CT_NEWLINE) &&
              (pc->type != CT_BRACE_CLOSE) &&
              (pc->type != CT_VBRACE_CLOSE)))
         {
            continue;
         }

         /* we just hit a newline and we have a previous token */
         if (((prev->flags & PCF_IN_PREPROC) == 0) &&
             ((prev->flags & (PCF_IN_ENUM | PCF_IN_STRUCT)) == 0) &&
             (prev->type != CT_VSEMICOLON) &&
             (prev->type != CT_SEMICOLON) &&
             !pawn_continued(prev, prev->brace_level))
         {
            pawn_add_vsemi_after(prev);
            prev = NULL;
         }
      }
   }
}
Exemplo n.º 3
0
/**
 * follows a variable definition at level 0 until the end.
 * Adds a semicolon at the end, if needed.
 */
static chunk_t *pawn_process_variable(chunk_t *start)
{
   chunk_t *prev = NULL;
   chunk_t *pc   = start;

   while ((pc = chunk_get_next_nc(pc)) != NULL)
   {
      if ((pc->type == CT_NEWLINE) &&
          !pawn_continued(prev, start->level))
      {
         if ((prev->type != CT_VSEMICOLON) &&
             (prev->type != CT_SEMICOLON))
         {
            pawn_add_vsemi_after(prev);
         }
         break;
      }
      prev = pc;
   }
   return(pc);
}