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

📄 cstrccom.c

📁 一套美国国家宇航局人工智能中心NASA的专家系统工具源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
   /*==========================*/      SaveCurrentModule();      /*==================================*/   /* Loop through all of the modules. */   /*==================================*/      for (theModule = GetNextDefmodule(NULL);        theModule != NULL;        theModule = GetNextDefmodule(theModule), moduleCount++)     {      /*=============================*/      /* Set the current module to   */      /* the module we're examining. */      /*=============================*/            SetCurrentModule((VOID *) theModule);      /*================================================*/      /* Perform the action for each of the constructs. */      /*================================================*/            theModuleItem = (struct defmoduleItemHeader *)                      GetModuleItem(theModule,moduleItemIndex);         for (theConstruct = theModuleItem->firstItem;           theConstruct != NULL;           theConstruct = theConstruct->next)        {         if (interruptable)           {             if (GetHaltExecution() == CLIPS_TRUE)               {               RestoreCurrentModule();               return(-1L);               }           }                     (*actionFunction)(theConstruct,userBuffer);        }     }        /*=============================*/   /* Restore the current module. */   /*=============================*/      RestoreCurrentModule();      /*=========================================*/   /* Return the number of modules traversed. */   /*=========================================*/      return(moduleCount);  }  /*****************************************************//* InitializeConstructHeader: Initializes construct  *//*   header info, including to which module item the *//*   new construct belongs                           *//*****************************************************/globle VOID InitializeConstructHeader(constructType,theConstruct,theConstructName)  char *constructType;  struct constructHeader *theConstruct;  SYMBOL_HN *theConstructName;  {   struct moduleItem *theModuleItem;   struct defmoduleItemHeader *theItemHeader;      theModuleItem = FindModuleItem(constructType);   theItemHeader = (struct defmoduleItemHeader *)                    GetModuleItem(NULL,theModuleItem->moduleIndex);                      theConstruct->whichModule = theItemHeader;   theConstruct->name = theConstructName;   theConstruct->ppForm = NULL;   theConstruct->bsaveID = 0L;   theConstruct->next = NULL;  }/*************************************************//* SetConstructPPForm: Sets a construct's pretty *//*   print form and deletes the old one.         *//*************************************************/globle VOID SetConstructPPForm(theConstruct,ppForm)  struct constructHeader *theConstruct;  char *ppForm;  {   if (theConstruct->ppForm != NULL)     {      rm((VOID *) theConstruct->ppForm,         (int) ((strlen(theConstruct->ppForm) + 1) * sizeof(char)));     }   theConstruct->ppForm = ppForm;  }#if DEBUGGING_FUNCTIONS/******************************************************//* ConstructPrintWatchAccess: Provides an interface   *//*   to the list-watch-items function for a construct *//******************************************************/globle BOOLEAN ConstructPrintWatchAccess(constructClass,log,argExprs,                                         getWatchFunc,setWatchFunc)  struct construct *constructClass;  char *log;  EXPRESSION *argExprs;#if ANSI_COMPILER  BOOLEAN (*getWatchFunc)(VOID *);  VOID (*setWatchFunc)(BOOLEAN,VOID *);#else  BOOLEAN (*getWatchFunc)();  VOID (*setWatchFunc)();#endif  {   return(ConstructWatchSupport(constructClass,"list-watch-items",log,argExprs,                                CLIPS_FALSE,CLIPS_FALSE,getWatchFunc,setWatchFunc));  }/**************************************************//* ConstructSetWatchAccess: Provides an interface *//*   to the watch function for a construct        *//**************************************************/globle BOOLEAN ConstructSetWatchAccess(constructClass,newState,argExprs,                                       getWatchFunc,setWatchFunc)  struct construct *constructClass;  BOOLEAN newState;  EXPRESSION *argExprs;#if ANSI_COMPILER  BOOLEAN (*getWatchFunc)(VOID *);  VOID (*setWatchFunc)(BOOLEAN,VOID *);#else  BOOLEAN (*getWatchFunc)();  VOID (*setWatchFunc)();#endif  {   return(ConstructWatchSupport(constructClass,"watch",WERROR,argExprs,                                CLIPS_TRUE,newState,getWatchFunc,setWatchFunc));  }/******************************************************//* ConstructWatchSupport: Generic construct interface *//*   into watch and list-watch-items.                 *//******************************************************/static BOOLEAN ConstructWatchSupport(constructClass,funcName,log,argExprs,                                     setFlag,newState,getWatchFunc,setWatchFunc)  struct construct *constructClass;  char *funcName,*log;  EXPRESSION *argExprs;  BOOLEAN setFlag,newState;#if ANSI_COMPILER  BOOLEAN (*getWatchFunc)(VOID *);  VOID (*setWatchFunc)(BOOLEAN,VOID *);#else  BOOLEAN (*getWatchFunc)();  VOID (*setWatchFunc)();#endif  {   struct defmodule *theModule;   VOID *theConstruct;   DATA_OBJECT constructName;   int argIndex = 2;      /*========================================*/   /* If no constructs are specified, then   */   /* show/set the trace for all constructs. */   /*========================================*/      if (argExprs == NULL)     {      /*==========================*/      /* Save the current module. */      /*==========================*/            SaveCurrentModule();            /*===========================*/      /* Loop through each module. */      /*===========================*/            for (theModule = (struct defmodule *) GetNextDefmodule(NULL);           theModule != NULL;           theModule = (struct defmodule *) GetNextDefmodule((VOID *) theModule))        {         /*============================*/         /* Set the current module to  */         /* the module being examined. */         /*============================*/                  SetCurrentModule((VOID *) theModule);                  /*====================================================*/         /* If we're displaying the names of constructs with   */         /* watch flags enabled, then preface each module      */         /* listing of constructs with the name of the module. */         /*====================================================*/                  if (setFlag == CLIPS_FALSE)           {            PrintCLIPS(log,GetDefmoduleName((VOID *) theModule));            PrintCLIPS(log,":\n");           }                    /*============================================*/         /* Loop through each construct in the module. */         /*============================================*/                  for (theConstruct = (*constructClass->getNextItemFunction)(NULL);              theConstruct != NULL;              theConstruct = (*constructClass->getNextItemFunction)(theConstruct))           {            /*=============================================*/            /* Either set the watch flag for the construct */            /* or display its current state.               */            /*=============================================*/                        if (setFlag)              { (*setWatchFunc)(newState,theConstruct); }            else              {               PrintCLIPS(log,"   ");               ConstructPrintWatch(log,constructClass,theConstruct,getWatchFunc);              }           }        }              /*=============================*/      /* Restore the current module. */      /*=============================*/            RestoreCurrentModule();            /*====================================*/      /* Return TRUE to indicate successful */      /* completion of the command.         */      /*====================================*/            return(CLIPS_TRUE);     }        /*==================================================*/   /* Show/set the trace for each specified construct. */   /*==================================================*/      while (argExprs != NULL)     {      /*==========================================*/      /* Evaluate the argument that should be a   */      /* construct name. Return FALSE is an error */      /* occurs when evaluating the argument.     */      /*==========================================*/            if (EvaluateExpression(argExprs,&constructName))        { return(CLIPS_FALSE); }            /*================================================*/      /* Check to see that it's a valid construct name. */      /*================================================*/            if ((constructName.type != SYMBOL) ? CLIPS_TRUE :          ((theConstruct = LookupConstruct(constructClass,                                           DOToString(constructName),CLIPS_TRUE)) == NULL))        {         ExpectedTypeError1(funcName,argIndex,constructClass->constructName);         return(CLIPS_FALSE);        }             /*=============================================*/      /* Either set the watch flag for the construct */      /* or display its current state.               */      /*=============================================*/      if (setFlag)        { (*setWatchFunc)(newState,theConstruct); }      else        { ConstructPrintWatch(log,constructClass,theConstruct,getWatchFunc); }              /*===============================*/      /* Move on to the next argument. */      /*===============================*/            argIndex++;      argExprs = GetNextArgument(argExprs);     }         /*====================================*/   /* Return TRUE to indicate successful */   /* completion of the command.         */   /*====================================*/        return(CLIPS_TRUE);  }  /*************************************************//* ConstructPrintWatch: Displays the trace value *//*   of a construct for list-watch-items         *//*************************************************/static VOID ConstructPrintWatch(log,constructClass,theConstruct,getWatchFunc)  char *log;  struct construct *constructClass;  VOID *theConstruct;#if ANSI_COMPILER  BOOLEAN (*getWatchFunc)(VOID *);#else  BOOLEAN (*getWatchFunc)();#endif  {   PrintCLIPS(log,ValueToString((*constructClass->getConstructNameFunction)(theConstruct)));   PrintCLIPS(log,(*getWatchFunc)(theConstruct) ? " = on\n" : " = off\n");  }   #endif /* DEBUGGING_FUNCTIONS *//*****************************************************//* LookupConstruct: Finds a construct in the current *//*   or imported modules. If specified, will also    *//*   look for construct in a non-imported module.    *//*****************************************************/globle VOID *LookupConstruct(constructClass,constructName,moduleNameAllowed)  struct construct *constructClass;  char *constructName;  BOOLEAN moduleNameAllowed;  {   VOID *theConstruct;   char *constructType;   int moduleCount;      /*============================================*/   /* Look for the specified construct in the    */   /* current module or in any imported modules. */   /*============================================*/      constructType = constructClass->constructName;   theConstruct = FindImportedConstruct(constructType,NULL,constructName,                                        &moduleCount,CLIPS_TRUE,NULL);   /*===========================================*/   /* Return NULL if the reference is ambiguous */   /* (it was found in more than one module).   */   /*===========================================*/      if (theConstruct != NULL)     {      if (moduleCount > 1)        {         AmbiguousReferenceErrorMessage(constructType,constructName);         return(NULL);        }      return(theConstruct);     }        /*=============================================*/   /* If specified, check to see if the construct */   /* is in a non-imported module.                */   /*=============================================*/      if (moduleNameAllowed && FindModuleSeparator(constructName))     { theConstruct = (*constructClass->findFunction)(constructName); }        /*====================================*/   /* Return a pointer to the construct. */   /*====================================*/      return(theConstruct);  }

⌨️ 快捷键说明

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