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