Exemple #1
0
      //
      // PPTokenTBuf::IsNumFlt
      //
      bool PPTokenTBuf::IsNumFlt(Core::String str)
      {
         char const *itr = str.begin(), *end = str.end();

         itr = SkipFlt(itr, end);

         // floating-suffix(opt)
         if(itr == end) return true;
         return (*itr == 'F' || *itr == 'f' || *itr == 'L' || *itr == 'l') && ++itr == end;
      }
Exemple #2
0
      //
      // PPTokenTBuf::IsNumInt
      //
      bool PPTokenTBuf::IsNumInt(Core::String str)
      {
         char const *itr = str.begin(), *end = str.end();

         if(*itr == '0')
         {
            ++itr;

            // hexadecimal-constant
            if(*itr == 'X' || *itr == 'x')
               itr = SkipHex(itr, end);

            // octal-constant
            else
               itr = SkipOct(itr, end);
         }

         // decimal-constant
         else if('1' <= *itr && *itr <= '9')
            itr = SkipDec(++itr, end);

         else
            return false;

         // integer-suffix(opt)
         if(itr == end) return true;

         auto upr = [&itr](std::size_t i) {return std::toupper(itr[i]);};

         // unsigned-suffix long-suffix(opt)
         if(end - itr == 1 && upr(0) == 'U') return true;
         if(end - itr == 2 && upr(0) == 'U' && upr(1) == 'L') return true;

         // unsigned-suffix long-long-suffix
         if(end - itr == 3 && upr(0) == 'U' && upr(1) == 'L' && itr[2] == itr[1]) return true;

         // long-suffix unsigned-suffix(opt)
         if(end - itr == 1 && upr(0) == 'L') return true;
         if(end - itr == 2 && upr(0) == 'L' && upr(1) == 'U') return true;

         // long-long-suffix unsigned-suffix(opt)
         if(end - itr == 2 && upr(0) == 'L' && itr[1] == itr[0]) return true;
         if(end - itr == 3 && upr(0) == 'L' && itr[1] == itr[0] && upr(2) == 'U') return true;

         return false;
      }
Exemple #3
0
      //
      // PPTokenTBuf::IsNumFix
      //
      bool PPTokenTBuf::IsNumFix(Core::String str)
      {
         char const *itr = str.begin(), *end = str.end();

         itr = SkipFlt(itr, end);

         // unsigned-suffix(opt)
         if(itr == end) return false;
         if(*itr == 'U' || *itr == 'u') ++itr;

         // fxp-suffix(opt)
         if(itr == end) return false;
         if(*itr == 'L' || *itr == 'l' || *itr == 'H' || *itr == 'h') ++itr;

         // fixed-qual
         if(itr == end) return false;
         return (*itr == 'K' || *itr == 'k' || *itr == 'R' || *itr == 'r') && ++itr == end;
      }
Exemple #4
0
   //
   // Info::lenString
   //
   std::size_t Info::lenString(Core::String s)
   {
      std::size_t len = 0;

      for(auto i = s.begin(), e = s.end(); i != e; ++i) switch(*i)
      {
      case '\0':
         if('0' <= i[1] && i[1] <= '7')
            len += 4;
         else
            len += 2;
         break;

      case '\\':
         len += 2;
         break;

      default:
         len += 1;
         break;
      }

      return len + 1;
   }