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

📄 rulebsc.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*             CLIPS Version 6.24  06/05/06            */   /*                                                     */   /*          DEFRULE BASIC COMMANDS HEADER FILE         */   /*******************************************************//*************************************************************//* Purpose: Implements core commands for the defrule         *//*   construct such as clear, reset, save, undefrule,        *//*   ppdefrule, list-defrules, and                           *//*   get-defrule-list.                                       *//*                                                           *//* Principal Programmer(s):                                  *//*      Gary D. Riley                                        *//*                                                           *//* Contributing Programmer(s):                               *//*      Brian L. Donnell                                     *//*                                                           *//* Revision History:                                         *//*      6.23: Corrected compilation errors for files         *//*            generated by constructs-to-c. DR0861           *//*                                                           *//*            Changed name of variable log to logName        *//*            because of Unix compiler warnings of shadowed  *//*            definitions.                                   *//*                                                           *//*      6.24: Renamed BOOLEAN macro type to intBool.         *//*                                                           *//*************************************************************/#define _RULEBSC_SOURCE_#include "setup.h"#if DEFRULE_CONSTRUCT#include <stdio.h>#define _STDIO_INCLUDED_#include "argacces.h"#include "constrct.h"#include "envrnmnt.h"#include "router.h"#include "watch.h"#include "extnfunc.h"#include "ruledef.h"#include "engine.h"#include "drive.h"#include "reteutil.h"#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE#include "rulebin.h"#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)#include "rulecmp.h"#endif#include "rulebsc.h"/***************************************//* LOCAL INTERNAL FUNCTION DEFINITIONS *//***************************************/   static void                    ResetDefrules(void *);   static void                    ResetDefrulesPrime(void *);   static void                    SaveDefrules(void *,void *,char *);#if (! RUN_TIME)   static int                     ClearDefrulesReady(void *);   static void                    ClearDefrules(void *);#endif/*************************************************************//* DefruleBasicCommands: Initializes basic defrule commands. *//*************************************************************/globle void DefruleBasicCommands(  void *theEnv)  {   EnvAddResetFunction(theEnv,"defrule",ResetDefrules,70);   EnvAddResetFunction(theEnv,"defrule",ResetDefrulesPrime,10);   AddSaveFunction(theEnv,"defrule",SaveDefrules,0);#if (! RUN_TIME)   AddClearReadyFunction(theEnv,"defrule",ClearDefrulesReady,0);   EnvAddClearFunction(theEnv,"defrule",ClearDefrules,0);#endif   #if DEBUGGING_FUNCTIONS   AddWatchItem(theEnv,"rules",0,&DefruleData(theEnv)->WatchRules,70,DefruleWatchAccess,DefruleWatchPrint);#endif#if ! RUN_TIME   EnvDefineFunction2(theEnv,"get-defrule-list",'m',PTIEF GetDefruleListFunction,"GetDefruleListFunction","01w");   EnvDefineFunction2(theEnv,"undefrule",'v',PTIEF UndefruleCommand,"UndefruleCommand","11w");   EnvDefineFunction2(theEnv,"defrule-module",'w',PTIEF DefruleModuleFunction,"DefruleModuleFunction","11w");#if DEBUGGING_FUNCTIONS   EnvDefineFunction2(theEnv,"rules",'v', PTIEF ListDefrulesCommand,"ListDefrulesCommand","01w");   EnvDefineFunction2(theEnv,"list-defrules",'v', PTIEF ListDefrulesCommand,"ListDefrulesCommand","01w");   EnvDefineFunction2(theEnv,"ppdefrule",'v',PTIEF PPDefruleCommand,"PPDefruleCommand","11w");#endif#if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)   DefruleBinarySetup(theEnv);#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)   DefruleCompilerSetup(theEnv);#endif#endif  }/*****************************************************//* ResetDefrules: Defrule reset routine for use with *//*   the reset command. Sets the current entity time *//*   tag (used by the conflict resolution strategies *//*   for recency) to zero. The focus stack is also   *//*   cleared.                                        *//*****************************************************/static void ResetDefrules(  void *theEnv)  {   struct defmodule *theModule;   struct joinLink *theLink;   struct partialMatch *notParent;     DefruleData(theEnv)->CurrentEntityTimeTag = 1L;   EnvClearFocusStack(theEnv);   theModule = (struct defmodule *) EnvFindDefmodule(theEnv,"MAIN");   EnvFocus(theEnv,(void *) theModule);      for (theLink = DefruleData(theEnv)->RightPrimeJoins;        theLink != NULL;        theLink = theLink->next)     { PosEntryRetractAlpha(theEnv,theLink->join->rightMemory->beta[0]); }   for (theLink = DefruleData(theEnv)->LeftPrimeJoins;        theLink != NULL;        theLink = theLink->next)     {       if ((theLink->join->patternIsNegated || theLink->join->joinFromTheRight) &&           (! theLink->join->patternIsExists))        {         notParent = theLink->join->leftMemory->beta[0];                  if (notParent->marker)           { RemoveBlockedLink(notParent); }                    /*==========================================================*/         /* Prevent any retractions from generating partial matches. */         /*==========================================================*/                    notParent->marker = notParent;                  if (notParent->children != NULL)           { PosEntryRetractBeta(theEnv,notParent,notParent->children); }                    if (notParent->dependents != NULL)            { RemoveLogicalSupport(theEnv,notParent); }        }     }  }/*****************************************************//* ResetDefrulesPrime:                      *//*****************************************************/static void ResetDefrulesPrime(  void *theEnv)  {   struct joinLink *theLink;   struct partialMatch *notParent;         for (theLink = DefruleData(theEnv)->RightPrimeJoins;        theLink != NULL;        theLink = theLink->next)     { NetworkAssert(theEnv,theLink->join->rightMemory->beta[0],theLink->join); }   for (theLink = DefruleData(theEnv)->LeftPrimeJoins;        theLink != NULL;        theLink = theLink->next)     {       if ((theLink->join->patternIsNegated || theLink->join->joinFromTheRight) &&           (! theLink->join->patternIsExists))        {         notParent = theLink->join->leftMemory->beta[0];         if (theLink->join->secondaryNetworkTest != NULL)           {            if (EvaluateSecondaryNetworkTest(theEnv,notParent,theLink->join) == FALSE)              { continue; }           }         notParent->marker = NULL;         EPMDrive(theEnv,notParent,theLink->join);        }     }  }#if (! RUN_TIME)/******************************************************************//* ClearDefrulesReady: Indicates whether defrules can be cleared. *//******************************************************************/static int ClearDefrulesReady(  void *theEnv)  {   if (EngineData(theEnv)->ExecutingRule != NULL) return(FALSE);      EnvClearFocusStack(theEnv);   if (EnvGetCurrentModule(theEnv) == NULL) return(FALSE);   DefruleData(theEnv)->CurrentEntityTimeTag = 1L;   return(TRUE);  }/***************************************************************//* ClearDefrules: Pushes the MAIN module as the current focus. *//***************************************************************/static void ClearDefrules(  void *theEnv)  {   struct defmodule *theModule;   theModule = (struct defmodule *) EnvFindDefmodule(theEnv,"MAIN");   EnvFocus(theEnv,(void *) theModule);  }#endif/**************************************//* SaveDefrules: Defrule save routine *//*   for use with the save command.   *//**************************************/static void SaveDefrules(  void *theEnv,  void *theModule,  char *logicalName)  {   SaveConstruct(theEnv,theModule,logicalName,DefruleData(theEnv)->DefruleConstruct);   }

⌨️ 快捷键说明

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