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

📄 factgen.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 4 页
字号:
      ClearBitString(&hack,sizeof(struct factGetVarJN1Call));      /*========================================*/   /* A slot value of zero indicates that we */   /* want the pattern address returned.     */   /*========================================*/      if (theNode->slotNumber <= 0)     {      hack.factAddress = 1;      hack.allFields = 0;      hack.whichSlot = 0;      hack.whichField = 0;     }        /*=====================================================*/   /* A slot value greater than zero and a field value of */   /* zero indicate that we want the entire contents of   */   /* the slot whether it is a single field or multifield */   /* slot.                                               */   /*=====================================================*/      else if (theNode->index <= 0)     {      hack.factAddress = 0;      hack.allFields = 1;      hack.whichSlot = theNode->slotNumber - 1;      hack.whichField = 0;     }        /*=====================================================*/   /* A slot value, m, and a field value, n, both greater */   /* than zero indicate that we want the nth field of    */   /* the mth slot.                                       */   /*=====================================================*/      else     {      hack.factAddress = 0;      hack.allFields = 0;      hack.whichSlot = theNode->slotNumber - 1;      hack.whichField = theNode->index - 1;     }        /*=========================================*/   /* Store the position in the partial match */   /* from which the fact will be retrieved.  */   /*=========================================*/      hack.whichPattern = theNode->pattern - 1;   /*=============================*/   /* Return the argument bitmap. */   /*=============================*/      return(AddBitMap(&hack,sizeof(struct factGetVarJN1Call)));  }  /**************************************************************//* FactGetVarJN2: Creates the arguments for the routine which *//*   retrieves a variable's value from a single field slot of *//*   a fact. The retrieval relies on information stored in a  *//*   partial match, so this retrieval mechanism is used by    *//*   expressions in the join network or from the RHS of a     *//*   rule.                                                    */ /**************************************************************/static VOID *FactGetVarJN2(theNode)  struct lhsParseNode *theNode;  {   struct factGetVarJN2Call hack;      /*===================================================*/   /* Clear the bitmap for storing the argument values. */   /*===================================================*/   ClearBitString(&hack,sizeof(struct factGetVarJN2Call));      /*=====================================================*/   /* Store the position in the partial match from which  */   /* the fact will be retrieved and the slot in the fact */   /* from which the value will be retrieved.             */   /*=====================================================*/      hack.whichSlot = theNode->slotNumber - 1;   hack.whichPattern = theNode->pattern - 1;   /*=============================*/   /* Return the argument bitmap. */   /*=============================*/      return(AddBitMap(&hack,sizeof(struct factGetVarJN2Call)));  }  /*************************************************************//* FactGetVarJN3: Creates the arguments for the routine for  *//*   retrieving a variable's value from a multifield slot of *//*   a fact. For this routine, the variable's value must be  *//*   from a multifield slot that contains at most one        *//*   multifield variable or contains no multifield variables *//*   before the variable's value to be retrieved. The        *//*   retrieval relies on information stored in a partial     *//*   match, so this retrieval mechanism is used by           *//*   expressions in the join network or from the RHS of a    *//*   rule.                                                   */ /*************************************************************/static VOID *FactGetVarJN3(theNode)  struct lhsParseNode *theNode;  {   struct factGetVarJN3Call hack;   /*===================================================*/   /* Clear the bitmap for storing the argument values. */   /*===================================================*/        ClearBitString(&hack,sizeof(struct factGetVarJN3Call));      /*=====================================================*/   /* Store the position in the partial match from which  */   /* the fact will be retrieved and the slot in the fact */   /* from which the value will be retrieved.             */   /*=====================================================*/   hack.whichSlot = theNode->slotNumber - 1;   hack.whichPattern = theNode->pattern - 1;      /*==============================================================*/   /* If a single field variable value is being retrieved, then... */   /*==============================================================*/      if ((theNode->type == SF_WILDCARD) || (theNode->type == SF_VARIABLE))     {      /*=========================================================*/      /* If no multifield values occur before the variable, then */      /* the variable's value can be retrieved based on its      */      /* offset from the beginning of the slot's value           */      /* regardless of the number of multifield variables or     */      /* wildcards following the variable being retrieved.       */      /*=========================================================*/            if (theNode->multiFieldsBefore == 0)        {         hack.fromBeginning = 1;         hack.fromEnd = 0;         hack.beginOffset = theNode->singleFieldsBefore;         hack.endOffset = 0;        }              /*===============================================*/      /* Otherwise the variable is retrieved based its */      /* position relative to the end of the slot.     */      /*===============================================*/            else        {         hack.fromBeginning = 0;         hack.fromEnd = 1;         hack.beginOffset = 0;         hack.endOffset = theNode->singleFieldsAfter;        }          /*=============================*/      /* Return the argument bitmap. */      /*=============================*/      return(AddBitMap(&hack,sizeof(struct factGetVarJN3Call)));     }        /*============================================================*/   /* A multifield variable value is being retrieved. This means */   /* that there are no other multifield variables or wildcards  */   /* in the slot. The multifield value is retrieved by storing  */   /* the number of single field values which come before and    */   /* after the multifield value. The multifield value can then  */   /* be retrieved based on the length of the value in the slot  */   /* and the number of single field values which must occur     */   /* before and after the multifield value.                     */   /*============================================================*/      hack.fromBeginning = 1;   hack.fromEnd = 1;   hack.beginOffset = theNode->singleFieldsBefore;   hack.endOffset = theNode->singleFieldsAfter;        /*=============================*/   /* Return the argument bitmap. */   /*=============================*/      return(AddBitMap(&hack,sizeof(struct factGetVarJN3Call)));  }  /**************************************************************//* FactGetVarPN1: Creates the arguments for the most general  *//*   routine for retrieving a variable's value from the slot  *//*   of a fact. The retrieval relies on information stored    *//*   during fact pattern matching, so this retrieval          *//*   mechanism is only used by expressions in the pattern     *//*   network.                                                 *//**************************************************************/static VOID *FactGetVarPN1(theNode)  struct lhsParseNode *theNode;  {   struct factGetVarPN1Call hack;   /*===================================================*/   /* Clear the bitmap for storing the argument values. */   /*===================================================*/      ClearBitString(&hack,sizeof(struct factGetVarPN1Call));      /*========================================*/   /* A slot value of zero indicates that we */   /* want the pattern address returned.     */   /*========================================*/      if (theNode->slotNumber <= 0)     {      hack.factAddress = 1;      hack.allFields = 0;      hack.whichSlot = 0;      hack.whichField = 0;     }        /*=====================================================*/   /* A slot value greater than zero and a field value of */   /* zero indicate that we want the entire contents of   */   /* the slot whether it is a single field or multifield */   /* slot.                                               */   /*=====================================================*/      else if (theNode->index <= 0)     {      hack.factAddress = 0;      hack.allFields = 1;      hack.whichSlot = theNode->slotNumber - 1;      hack.whichField = 0;     }        /*=============================================*/   /* A slot value, m, and a field value, n, both */   /* greater than zero indicate that we want the */   /* nth field of the mth slot.                  */   /*=============================================*/      else     {      hack.factAddress = 0;      hack.allFields = 0;      hack.whichSlot = theNode->slotNumber - 1;      hack.whichField = theNode->index - 1;     }        /*=============================*/   /* Return the argument bitmap. */   /*=============================*/      return(AddBitMap(&hack,sizeof(struct factGetVarPN1Call)));  }/***************************************************************//* FactGetVarPN2: Creates the arguments for the routine which  *//*   retrieves a variable's value from a single field slot of  *//*   a fact. The retrieval relies on information stored during *//*   fact pattern matching, so this retrieval mechanism is     *//*   only used by expressions in the pattern network.          *//***************************************************************/static VOID *FactGetVarPN2(theNode)  struct lhsParseNode *theNode;  {   struct factGetVarPN2Call hack;      /*===================================================*/   /* Clear the bitmap for storing the argument values. */   /*===================================================*/   ClearBitString(&hack,sizeof(struct factGetVarPN2Call));      /*=======================================*/   /* Store the slot in the fact from which */   /* the value will be retrieved.          */   /*=======================================*/

⌨️ 快捷键说明

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