00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #define _DFFCTPSR_SOURCE_
00023
00024 #include "setup.h"
00025
00026 #if DEFFACTS_CONSTRUCT
00027
00028 #include "envrnmnt.h"
00029 #include "memalloc.h"
00030 #include "router.h"
00031 #include "cstrcpsr.h"
00032 #include "factrhs.h"
00033 #if BLOAD || BLOAD_AND_BSAVE
00034 #include "bload.h"
00035 #endif
00036 #include "dffctdef.h"
00037 #include "dffctbsc.h"
00038
00039 #include "dffctpsr.h"
00040
00041
00042
00043
00044
00045
00046
00047 globle int ParseDeffacts(
00048 void *theEnv,
00049 char *readSource)
00050 {
00051 #if (MAC_MCW || WIN_MCW) && (RUN_TIME || BLOAD_ONLY)
00052 #pragma unused(theEnv,readSource)
00053 #endif
00054
00055 #if (! RUN_TIME) && (! BLOAD_ONLY)
00056 SYMBOL_HN *deffactsName;
00057 struct expr *temp;
00058 struct deffacts *newDeffacts;
00059 int deffactsError;
00060 struct token inputToken;
00061
00062
00063
00064
00065
00066 deffactsError = FALSE;
00067 SetPPBufferStatus(theEnv,ON);
00068
00069 FlushPPBuffer(theEnv);
00070 SetIndentDepth(theEnv,3);
00071 SavePPBuffer(theEnv,"(deffacts ");
00072
00073
00074
00075
00076
00077 #if BLOAD || BLOAD_AND_BSAVE
00078 if ((Bloaded(theEnv) == TRUE) && (! ConstructData(theEnv)->CheckSyntaxMode))
00079 {
00080 CannotLoadWithBloadMessage(theEnv,"deffacts");
00081 return(TRUE);
00082 }
00083 #endif
00084
00085
00086
00087
00088
00089 deffactsName = GetConstructNameAndComment(theEnv,readSource,&inputToken,"deffacts",
00090 EnvFindDeffacts,EnvUndeffacts,"$",TRUE,
00091 TRUE,TRUE);
00092 if (deffactsName == NULL) { return(TRUE); }
00093
00094
00095
00096
00097
00098 temp = BuildRHSAssert(theEnv,readSource,&inputToken,&deffactsError,FALSE,FALSE,"deffacts");
00099
00100 if (deffactsError == TRUE) { return(TRUE); }
00101
00102 if (ExpressionContainsVariables(temp,FALSE))
00103 {
00104 LocalVariableErrorMessage(theEnv,"a deffacts construct");
00105 ReturnExpression(theEnv,temp);
00106 return(TRUE);
00107 }
00108
00109 SavePPBuffer(theEnv,"\n");
00110
00111
00112
00113
00114
00115
00116 if (ConstructData(theEnv)->CheckSyntaxMode)
00117 {
00118 ReturnExpression(theEnv,temp);
00119 return(FALSE);
00120 }
00121
00122
00123
00124
00125
00126 ExpressionInstall(theEnv,temp);
00127 newDeffacts = get_struct(theEnv,deffacts);
00128 newDeffacts->header.name = deffactsName;
00129 IncrementSymbolCount(deffactsName);
00130 newDeffacts->assertList = PackExpression(theEnv,temp);
00131 newDeffacts->header.whichModule = (struct defmoduleItemHeader *)
00132 GetModuleItem(theEnv,NULL,FindModuleItem(theEnv,"deffacts")->moduleIndex);
00133
00134 newDeffacts->header.next = NULL;
00135 newDeffacts->header.usrData = NULL;
00136 ReturnExpression(theEnv,temp);
00137
00138
00139
00140
00141
00142 if (EnvGetConserveMemory(theEnv) == TRUE)
00143 { newDeffacts->header.ppForm = NULL; }
00144 else
00145 { newDeffacts->header.ppForm = CopyPPBuffer(theEnv); }
00146
00147
00148
00149
00150
00151 AddConstructToModule(&newDeffacts->header);
00152
00153 #endif
00154
00155
00156
00157
00158
00159 return(FALSE);
00160 }
00161
00162 #endif
00163
00164