Changeset 3d1329c in tol


Ignore:
Timestamp:
Mar 3, 2009, 9:34:43 AM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
994e0b6
Parents:
f66f51f
Message:

New built-in function GetGlobalFunctions that returns all functions of a grammar

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@681 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/set_type/setgra.cpp

    rf66f51f r3d1329c  
    21662166}
    21672167
     2168//--------------------------------------------------------------------
     2169DeclareContensClass(BSet, BSetTemporary, BSetGetGlobalFunctions);
     2170DefExtOpr(1, BSetGetGlobalFunctions, "GetGlobalFunctions", 1, 1, "Text",
     2171"(Text grammar)",
     2172I2("Returns all global functions returning specified grammar",
     2173         "Devuelve todas las funciones globales que devuelven el tipo "
     2174   "especificado"),
     2175BOperClassify::System_);
     2176//--------------------------------------------------------------------
     2177void BSetGetGlobalFunctions::CalcContens()
     2178//--------------------------------------------------------------------
     2179{
     2180  BText& graName = Text(Arg(1));
     2181  BGrammar* gra = BGrammar::FindByName(graName, true);
     2182  if(!gra) { return; }
     2183  BList* oprLst = gra->GetOperators();
     2184  BList* codeLst = NULL;
     2185  BList* aux = oprLst;
     2186  while(oprLst)
     2187  {
     2188    BSyntaxObject* obj = (BSyntaxObject*)Car(oprLst);
     2189    if(obj)
     2190    {
     2191      if(obj->Mode()==BOBJECTMODE)
     2192      {
     2193        codeLst = Cons(obj, codeLst);
     2194      }
     2195      else
     2196      {
     2197        BOperator* opr = (BOperator*)obj;
     2198        BUserFunCode* funCode = opr->GetCode();
     2199        if(funCode)
     2200        {
     2201          codeLst = Cons(funCode, codeLst);
     2202        }
     2203      }
     2204    }
     2205    oprLst = Cdr(oprLst);
     2206  };
     2207  DESTROY(aux);
     2208  contens_.RobElement(codeLst);
     2209}
     2210
     2211
    21682212#if !defined(USE_DELAY_INIT)
    21692213
    … …  
    26012645
    26022646
     2647
Note: See TracChangeset for help on using the changeset viewer.