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

📄 cstrccom.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 4 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*             CLIPS Version 6.05  04/09/97             */   /*                                                     */   /*              CONSTRUCT COMMANDS MODULE              */   /*******************************************************//*************************************************************//* Purpose: Contains generic routines for deleting, pretty   *//*   printing, finding, obtaining module information,        *//*   obtaining lists of constructs, listing constructs, and  *//*   manipulation routines.                                  *//*                                                           *//* Principal Programmer(s):                                  *//*      Gary D. Riley                                        *//*      Brian L. Donnell                                     *//*                                                           *//* Contributing Programmer(s):                               *//*                                                           *//* Revision History:                                         *//*                                                           *//*************************************************************/#define _CSTRCCOM_SOURCE_#include <string.h>#include "setup.h"#include "constant.h"#include "clipsmem.h"#include "moduldef.h"#include "argacces.h"#include "multifld.h"#include "modulutl.h"#include "router.h"#include "utility.h"#include "commline.h"#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE#include "bload.h"#endif#if (! BLOAD_ONLY) && (! RUN_TIME)#include "cstrcpsr.h"#endif#include "cstrccom.h"/***************************************//* LOCAL INTERNAL FUNCTION DEFINITIONS *//***************************************/#if ANSI_COMPILER#if DEBUGGING_FUNCTIONS   static VOID                    ConstructPrintWatch(char *,struct construct *,VOID *,                                                      BOOLEAN (*)(VOID *));   static BOOLEAN                 ConstructWatchSupport(struct construct *,char *,                                                        char *,EXPRESSION *,BOOLEAN,                                                        BOOLEAN,BOOLEAN (*)(VOID *),                                                        VOID (*)(BOOLEAN,VOID *));#endif#else#if DEBUGGING_FUNCTIONS   static VOID                    ConstructPrintWatch();   static BOOLEAN                 ConstructWatchSupport();#endif#endif#if (! RUN_TIME)/************************************//* AddConstructToModule: Adds a     *//* construct to the current module. *//************************************/globle VOID AddConstructToModule(theConstruct)  struct constructHeader *theConstruct;  {   if (theConstruct->whichModule->lastItem == NULL)     { theConstruct->whichModule->firstItem = theConstruct; }   else     { theConstruct->whichModule->lastItem->next = theConstruct; }      theConstruct->whichModule->lastItem = theConstruct;   theConstruct->next = NULL;  }#endif /* (! RUN_TIME) *//****************************************************//* DeleteNamedConstruct: Generic driver routine for *//*   deleting a specific construct from a module.   *//****************************************************/globle BOOLEAN DeleteNamedConstruct(constructName,constructClass)  char *constructName;  struct construct *constructClass;  {#if (! BLOAD_ONLY)   VOID *constructPtr;   /*=============================*/   /* Constructs can't be deleted */   /* while a bload is in effect. */   /*=============================*/   #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE   if (Bloaded() == CLIPS_TRUE) return(CLIPS_FALSE);#endif   /*===============================*/   /* Look for the named construct. */   /*===============================*/      constructPtr = (*constructClass->findFunction)(constructName);   /*========================================*/   /* If the construct was found, delete it. */   /*========================================*/      if (constructPtr != NULL)     { return((*constructClass->deleteFunction)(constructPtr)); }    /*========================================*/   /* If the construct wasn't found, but the */   /* special symbol * was used, then delete */   /* all constructs of the specified type.  */   /*========================================*/      if (strcmp("*",constructName) == 0)     {      (*constructClass->deleteFunction)(NULL);      return(CLIPS_TRUE);     }   /*===============================*/   /* Otherwise, return FALSE to    */   /* indicate no deletion occured. */   /*===============================*/                 return(CLIPS_FALSE);#else   return(CLIPS_FALSE);#endif  }/*******************************************//* FindNamedConstruct: Generic routine for *//*   searching for a specified construct.  *//*******************************************/globle VOID *FindNamedConstruct(constructName,constructClass)  char *constructName;  struct construct *constructClass;  {   VOID *theConstruct;   SYMBOL_HN *findValue;       /*==========================*/   /* Save the current module. */   /*==========================*/      SaveCurrentModule();        /*=========================================================*/   /* Extract the construct name. If a module was specified,  */   /* then ExtractModuleAndConstructName will set the current */   /* module to the module specified in the name.             */   /*=========================================================*/      constructName = ExtractModuleAndConstructName(constructName);   /*=================================================*/   /* If a valid construct name couldn't be extracted */   /* or the construct name isn't in the symbol table */   /* (which means the construct doesn't exist), then */   /* return NULL to indicate the specified construct */   /* couldn't be found.                              */   /*=================================================*/      if ((constructName == NULL) ?       CLIPS_TRUE :       ((findValue = (SYMBOL_HN *) FindSymbol(constructName)) == NULL))     {      RestoreCurrentModule();      return(NULL);     }   /*===============================================*/   /* Loop through every construct of the specified */   /* class in the current module checking to see   */   /* if the construct's name matches the construct */   /* being sought. If found, restore the current   */   /* module and return a pointer to the construct. */   /*===============================================*/      for (theConstruct = (*constructClass->getNextItemFunction)(NULL);        theConstruct != NULL;        theConstruct = (*constructClass->getNextItemFunction)(theConstruct))     {       if (findValue == (*constructClass->getConstructNameFunction)(theConstruct))         {          RestoreCurrentModule();         return (theConstruct);        }     }    /*=============================*/   /* Restore the current module. */   /*=============================*/   RestoreCurrentModule();      /*====================================*/   /* Return NULL to indicated the named */   /* construct was not found.           */   /*====================================*/      return(NULL);  }/*****************************************//* UndefconstructCommand: Driver routine *//*   for the undef<construct> commands.  *//*****************************************/globle VOID UndefconstructCommand(command,constructClass)  char *command;  struct construct *constructClass;  {   char *constructName;   char buffer[80];      /*==============================================*/   /* Get the name of the construct to be deleted. */   /*==============================================*/      sprintf(buffer,"%s name",constructClass->constructName);   constructName = GetConstructName(command,buffer);   if (constructName == NULL) return;#if (! RUN_TIME) && (! BLOAD_ONLY)   /*=============================================*/   /* Check to see if the named construct exists. */   /*=============================================*/      if (((*constructClass->findFunction)(constructName) == CLIPS_FALSE) &&        (strcmp("*",constructName) != 0))     {      CantFindItemErrorMessage(constructClass->constructName,constructName);      return;     }        /*===============================================*/   /* If the construct does exist, try deleting it. */   /*===============================================*/      else if (DeleteNamedConstruct(constructName,constructClass) == CLIPS_FALSE)     {      CantDeleteItemErrorMessage(constructClass->constructName,constructName);      return;     }   return;#else   /*=====================================*/   /* Constructs can't be deleted in a    */   /* run-time or bload only environment. */   /*=====================================*/      CantDeleteItemErrorMessage(constructClass->constructName,constructName);   return;#endif  }   /******************************************//* PPConstructCommand: Driver routine for *//*   the ppdef<construct> commands.       *//******************************************/globle VOID PPConstructCommand(command,constructClass)  char *command;  struct construct *constructClass;  {   char *constructName;   char buffer[80];      /*===============================*/   /* Get the name of the construct */   /* to be "pretty printed."       */   /*===============================*/      sprintf(buffer,"%s name",constructClass->constructName);   constructName = GetConstructName(command,buffer);   if (constructName == NULL) return;   /*================================*/   /* Call the driver routine for    */   /* pretty printing the construct. */   /*================================*/      if (PPConstruct(constructName,WDISPLAY,constructClass) == CLIPS_FALSE)     { CantFindItemErrorMessage(constructClass->constructName,constructName); }  }  /***********************************//* PPConstruct: Driver routine for *//*   pretty printing a construct.  *//***********************************/globle int PPConstruct(constructName,logicalName,constructClass)  char *constructName;  char *logicalName;  struct construct *constructClass;  {   VOID *constructPtr;   /*==================================*/   /* Use the construct's name to find */   /* a pointer to actual construct.   */   /*==================================*/      constructPtr = (*constructClass->findFunction)(constructName);   if (constructPtr == NULL) return(CLIPS_FALSE);   /*==============================================*/   /* If the pretty print form is NULL (because of */    /* conserve-mem), return TRUE (which indicates  */   /* the construct was found).                    */   /*==============================================*/      if ((*constructClass->getPPFormFunction)(constructPtr) == NULL)      { return(CLIPS_TRUE); }      /*============================================*/   /* Print the pretty print string in smaller   */   /* chunks. (VMS had a bug that didn't allow   */   /* printing a string greater than 512 bytes.) */   /*============================================*/      PrintInChunks(logicalName,(*constructClass->getPPFormFunction)(constructPtr));      /*=======================================*/   /* Return TRUE to indicate the construct */   /* was found and pretty printed.         */   /*=======================================*/      return(CLIPS_TRUE);  }/*********************************************//* GetConstructModuleCommand: Driver routine *//*   for def<construct>-module routines      *//*********************************************/globle SYMBOL_HN *GetConstructModuleCommand(command,constructClass)  char *command;  struct construct *constructClass;  {   char *constructName;   char buffer[80];   struct defmodule *constructModule;      /*=========================================*/   /* Get the name of the construct for which */   /* we want to determine its module.        */   /*=========================================*/      sprintf(buffer,"%s name",constructClass->constructName);

⌨️ 快捷键说明

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