⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cstrccom.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 4 页
字号:
   constructName = GetConstructName(command,buffer);   if (constructName == NULL) return((SYMBOL_HN *) CLIPSFalseSymbol);   /*==========================================*/   /* Get a pointer to the construct's module. */   /*==========================================*/      constructModule = GetConstructModule(constructName,constructClass);   if (constructModule == NULL)     {      CantFindItemErrorMessage(constructClass->constructName,constructName);      return((SYMBOL_HN *) CLIPSFalseSymbol);     }        /*============================================*/   /* Return the name of the construct's module. */   /*============================================*/      return(constructModule->name);  }  /******************************************//* GetConstructModule: Driver routine for *//*   getting the module for a construct   *//******************************************/globle struct defmodule *GetConstructModule(constructName,constructClass)  char *constructName;  struct construct *constructClass;  {   struct constructHeader *constructPtr;   int count, position;   SYMBOL_HN *theName;      /*====================================================*/   /* If the construct name contains a module specifier, */   /* then get a pointer to the defmodule associated     */   /* with the specified name.                           */   /*====================================================*/      if ((position = FindModuleSeparator(constructName)) != CLIPS_FALSE)     {      theName = ExtractModuleName(position,constructName);      if (theName != NULL)         { return((struct defmodule *) FindDefmodule(ValueToString(theName))); }     }        /*============================================*/   /* No module was specified, so search for the */   /* named construct in the current module and  */   /* modules from which it imports.             */   /*============================================*/      constructPtr = (struct constructHeader *)                   FindImportedConstruct(constructClass->constructName,NULL,constructName,                                        &count,CLIPS_TRUE,NULL);   if (constructPtr == NULL) return(NULL);   return(constructPtr->whichModule->theModule);  }/*************************************//* Undefconstruct: Generic C routine *//*   for deleting a construct.       *//*************************************/globle BOOLEAN Undefconstruct(theConstruct,constructClass)  VOID *theConstruct;  struct construct *constructClass;  {#if BLOAD_ONLY || RUN_TIME#if MAC_MPW || MAC_MCW#pragma unused(theConstruct)#pragma unused(constructClass)#endif   return(CLIPS_FALSE);#else   VOID *currentConstruct,*nextConstruct;   BOOLEAN success;      /*================================================*/   /* Delete all constructs of the specified type if */   /* the construct pointer is the NULL pointer.     */   /*================================================*/   if (theConstruct == NULL)     {      success = CLIPS_TRUE;            /*===================================================*/      /* Loop through all of the constructs in the module. */      /*===================================================*/            currentConstruct = (*constructClass->getNextItemFunction)(NULL);      while (currentConstruct != NULL)        {         /*==============================*/         /* Remember the next construct. */         /*==============================*/                  nextConstruct = (*constructClass->getNextItemFunction)(currentConstruct);                  /*=============================*/         /* Try deleting the construct. */         /*=============================*/                  if ((*constructClass->isConstructDeletableFunction)(currentConstruct))           {            RemoveConstructFromModule((struct constructHeader *) currentConstruct);            (*constructClass->freeFunction)(currentConstruct);           }         else           {            CantDeleteItemErrorMessage(constructClass->constructName,                        ValueToString((*constructClass->getConstructNameFunction)(currentConstruct)));            success = CLIPS_FALSE;           }                    /*================================*/         /* Move on to the next construct. */         /*================================*/                  currentConstruct = nextConstruct;        }              /*================================================*/      /* Perform periodic cleanup if CLIPS is embedded. */      /*================================================*/            if ((CurrentEvaluationDepth == 0) && (! EvaluatingTopLevelCommand) &&          (CurrentExpression == NULL))        { PeriodicCleanup(CLIPS_TRUE,CLIPS_FALSE); }      /*============================================*/      /* Return TRUE if all constructs successfully */      /* deleted, otherwise FALSE.                  */      /*============================================*/            return(success);     }        /*==================================================*/   /* Return FALSE if the construct cannot be deleted. */   /*==================================================*/   if ((*constructClass->isConstructDeletableFunction)(theConstruct) == CLIPS_FALSE)     { return(CLIPS_FALSE); }   /*===========================*/   /* Remove the construct from */   /* the list in its module.   */   /*===========================*/      RemoveConstructFromModule((struct constructHeader *) theConstruct);      /*=======================*/   /* Delete the construct. */   /*=======================*/      (*constructClass->freeFunction)(theConstruct);      /*================================================*/   /* Perform periodic cleanup if CLIPS is embedded. */   /*================================================*/   if ((CurrentEvaluationDepth == 0) && (! EvaluatingTopLevelCommand) &&       (CurrentExpression == NULL))     { PeriodicCleanup(CLIPS_TRUE,CLIPS_FALSE); }   /*=============================*/   /* Return TRUE to indicate the */   /* construct was deleted.      */   /*=============================*/      return(CLIPS_TRUE);#endif  }  /***********************************//* SaveConstruct: Generic routine  *//*   for saving a construct class. *//***********************************/globle VOID SaveConstruct(logicalName,constructClass)  char *logicalName;  struct construct *constructClass;  {   struct defmodule *theModule;   char *ppform;   struct constructHeader *theConstruct;   /*==========================*/   /* Save the current module. */   /*==========================*/      SaveCurrentModule();      /*===========================*/   /* Loop through each module. */   /*===========================*/      for (theModule = (struct defmodule *) GetNextDefmodule(NULL);        theModule != NULL;        theModule = (struct defmodule *) GetNextDefmodule(theModule))     {      /*===========================*/      /* Set the current module to */      /* the one we're examining.  */      /*===========================*/            SetCurrentModule((VOID *) theModule);            /*==============================================*/      /* Loop through each construct of the specified */      /* construct class in the module.               */      /*==============================================*/            for (theConstruct = (struct constructHeader *)                          (*constructClass->getNextItemFunction)(NULL);           theConstruct != NULL;           theConstruct = (struct constructHeader *)                          (*constructClass->getNextItemFunction)(theConstruct))        {         /*==========================================*/         /* Print the construct's pretty print form. */         /*==========================================*/                  ppform = (*constructClass->getPPFormFunction)(theConstruct);             if (ppform != NULL)           {            PrintInChunks(logicalName,ppform);            PrintCLIPS(logicalName,"\n");           }        }     }        /*=============================*/   /* Restore the current module. */   /*=============================*/      RestoreCurrentModule();  }  /*********************************************************//* GetConstructModuleName: Generic routine for returning *//*   the name of the module to which a construct belongs *//*********************************************************/globle char *GetConstructModuleName(theConstruct)  struct constructHeader *theConstruct;  { return(GetDefmoduleName((VOID *) theConstruct->whichModule->theModule)); }/*********************************************************//* GetConstructNameString: Generic routine for returning *//*   the name string of a construct.                     *//*********************************************************/globle char *GetConstructNameString(theConstruct)  struct constructHeader *theConstruct;  { return(ValueToString(theConstruct->name)); }/**********************************************************//* GetConstructNamePointer: Generic routine for returning *//*   the name pointer of a construct.                     *//**********************************************************/globle SYMBOL_HN *GetConstructNamePointer(theConstruct)  struct constructHeader *theConstruct;  { return(theConstruct->name); }/***************************************************//* GetConstructListFunction: Generic CLIPS Routine *//*   for retrieving the constructs in a module.    *//***************************************************/globle VOID GetConstructListFunction(functionName,returnValue,constructClass)  char *functionName;  DATA_OBJECT_PTR returnValue;  struct construct *constructClass;  {   struct defmodule *theModule;   DATA_OBJECT result;   int numArgs;      /*============================================*/   /* Check for the correct number of arguments. */   /*============================================*/      if ((numArgs = ArgCountCheck(functionName,NO_MORE_THAN,1)) == -1)     {            SetMultifieldErrorValue(returnValue);      return;     }        /*====================================*/   /* If an argument was given, check to */   /* see that it's a valid module name. */   /*====================================*/   if (numArgs == 1)     {      /*======================================*/      /* Only symbols are valid module names. */      /*======================================*/            RtnUnknown(1,&result);      if (GetType(result) != SYMBOL)        {         SetMultifieldErrorValue(returnValue);         ExpectedTypeError1(functionName,1,"defmodule name");         return;        }              /*===========================================*/      /* Verify that the named module exists or is */      /* the symbol * (for obtaining the construct */      /* list for all modules).                    */      /*===========================================*/                         if ((theModule = (struct defmodule *) FindDefmodule(DOToString(result))) == NULL)        {         if (strcmp("*",DOToString(result)) != 0)            {            SetMultifieldErrorValue(returnValue);            ExpectedTypeError1(functionName,1,"defmodule name");            return;           }                    theModule = NULL;        }     }        /*=====================================*/   /* Otherwise use the current module to */   /* generate the construct list.        */   /*=====================================*/      else     { theModule = ((struct defmodule *) GetCurrentModule()); }     /*=============================*/   /* Call the driver routine to  */   /* get the list of constructs. */   /*=============================*/      GetConstructList(returnValue,constructClass,theModule);  }  /********************************************//* GetConstructList: Generic C Routine for  *//*   retrieving the constructs in a module. *//********************************************/globle VOID GetConstructList(returnValue,constructClass,theModule)  DATA_OBJECT_PTR returnValue;  struct construct *constructClass;  struct defmodule *theModule;  {    VOID *theConstruct;   long count = 0;   struct multifield *theList;   SYMBOL_HN *theName;   struct defmodule *loopModule;   int allModules = CLIPS_FALSE;      /*==========================*/   /* Save the current module. */   /*==========================*/      SaveCurrentModule();         /*=======================================*/   /* If the module specified is NULL, then */   /* get all constructs in all modules.    */   /*=======================================*/   if (theModule == NULL)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -