Esempio n. 1
0
extern void do_endwhile(void)
{
   if (in_false_if())
   {
      do_endif(0);
      input_unmark();
#ifdef DEBUG_WHILE

      if (debugging)
      {
         outputs("//endwhile:");
         outputd(curline());
         outputs(",");
         outputs(curfile());
         outputs("\\\\");
      }
#endif
      out_at(curline(), curfile());
   }
   else
   {
      do_endif(0);
      input_recover();
      input_mark();
      do_if(0);
   }
}
Esempio n. 2
0
int eval_expr (int Sharp, int Complain)
{
   char c;
   char d;
   int rv;

   sharp = Sharp;
   complain = Complain;
   expr = read_expr_();
   if (sharp)
   {
      c = getnonhspace();
      d = '\n';
   }
   else
   {
      c = getnonspace();
      d = ')';
   }
   if (c != d)
   {
      if (complain)
      {
         err_head();
         fprintf(stderr, "expression syntax error -- junk after expression\n");
      }
      while (Get() != d)
         ;
   }
#ifdef DEBUG_EXPR
   if (debugging)
   {
      outputc('<');
      dump_expr(expr);
      outputc('=');
      rv = exec_free(expr);
      outputd(rv);
      outputc('>');
   }
   else
   {
      rv = exec_free(expr);
   }
   return (rv);
#else

   return (exec_free(expr));
#endif
}
Esempio n. 3
0
static EORB_CPP_node *read_expr_11 (void)
{
   char c;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E11:");
   }
#endif
   while (1)
   {
      c = getnhsexpand();
      if (c == '(')
      {
         EORB_CPP_node *n;
#ifdef DEBUG_EXPR

         if (debugging)
         {
            outputs("()");
         }
#endif
         n = read_expr_();
         c = getnhsexpand();
         if (c != ')')
         {
            err_head();
            fprintf(stderr, "expression syntax error -- missing ) supplied\n");
            Push(c);
         }
#ifdef DEBUG_EXPR
         if (debugging)
         {
            outputs("~");
         }
#endif
         return (n);
      }
      else if (isdigit((int) c))
      {
         int base;
         static char digits[] = "0123456789abcdefABCDEF";
         static char values[] =
            "\0\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\12\13\14\15\16\17";
         char *d;
         int v;
#ifdef DEBUG_EXPR

         if (debugging)
         {
            outputs("N");
         }
#endif
         base = 10;
         if (c == '0')
         {
            base = 8;
            c = Get();
            if ((c == 'x') || (c == 'X'))
            {
               base = 16;
               c = Get();
            }
         }
         v = 0;
         while (1)
         {
            d = strchr(digits, c);
            if (d == 0)
            {
               Push(c);
#ifdef DEBUG_EXPR

               if (debugging)
               {
                  outputd(v);
                  outputs("~");
               }
#endif
               return (newleaf(v));
            }
            else if (values[d -digits] >= base)
            {
               err_head();
               fprintf(stderr, "warning: illegal %sdigit `%c'\n",
                       (base == 16) ? "hex " : (base == 8) ? "octal " : "", c);
            }
            v = (v * base) + values[d - digits];
            c = Get();
         }
      }
      else if (c == '\'')
      {
         int i;
         int j;
         int n;
         i = 0;
         n = 0;
         while (1)
         {
            j = get_quote_char();
            if (j < 0)
            {
               break;
            }
            i = (i << 8) | j;
            n ++;
         }
         if (n > 4)
         {
            err_head();
            fprintf(stderr, "warning: too many characters in character constant\n");
         }
         return (newleaf(i));
      }
      else if ((c == '\n') && !sharp)
      {}
      else
      {
         char *id;
         if (complain)
         {
            err_head();
            fprintf(stderr, "expression syntax error -- number expected\n");
         }
         if (isbsymchar(c))
         {
            Push(c);
            id = read_ident();
         }
         else
         {
            id = 0;
         }
#ifdef DEBUG_EXPR
         if (debugging)
         {
            outputs("0(");
            outputc(c);
            outputs(":");
            outputs(id ? id : "(none)");
            outputs(")~");
         }
#endif
         if (id)
         {
            os_free(id);
         }
         return (newleaf(0));
      }
   }
}