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

📄 reteutil.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
   while (theMarkers != NULL)     {      newMark = get_struct(multifieldMarker);      newMark->next = NULL;      newMark->whichField = theMarkers->whichField;      newMark->where = theMarkers->where;      newMark->startPosition = theMarkers->startPosition;      newMark->endPosition = theMarkers->endPosition;      if (lastMark == NULL)        { head = newMark; }      else        { lastMark->next = newMark; }      lastMark = newMark;      theMarkers = theMarkers->next;     }   return(head);  }/***************************************************************//* NewPseudoFactPartialMatch: Creates a partial structure that *//*   indicates the "pseudo" fact to which a not pattern CE has *//*   been bound. Since a non-existant fact has no fact index,  *//*   the partial match structure is given a pseudo fact index  *//*   (a unique negative integer). Note that a "pseudo" fact    *//*   can also be used as a "pseudo" instance.                  *//***************************************************************/globle struct partialMatch *NewPseudoFactPartialMatch()  {   struct partialMatch *linker;   struct alphaMatch *tempAlpha;   linker = get_struct(partialMatch);   linker->next = NULL;   linker->betaMemory = CLIPS_TRUE;   linker->busy = CLIPS_FALSE;   linker->activationf = CLIPS_FALSE;   linker->dependentsf = CLIPS_FALSE;   linker->notOriginf = CLIPS_TRUE;   linker->counterf = CLIPS_FALSE;   linker->bcount = 0;   tempAlpha = get_struct(alphaMatch);   tempAlpha->next = NULL;   tempAlpha->matchingItem = NULL;   tempAlpha->markers = NULL;   linker->binds[0].gm.theMatch = tempAlpha;   return(linker);  }/******************************************************************//* FlushAlphaBetaMemory: Returns all partial matches in a list of *//*   partial matches either directly to the pool of free memory   *//*   or to the list of GarbagePartialMatches. Partial matches     *//*   stored in alpha memories and partial matches which store the *//*   information for pseudo facts (for not CEs) may be referred   *//*   to by other data structures and thus must be placed on the   *//*   list of GarbagePartialMatches.                               *//******************************************************************/globle VOID FlushAlphaBetaMemory(pfl)  struct partialMatch *pfl;  {   struct partialMatch *pfltemp;   while (pfl != NULL)     {      pfltemp = pfl->next;            if (((pfl->notOriginf) && (pfl->counterf == CLIPS_FALSE)) ||           (pfl->betaMemory == CLIPS_FALSE))        {         pfl->next = GarbagePartialMatches;         GarbagePartialMatches = pfl;        }      else        { ReturnPartialMatch(pfl); }      pfl = pfltemp;     }  }/***********************************************************************//* GetPatternNumberFromJoin: Given a pointer to a join associated with *//*   a pattern CE, returns an integer representing the position of the *//*   pattern CE in the rule (e.g. first, second, third).               *//***********************************************************************/globle int GetPatternNumberFromJoin(joinPtr)  struct joinNode *joinPtr;  {   int whichOne = 0;      while (joinPtr != NULL)     {      if (joinPtr->joinFromTheRight)        { joinPtr = (struct joinNode *) joinPtr->rightSideEntryStructure; }      else        {         whichOne++;         joinPtr = joinPtr->lastLevel;        }     }        return(whichOne);  }                  /************************************************************************//* TraceErrorToRule: Prints an error message when a error occurs as the *//*   result of evaluating an expression in the pattern network. Used to *//*   indicate which rule caused the problem.                            *//************************************************************************/globle VOID TraceErrorToRule(joinPtr,indentSpaces)  struct joinNode *joinPtr;  char *indentSpaces;  {   MarkRuleNetwork(0);   TraceErrorToRuleDriver(joinPtr,indentSpaces);  }  /**************************************************************//* TraceErrorToRuleDriver: Driver code for printing out which *//*   rule caused a pattern or join network error.             *//**************************************************************/static VOID TraceErrorToRuleDriver(joinPtr,indentSpaces)  struct joinNode *joinPtr;  char *indentSpaces;  {   char *name;        while (joinPtr != NULL)     {      if (joinPtr->marked)         { /* Do Nothing */ }      else if (joinPtr->ruleToActivate != NULL)        {         joinPtr->marked = 1;         name = GetDefruleName((VOID *) joinPtr->ruleToActivate);         PrintCLIPS(WERROR,indentSpaces);         PrintCLIPS(WERROR,name);         PrintCLIPS(WERROR,"\n");        }           else         {          joinPtr->marked = 1;         TraceErrorToRuleDriver(joinPtr->nextLevel,indentSpaces);        }      joinPtr = joinPtr->rightDriveNode;     }  }        /********************************************************//* MarkRuleNetwork: Sets the marked flag in each of the *//*   joins in the join network to the specified value.  *//********************************************************/globle VOID MarkRuleNetwork(value)  int value;  {   struct defrule *rulePtr;   struct joinNode *joinPtr;   struct defmodule *modulePtr;   /*===========================*/   /* Loop through each module. */   /*===========================*/       SaveCurrentModule();   for (modulePtr = (struct defmodule *) GetNextDefmodule(NULL);        modulePtr != NULL;        modulePtr = (struct defmodule *) GetNextDefmodule(modulePtr))     {      SetCurrentModule((VOID *) modulePtr);            /*=========================*/      /* Loop through each rule. */      /*=========================*/      rulePtr = (struct defrule *) GetNextDefrule(NULL);      while (rulePtr != NULL)        {         /*=============================*/         /* Mark each join for the rule */         /* with the specified value.   */         /*=============================*/               joinPtr = rulePtr->lastJoin;         while (joinPtr != NULL)           {            joinPtr->marked = value;            joinPtr = GetPreviousJoin(joinPtr);           }         /*=================================*/         /* Move on to the next rule or the */         /* next disjunct for this rule.    */         /*=================================*/               if (rulePtr->disjunct != NULL) rulePtr = rulePtr->disjunct;         else rulePtr = (struct defrule *) GetNextDefrule(rulePtr);        }             }        RestoreCurrentModule();  }  #if (CONSTRUCT_COMPILER || BLOAD_AND_BSAVE) && (! RUN_TIME)/*************************************************************//* TagRuleNetwork: Assigns each join in the join network and *//*   each defrule data structure with a unique integer ID.   *//*   Also counts the number of defrule and joinNode data     *//*   structures currently in use.                            *//*************************************************************/globle VOID TagRuleNetwork(moduleCount,ruleCount,joinCount)  long int *moduleCount, *ruleCount, *joinCount;  {   struct defmodule *modulePtr;   struct defrule *rulePtr;   struct joinNode *joinPtr;   *moduleCount = 0;   *ruleCount = 0;   *joinCount = 0;      MarkRuleNetwork(0);      /*===========================*/   /* Loop through each module. */   /*===========================*/      for (modulePtr = (struct defmodule *) GetNextDefmodule(NULL);        modulePtr != NULL;        modulePtr = (struct defmodule *) GetNextDefmodule(modulePtr))     {      (*moduleCount)++;      SetCurrentModule((VOID *) modulePtr);            /*=========================*/      /* Loop through each rule. */      /*=========================*/      rulePtr = (struct defrule *) GetNextDefrule(NULL);      while (rulePtr != NULL)        {         rulePtr->header.bsaveID = *ruleCount;         (*ruleCount)++;                  /*=========================*/         /* Loop through each join. */         /*=========================*/         for (joinPtr = rulePtr->lastJoin;              joinPtr != NULL;              joinPtr = GetPreviousJoin(joinPtr))           {            if (joinPtr->marked == 0)              {               joinPtr->marked = 1;               joinPtr->bsaveID = *joinCount;               (*joinCount)++;              }           }            if (rulePtr->disjunct != NULL) rulePtr = rulePtr->disjunct;         else rulePtr = (struct defrule *) GetNextDefrule(rulePtr);        }     }  }  #endif /* (CONSTRUCT_COMPILER || BLOAD_AND_BSAVE) && (! RUN_TIME) */#endif /* DEFRULE_CONSTRUCT */

⌨️ 快捷键说明

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