00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _H_pattern
00030
00031 #define _H_pattern
00032
00033 #ifndef _STDIO_INCLUDED_
00034 #include <stdio.h>
00035 #define _STDIO_INCLUDED_
00036 #endif
00037
00038 #ifndef _H_evaluatn
00039 #include "evaluatn.h"
00040 #endif
00041
00042 struct patternEntityRecord
00043 {
00044 struct entityRecord base;
00045 void (*decrementBasisCount)(void *,void *);
00046 void (*incrementBasisCount)(void *,void *);
00047 void (*matchFunction)(void *,void *);
00048 intBool (*synchronized)(void *,void *);
00049 };
00050
00051 typedef struct patternEntityRecord PTRN_ENTITY_RECORD;
00052 typedef struct patternEntityRecord *PTRN_ENTITY_RECORD_PTR;
00053
00054 struct patternEntity
00055 {
00056 struct patternEntityRecord *theInfo;
00057 void *dependents;
00058 unsigned busyCount;
00059 unsigned long long timeTag;
00060 };
00061
00062 typedef struct patternEntity PATTERN_ENTITY;
00063 typedef struct patternEntity * PATTERN_ENTITY_PTR;
00064
00065 struct patternParser;
00066
00067 #ifndef _H_symbol
00068 #include "symbol.h"
00069 #endif
00070 #ifndef _H_scanner
00071 #include "scanner.h"
00072 #endif
00073 #ifndef _H_expressn
00074 #include "expressn.h"
00075 #endif
00076 #ifndef _H_match
00077 #include "match.h"
00078 #endif
00079 #ifndef _H_reorder
00080 #include "reorder.h"
00081 #endif
00082 #ifndef _H_constrnt
00083 #include "constrnt.h"
00084 #endif
00085
00086 #define MAXIMUM_NUMBER_OF_PATTERNS 128
00087
00088 struct patternParser
00089 {
00090 char *name;
00091 struct patternEntityRecord *entityType;
00092 int positionInArray;
00093 int (*recognizeFunction)(SYMBOL_HN *);
00094 struct lhsParseNode *(*parseFunction)(void *,char *,struct token *);
00095 int (*postAnalysisFunction)(void *,struct lhsParseNode *);
00096 struct patternNodeHeader *(*addPatternFunction)(void *,struct lhsParseNode *);
00097 void (*removePatternFunction)(void *,struct patternNodeHeader *);
00098 struct expr *(*genJNConstantFunction)(void *,struct lhsParseNode *,int);
00099 void (*replaceGetJNValueFunction)(void *,struct expr *,struct lhsParseNode *,int);
00100 struct expr *(*genGetJNValueFunction)(void *,struct lhsParseNode *,int);
00101 struct expr *(*genCompareJNValuesFunction)(void *,struct lhsParseNode *,struct lhsParseNode *,int);
00102 struct expr *(*genPNConstantFunction)(void *,struct lhsParseNode *);
00103 void (*replaceGetPNValueFunction)(void *,struct expr *,struct lhsParseNode *);
00104 struct expr *(*genGetPNValueFunction)(void *,struct lhsParseNode *);
00105 struct expr *(*genComparePNValuesFunction)(void *,struct lhsParseNode *,struct lhsParseNode *);
00106 void (*returnUserDataFunction)(void *,void *);
00107 void *(*copyUserDataFunction)(void *,void *);
00108 void (*markIRPatternFunction)(void *,struct patternNodeHeader *,int);
00109 void (*incrementalResetFunction)(void *);
00110 struct lhsParseNode *(*initialPatternFunction)(void *);
00111 void (*codeReferenceFunction)(void *,void *,FILE *,int,int);
00112 int priority;
00113 struct patternParser *next;
00114 };
00115
00116 struct reservedSymbol
00117 {
00118 char *theSymbol;
00119 char *reservedBy;
00120 struct reservedSymbol *next;
00121 };
00122
00123 #define MAX_POSITIONS 8
00124
00125 #define PATTERN_DATA 19
00126
00127 struct patternData
00128 {
00129 struct patternParser *ListOfPatternParsers;
00130 struct patternParser *PatternParserArray[MAX_POSITIONS];
00131 int NextPosition;
00132 struct reservedSymbol *ListOfReservedPatternSymbols;
00133 int WithinNotCE;
00134 int GlobalSalience;
00135 int GlobalAutoFocus;
00136 struct expr *SalienceExpression;
00137 struct patternNodeHashEntry **PatternHashTable;
00138 unsigned long PatternHashTableSize;
00139 };
00140
00141 #define PatternData(theEnv) ((struct patternData *) GetEnvironmentData(theEnv,PATTERN_DATA))
00142
00143 #ifdef LOCALE
00144 #undef LOCALE
00145 #endif
00146
00147 #ifdef _PATTERN_SOURCE_
00148 #define LOCALE
00149 #else
00150 #define LOCALE extern
00151 #endif
00152
00153 LOCALE void InitializePatterns(void *);
00154 LOCALE int AddPatternParser(void *,struct patternParser *);
00155 LOCALE struct patternParser *FindPatternParser(void *,char *);
00156 LOCALE void DetachPattern(void *,int,struct patternNodeHeader *);
00157 LOCALE void GetNextPatternEntity(void *,
00158 struct patternParser **,
00159 struct patternEntity **);
00160 LOCALE struct patternParser *GetPatternParser(void *,int);
00161 LOCALE struct lhsParseNode *RestrictionParse(void *,char *,struct token *,int,
00162 struct symbolHashNode *,short,
00163 struct constraintRecord *,short);
00164 LOCALE int PostPatternAnalysis(void *,struct lhsParseNode *);
00165 LOCALE void PatternNodeHeaderToCode(void *,FILE *,struct patternNodeHeader *,int,int);
00166 LOCALE void AddReservedPatternSymbol(void *,char *,char *);
00167 LOCALE intBool ReservedPatternSymbol(void *,char *,char *);
00168 LOCALE void ReservedPatternSymbolErrorMsg(void *,char *,char *);
00169 LOCALE void AddHashedPatternNode(void *,void *,void *,unsigned short,void *);
00170 LOCALE intBool RemoveHashedPatternNode(void *,void *,void *,unsigned short,void *);
00171 LOCALE void *FindHashedPatternNode(void *,void *,unsigned short,void *);
00172
00173 #endif
00174
00175
00176
00177
00178
00179
00180
00181
00182