Exemplo n.º 1
0
//
// SourceTokenizerC::get
//
SourceTokenC::Reference SourceTokenizerC::get()
{
   SourceTokenC::Pointer tok;

   for (;;)
   {
      tok = getExpand();

      // Preprocessor directive.
      if (tok->type == SourceTokenC::TT_ENDL)
      {
         while (tok->type == SourceTokenC::TT_ENDL)
            tok = getExpand();

         if (tok->type == SourceTokenC::TT_HASH1)
         {
            doCommand(); continue;
         }
      }

      if (isSkip())
         continue;

      if (tok->type == SourceTokenC::TT_NONE)
         continue;

      break;
   }

   // String literal concatenation.
   if (tok->type == SourceTokenC::TT_STR)
   {
      SourceTokenC::Reference tmpTok = get();

      if (tmpTok->type == SourceTokenC::TT_STR)
         tok = SourceTokenC::create(tok->pos, tok->data + tmpTok->data, tok->type);
      else
         unget(tmpTok);
   }

   return static_cast<SourceTokenC::Reference>(tok);
}
Exemplo n.º 2
0
//
// SourceTokenizerC::getExpand
//
SourceTokenC::Reference SourceTokenizerC::getExpand()
{
   SourceTokenC::Reference tok = getRaw();

   if (canExpand && tok->type == SourceTokenC::TT_NAM)
   {
      if (hasMacro(tok->data))
      {
         SourceTokenC::Reference tmpTok = getExpand();

         // Macro invocation!
         if (tmpTok->type == SourceTokenC::TT_PAREN_O)
         {
            expandMacro(tok); return getExpand();
         }

         unget(tmpTok);
      }

      if (hasDefine(tok->data))
      {
         expandDefine(tok); return getExpand();
      }

      if (tok->data == "__FILE__")
         return SourceTokenC::create(tok->pos, tok->pos.filename,
                                     SourceTokenC::TT_STR);

      if (tok->data == "__LINE__")
      {
         std::ostringstream oss; oss << tok->pos.line;
         return SourceTokenC::create(tok->pos, oss.str(), SourceTokenC::TT_INT);
      }
   }

   return tok;
}
Exemplo n.º 3
0
void TsubtitlesSettings::getExpand(int *x, int *y) const
{
    getExpand(isExpand, expandCode, x, y);
}