1 /*******************************************************/ 2 /* "C" Language Integrated Production System */ 3 /* */ 4 /* CLIPS Version 6.30 08/16/14 */ 5 /* */ 6 /* MATCH HEADER FILE */ 7 /*******************************************************/ 8 9 /*************************************************************/ 10 /* Purpose: */ 11 /* */ 12 /* Principal Programmer(s): */ 13 /* Gary D. Riley */ 14 /* */ 15 /* Contributing Programmer(s): */ 16 /* */ 17 /* Revision History: */ 18 /* */ 19 /* 6.30: Added support for hashed memories. */ 20 /* */ 21 /* Added additional members to partialMatch to */ 22 /* support changes to the matching algorithm. */ 23 /* */ 24 /*************************************************************/ 25 26 #ifndef _H_match 27 28 #define _H_match 29 30 struct genericMatch; 31 struct patternMatch; 32 struct partialMatch; 33 struct alphaMatch; 34 struct multifieldMarker; 35 36 #ifndef _H_evaluatn 37 #include "evaluatn.h" 38 #endif 39 #ifndef _H_network 40 #include "network.h" 41 #endif 42 #ifndef _H_pattern 43 #include "pattern.h" 44 #endif 45 46 /************************************************************/ 47 /* PATTERNMATCH STRUCTURE: */ 48 /************************************************************/ 49 struct patternMatch 50 { 51 struct patternMatch *next; 52 struct partialMatch *theMatch; 53 struct patternNodeHeader *matchingPattern; 54 }; 55 56 /**************************/ 57 /* genericMatch structure */ 58 /**************************/ 59 struct genericMatch 60 { 61 union 62 { 63 void *theValue; 64 struct alphaMatch *theMatch; 65 } gm; 66 }; 67 68 /************************************************************/ 69 /* PARTIALMATCH STRUCTURE: */ 70 /************************************************************/ 71 struct partialMatch 72 { 73 unsigned int betaMemory : 1; 74 unsigned int busy : 1; 75 unsigned int rhsMemory : 1; 76 unsigned short bcount; 77 unsigned long hashValue; 78 void *owner; 79 void *marker; 80 void *dependents; 81 struct partialMatch *nextInMemory; 82 struct partialMatch *prevInMemory; 83 struct partialMatch *children; 84 struct partialMatch *rightParent; 85 struct partialMatch *nextRightChild; 86 struct partialMatch *prevRightChild; 87 struct partialMatch *leftParent; 88 struct partialMatch *nextLeftChild; 89 struct partialMatch *prevLeftChild; 90 struct partialMatch *blockList; 91 struct partialMatch *nextBlocked; 92 struct partialMatch *prevBlocked; 93 struct genericMatch binds[1]; 94 }; 95 96 /************************************************************/ 97 /* ALPHAMATCH STRUCTURE: */ 98 /************************************************************/ 99 struct alphaMatch 100 { 101 struct patternEntity *matchingItem; 102 struct multifieldMarker *markers; 103 struct alphaMatch *next; 104 unsigned long bucket; 105 }; 106 107 /************************************************************/ 108 /* MULTIFIELDMARKER STRUCTURE: Used in the pattern matching */ 109 /* process to mark the range of fields that the $? and */ 110 /* $?variables match because a single pattern restriction */ 111 /* may span zero or more fields.. */ 112 /************************************************************/ 113 struct multifieldMarker 114 { 115 int whichField; 116 union 117 { 118 void *whichSlot; 119 short int whichSlotNumber; 120 } where; 121 long startPosition; 122 long endPosition; 123 struct multifieldMarker *next; 124 }; 125 126 #define get_nth_pm_value(thePM,thePos) (thePM->binds[thePos].gm.theValue) 127 #define get_nth_pm_match(thePM,thePos) (thePM->binds[thePos].gm.theMatch) 128 129 #define set_nth_pm_value(thePM,thePos,theVal) (thePM->binds[thePos].gm.theValue = (void *) theVal) 130 #define set_nth_pm_match(thePM,thePos,theVal) (thePM->binds[thePos].gm.theMatch = theVal) 131 132 #endif /* _H_match */ 133 134 135 136 137 138 139