if(function(return 0/-1))^_^switch里边嵌套if可以实现跳转!

switch里边嵌套if可以实现跳转!代码以后附上^_^

 

if (sl_pp_token_peek_get(&peek, &input)) {

            sl_pp_token_peek_destroy(&peek);

            return -1;

         }

 

int sl_pp_token_buffer_get(struct sl_pp_token_buffer *buffer,

                       struct sl_pp_token_info *out)

{

   /* Pop from stack first if not empty. */

   if (buffer->size) {

      *out = buffer->tokens[--buffer->size];

      return 0;

   }

 

   assert(buffer->context);

   return sl_pp_token_get(buffer->context, out);

}

 

int sl_pp_token_get(struct sl_pp_context *context,

                struct sl_pp_token_info *out)

{

   int c = _pure_getc(context);

 

   switch (c) {

   case ' ':

   case '/t':

      out->token = SL_PP_WHITESPACE;

      break;

 

   case '/n':

      out->token = SL_PP_NEWLINE;

      break;

 

   case '#':

      out->token = SL_PP_HASH;

      break;

 

   case ',':

      out->token = SL_PP_COMMA;

      break;

 

   case ';':

      out->token = SL_PP_SEMICOLON;

      break;

 

   case '{':

      out->token = SL_PP_LBRACE;

      break;

 

   case '}':

      out->token = SL_PP_RBRACE;

      break;

 

   case '(':

      out->token = SL_PP_LPAREN;

      break;

 

   case ')':

      out->token = SL_PP_RPAREN;

      break;

 

   case '[':

      out->token = SL_PP_LBRACKET;

      break;

 

   case ']':

      out->token = SL_PP_RBRACKET;

      break;

 

   case '.':

      {

         int c2 = _pure_getc(context);

 

         if (c2 == PURE_ERROR) {

            return -1;

         }

         if (c2 >= '0' && c2 <= '9') {

            _pure_ungetc(context, c2);

            _pure_ungetc(context, c);

            if (_tokenise_number(context, out)) {

               return -1;

            }

         } else {

            _pure_ungetc(context, c2);

            out->token = SL_PP_DOT;

         }

      }

      break;

 

   case '+':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '+') {

         out->token = SL_PP_INCREMENT;

      } else if (c == '=') {

         out->token = SL_PP_ADDASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_PLUS;

      }

      break;

 

   case '-':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '-') {

         out->token = SL_PP_DECREMENT;

      } else if (c == '=') {

         out->token = SL_PP_SUBASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_MINUS;

      }

      break;

 

   case '~':

      out->token = SL_PP_BITNOT;

      break;

 

   case '!':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '=') {

         out->token = SL_PP_NOTEQUAL;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_NOT;

      }

      break;

 

   case '*':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '=') {

         out->token = SL_PP_MULASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_STAR;

      }

      break;

 

   case '/':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '=') {

         out->token = SL_PP_DIVASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_SLASH;

      }

      break;

 

   case '%':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '=') {

         out->token = SL_PP_MODASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_MODULO;

      }

      break;

 

   case '<':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '<') {

         c = _pure_getc(context);

         if (c == PURE_ERROR) {

            return -1;

         }

         if (c == '=') {

            out->token = SL_PP_LSHIFTASSIGN;

         } else {

            _pure_ungetc(context, c);

            out->token = SL_PP_LSHIFT;

         }

      } else if (c == '=') {

         out->token = SL_PP_LESSEQUAL;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_LESS;

      }

      break;

 

   case '>':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '>') {

         c = _pure_getc(context);

         if (c == PURE_ERROR) {

            return -1;

         }

         if (c == '=') {

            out->token = SL_PP_RSHIFTASSIGN;

         } else {

            _pure_ungetc(context, c);

            out->token = SL_PP_RSHIFT;

         }

      } else if (c == '=') {

         out->token = SL_PP_GREATEREQUAL;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_GREATER;

      }

      break;

 

   case '=':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '=') {

         out->token = SL_PP_EQUAL;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_ASSIGN;

      }

      break;

 

   case '&':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '&') {

         out->token = SL_PP_AND;

      } else if (c == '=') {

         out->token = SL_PP_BITANDASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_BITAND;

      }

      break;

 

   case '^':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '^') {

         out->token = SL_PP_XOR;

      } else if (c == '=') {

         out->token = SL_PP_BITXORASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_BITXOR;

      }

      break;

 

   case '|':

      c = _pure_getc(context);

      if (c == PURE_ERROR) {

         return -1;

      }

      if (c == '|') {

         out->token = SL_PP_OR;

      } else if (c == '=') {

         out->token = SL_PP_BITORASSIGN;

      } else {

         _pure_ungetc(context, c);

         out->token = SL_PP_BITOR;

      }

      break;

 

   case '?':

      out->token = SL_PP_QUESTION;

      break;

 

   case ':':

      out->token = SL_PP_COLON;

      break;

 

   case '/0':

      out->token = SL_PP_EOF;

      break;

 

   case PURE_ERROR:

      return -1;

 

   default:

      if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_') {

         _pure_ungetc(context, c);

         if (_tokenise_identifier(context, out)) {

            return -1;

         }

      } else if (c >= '0' && c <= '9') {

         _pure_ungetc(context, c);

         if (_tokenise_number(context, out)) {

            return -1;

         }

      } else {

         out->data.other = c;

         out->token = SL_PP_OTHER;

      }

   }

 

   return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值