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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*******************************************************/
/* "C" Language Integrated Production System */
/* */
/* CLIPS Version 6.40 07/30/16 */
/* */
/* FACT RETE FUNCTION GENERATION HEADER FILE */
/*******************************************************/
/*************************************************************/
/* Purpose: */
/* */
/* Principal Programmer(s): */
/* Gary D. Riley */
/* */
/* Contributing Programmer(s): */
/* */
/* Revision History: */
/* */
/* 6.30: Support for performance optimizations. */
/* */
/* Increased maximum values for pattern/slot */
/* indices. */
/* */
/* 6.40: Removed LOCALE definition. */
/* */
/* Pragma once and other inclusion changes. */
/* */
/* Added support for booleans with <stdbool.h>. */
/* */
/* Removed use of void pointers for specific */
/* data structures. */
/* */
/*************************************************************/
#ifndef _H_factgen
#pragma once
#define _H_factgen
#include "reorder.h"
/**********************************************************/
/* factGetVarPN1Call: This structure is used to store the */
/* arguments to the most general extraction routine for */
/* retrieving a variable from the fact pattern network. */
/**********************************************************/
struct factGetVarPN1Call
{
unsigned int factAddress : 1;
unsigned int allFields : 1;
unsigned short whichField;
unsigned short whichSlot;
};
/***********************************************************/
/* factGetVarPN2Call: This structure is used to store the */
/* arguments to the most specific extraction routine for */
/* retrieving a variable from the fact pattern network. */
/* It is used for retrieving the single value stored in */
/* a single field slot (the slot index can be used to */
/* directly to retrieve the value from the fact array). */
/***********************************************************/
struct factGetVarPN2Call
{
unsigned short whichSlot;
};
/**********************************************************/
/* factGetVarPN3Call: */
/**********************************************************/
struct factGetVarPN3Call
{
unsigned int fromBeginning : 1;
unsigned int fromEnd : 1;
unsigned short beginOffset;
unsigned short endOffset;
unsigned short whichSlot;
};
/**************************************************************/
/* factConstantPN1Call: Used for testing for a constant value */
/* in the fact pattern network. Compare the value of a */
/* single field slot to a constant. */
/**************************************************************/
struct factConstantPN1Call
{
unsigned int testForEquality : 1;
unsigned short whichSlot;
};
/******************************************************************/
/* factConstantPN2Call: Used for testing for a constant value in */
/* the fact pattern network. Compare the value of a multifield */
/* slot to a constant (where the value retrieved for comparison */
/* from the slot contains no multifields before or only one */
/* multifield before and none after). */
/******************************************************************/
struct factConstantPN2Call
{
unsigned int testForEquality : 1;
unsigned int fromBeginning : 1;
unsigned short offset;
unsigned short whichSlot;
};
/**********************************************************/
/* factGetVarJN1Call: This structure is used to store the */
/* arguments to the most general extraction routine for */
/* retrieving a fact variable from the join network. */
/**********************************************************/
struct factGetVarJN1Call
{
unsigned int factAddress : 1;
unsigned int allFields : 1;
unsigned int lhs : 1;
unsigned int rhs : 1;
unsigned short whichPattern;
unsigned short whichSlot;
unsigned short whichField;
};
/**********************************************************/
/* factGetVarJN2Call: */
/**********************************************************/
struct factGetVarJN2Call
{
unsigned int lhs : 1;
unsigned int rhs : 1;
unsigned short whichPattern;
unsigned short whichSlot;
};
/**********************************************************/
/* factGetVarJN3Call: */
/**********************************************************/
struct factGetVarJN3Call
{
unsigned int fromBeginning : 1;
unsigned int fromEnd : 1;
unsigned int lhs : 1;
unsigned int rhs : 1;
unsigned short beginOffset;
unsigned short endOffset;
unsigned short whichPattern;
unsigned short whichSlot;
};
/**********************************************************/
/* factCompVarsPN1Call: */
/**********************************************************/
struct factCompVarsPN1Call
{
unsigned int pass : 1;
unsigned int fail : 1;
unsigned short field1;
unsigned short field2;
};
/**********************************************************/
/* factCompVarsJN1Call: */
/**********************************************************/
struct factCompVarsJN1Call
{
unsigned int pass : 1;
unsigned int fail : 1;
unsigned int p1lhs: 1;
unsigned int p1rhs: 1;
unsigned int p2lhs: 1;
unsigned int p2rhs: 1;
unsigned short pattern1;
unsigned short pattern2;
unsigned short slot1;
unsigned short slot2;
};
/**********************************************************/
/* factCompVarsJN2Call: */
/**********************************************************/
struct factCompVarsJN2Call
{
unsigned int pass : 1;
unsigned int fail : 1;
unsigned int p1lhs: 1;
unsigned int p1rhs: 1;
unsigned int p2lhs: 1;
unsigned int p2rhs: 1;
unsigned int fromBeginning1 : 1;
unsigned int fromBeginning2 : 1;
unsigned short offset1;
unsigned short offset2;
unsigned short pattern1;
unsigned short pattern2;
unsigned short slot1;
unsigned short slot2;
};
/**********************************************************/
/* factCheckLengthPNCall: This structure is used to store */
/* the arguments to the routine for determining if the */
/* length of a multifield slot is equal or greater than */
/* a specified value. */
/**********************************************************/
struct factCheckLengthPNCall
{
unsigned int exactly : 1;
unsigned short minLength;
unsigned short whichSlot;
};
/****************************************/
/* GLOBAL EXTERNAL FUNCTION DEFINITIONS */
/****************************************/
void InitializeFactReteFunctions(Environment *);
struct expr *FactPNVariableComparison(Environment *,struct lhsParseNode *,
struct lhsParseNode *);
struct expr *FactJNVariableComparison(Environment *,struct lhsParseNode *,
struct lhsParseNode *,bool);
void FactReplaceGetvar(Environment *,struct expr *,struct lhsParseNode *,int);
void FactReplaceGetfield(Environment *,struct expr *,struct lhsParseNode *);
struct expr *FactGenPNConstant(Environment *,struct lhsParseNode *);
struct expr *FactGenGetfield(Environment *,struct lhsParseNode *);
struct expr *FactGenGetvar(Environment *,struct lhsParseNode *,int);
struct expr *FactGenCheckLength(Environment *,struct lhsParseNode *);
struct expr *FactGenCheckZeroLength(Environment *,unsigned short);
#endif /* _H_factgen */