clipsruby 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/clipsruby/agenda.c +1373 -0
- data/ext/clipsruby/agenda.h +169 -0
- data/ext/clipsruby/analysis.c +1142 -0
- data/ext/clipsruby/analysis.h +61 -0
- data/ext/clipsruby/argacces.c +526 -0
- data/ext/clipsruby/argacces.h +77 -0
- data/ext/clipsruby/bload.c +884 -0
- data/ext/clipsruby/bload.h +94 -0
- data/ext/clipsruby/bmathfun.c +557 -0
- data/ext/clipsruby/bmathfun.h +66 -0
- data/ext/clipsruby/bsave.c +634 -0
- data/ext/clipsruby/bsave.h +130 -0
- data/ext/clipsruby/classcom.c +976 -0
- data/ext/clipsruby/classcom.h +115 -0
- data/ext/clipsruby/classexm.c +1376 -0
- data/ext/clipsruby/classexm.h +97 -0
- data/ext/clipsruby/classfun.c +1392 -0
- data/ext/clipsruby/classfun.h +164 -0
- data/ext/clipsruby/classinf.c +1245 -0
- data/ext/clipsruby/classinf.h +94 -0
- data/ext/clipsruby/classini.c +843 -0
- data/ext/clipsruby/classini.h +75 -0
- data/ext/clipsruby/classpsr.c +957 -0
- data/ext/clipsruby/classpsr.h +73 -0
- data/ext/clipsruby/clips.h +133 -0
- data/ext/clipsruby/clipsruby.c +619 -0
- data/ext/clipsruby/clsltpsr.c +931 -0
- data/ext/clipsruby/clsltpsr.h +72 -0
- data/ext/clipsruby/commline.c +1217 -0
- data/ext/clipsruby/commline.h +131 -0
- data/ext/clipsruby/conscomp.c +1593 -0
- data/ext/clipsruby/conscomp.h +150 -0
- data/ext/clipsruby/constant.h +264 -0
- data/ext/clipsruby/constrct.c +1090 -0
- data/ext/clipsruby/constrct.h +216 -0
- data/ext/clipsruby/constrnt.c +554 -0
- data/ext/clipsruby/constrnt.h +132 -0
- data/ext/clipsruby/crstrtgy.c +1088 -0
- data/ext/clipsruby/crstrtgy.h +85 -0
- data/ext/clipsruby/cstrcbin.c +185 -0
- data/ext/clipsruby/cstrcbin.h +61 -0
- data/ext/clipsruby/cstrccmp.h +43 -0
- data/ext/clipsruby/cstrccom.c +1791 -0
- data/ext/clipsruby/cstrccom.h +115 -0
- data/ext/clipsruby/cstrcpsr.c +835 -0
- data/ext/clipsruby/cstrcpsr.h +97 -0
- data/ext/clipsruby/cstrnbin.c +282 -0
- data/ext/clipsruby/cstrnbin.h +55 -0
- data/ext/clipsruby/cstrnchk.c +826 -0
- data/ext/clipsruby/cstrnchk.h +91 -0
- data/ext/clipsruby/cstrncmp.c +238 -0
- data/ext/clipsruby/cstrncmp.h +57 -0
- data/ext/clipsruby/cstrnops.c +1176 -0
- data/ext/clipsruby/cstrnops.h +47 -0
- data/ext/clipsruby/cstrnpsr.c +1394 -0
- data/ext/clipsruby/cstrnpsr.h +88 -0
- data/ext/clipsruby/cstrnutl.c +564 -0
- data/ext/clipsruby/cstrnutl.h +54 -0
- data/ext/clipsruby/default.c +454 -0
- data/ext/clipsruby/default.h +57 -0
- data/ext/clipsruby/defins.c +971 -0
- data/ext/clipsruby/defins.h +127 -0
- data/ext/clipsruby/developr.c +677 -0
- data/ext/clipsruby/developr.h +69 -0
- data/ext/clipsruby/dffctbin.c +477 -0
- data/ext/clipsruby/dffctbin.h +76 -0
- data/ext/clipsruby/dffctbsc.c +308 -0
- data/ext/clipsruby/dffctbsc.h +72 -0
- data/ext/clipsruby/dffctcmp.c +297 -0
- data/ext/clipsruby/dffctcmp.h +44 -0
- data/ext/clipsruby/dffctdef.c +364 -0
- data/ext/clipsruby/dffctdef.h +104 -0
- data/ext/clipsruby/dffctpsr.c +179 -0
- data/ext/clipsruby/dffctpsr.h +49 -0
- data/ext/clipsruby/dffnxbin.c +520 -0
- data/ext/clipsruby/dffnxbin.h +67 -0
- data/ext/clipsruby/dffnxcmp.c +378 -0
- data/ext/clipsruby/dffnxcmp.h +54 -0
- data/ext/clipsruby/dffnxexe.c +241 -0
- data/ext/clipsruby/dffnxexe.h +58 -0
- data/ext/clipsruby/dffnxfun.c +1192 -0
- data/ext/clipsruby/dffnxfun.h +155 -0
- data/ext/clipsruby/dffnxpsr.c +514 -0
- data/ext/clipsruby/dffnxpsr.h +57 -0
- data/ext/clipsruby/dfinsbin.c +509 -0
- data/ext/clipsruby/dfinsbin.h +66 -0
- data/ext/clipsruby/dfinscmp.c +345 -0
- data/ext/clipsruby/dfinscmp.h +48 -0
- data/ext/clipsruby/drive.c +1191 -0
- data/ext/clipsruby/drive.h +65 -0
- data/ext/clipsruby/emathfun.c +1213 -0
- data/ext/clipsruby/emathfun.h +99 -0
- data/ext/clipsruby/engine.c +1568 -0
- data/ext/clipsruby/engine.h +203 -0
- data/ext/clipsruby/entities.h +276 -0
- data/ext/clipsruby/envrnbld.c +514 -0
- data/ext/clipsruby/envrnbld.h +40 -0
- data/ext/clipsruby/envrnmnt.c +257 -0
- data/ext/clipsruby/envrnmnt.h +112 -0
- data/ext/clipsruby/evaluatn.c +1736 -0
- data/ext/clipsruby/evaluatn.h +211 -0
- data/ext/clipsruby/expressn.c +494 -0
- data/ext/clipsruby/expressn.h +154 -0
- data/ext/clipsruby/exprnbin.c +538 -0
- data/ext/clipsruby/exprnbin.h +60 -0
- data/ext/clipsruby/exprnops.c +564 -0
- data/ext/clipsruby/exprnops.h +67 -0
- data/ext/clipsruby/exprnpsr.c +1112 -0
- data/ext/clipsruby/exprnpsr.h +98 -0
- data/ext/clipsruby/extconf.rb +2 -0
- data/ext/clipsruby/extnfunc.c +1015 -0
- data/ext/clipsruby/extnfunc.h +157 -0
- data/ext/clipsruby/factbin.c +447 -0
- data/ext/clipsruby/factbin.h +56 -0
- data/ext/clipsruby/factbld.c +1035 -0
- data/ext/clipsruby/factbld.h +63 -0
- data/ext/clipsruby/factcmp.c +386 -0
- data/ext/clipsruby/factcmp.h +46 -0
- data/ext/clipsruby/factcom.c +759 -0
- data/ext/clipsruby/factcom.h +80 -0
- data/ext/clipsruby/factfile.c +1761 -0
- data/ext/clipsruby/factfile.h +54 -0
- data/ext/clipsruby/factfun.c +682 -0
- data/ext/clipsruby/factfun.h +77 -0
- data/ext/clipsruby/factgen.c +1305 -0
- data/ext/clipsruby/factgen.h +229 -0
- data/ext/clipsruby/facthsh.c +438 -0
- data/ext/clipsruby/facthsh.h +81 -0
- data/ext/clipsruby/factlhs.c +250 -0
- data/ext/clipsruby/factlhs.h +54 -0
- data/ext/clipsruby/factmch.c +905 -0
- data/ext/clipsruby/factmch.h +68 -0
- data/ext/clipsruby/factmngr.c +3373 -0
- data/ext/clipsruby/factmngr.h +325 -0
- data/ext/clipsruby/factprt.c +498 -0
- data/ext/clipsruby/factprt.h +60 -0
- data/ext/clipsruby/factqpsr.c +796 -0
- data/ext/clipsruby/factqpsr.h +61 -0
- data/ext/clipsruby/factqury.c +1267 -0
- data/ext/clipsruby/factqury.h +112 -0
- data/ext/clipsruby/factrete.c +978 -0
- data/ext/clipsruby/factrete.h +70 -0
- data/ext/clipsruby/factrhs.c +667 -0
- data/ext/clipsruby/factrhs.h +55 -0
- data/ext/clipsruby/filecom.c +353 -0
- data/ext/clipsruby/filecom.h +137 -0
- data/ext/clipsruby/filertr.c +481 -0
- data/ext/clipsruby/filertr.h +94 -0
- data/ext/clipsruby/fileutil.c +1020 -0
- data/ext/clipsruby/fileutil.h +50 -0
- data/ext/clipsruby/generate.c +1079 -0
- data/ext/clipsruby/generate.h +57 -0
- data/ext/clipsruby/genrcbin.c +902 -0
- data/ext/clipsruby/genrcbin.h +69 -0
- data/ext/clipsruby/genrccmp.c +640 -0
- data/ext/clipsruby/genrccmp.h +59 -0
- data/ext/clipsruby/genrccom.c +2017 -0
- data/ext/clipsruby/genrccom.h +119 -0
- data/ext/clipsruby/genrcexe.c +737 -0
- data/ext/clipsruby/genrcexe.h +73 -0
- data/ext/clipsruby/genrcfun.c +890 -0
- data/ext/clipsruby/genrcfun.h +185 -0
- data/ext/clipsruby/genrcpsr.c +1618 -0
- data/ext/clipsruby/genrcpsr.h +80 -0
- data/ext/clipsruby/globlbin.c +458 -0
- data/ext/clipsruby/globlbin.h +71 -0
- data/ext/clipsruby/globlbsc.c +361 -0
- data/ext/clipsruby/globlbsc.h +83 -0
- data/ext/clipsruby/globlcmp.c +330 -0
- data/ext/clipsruby/globlcmp.h +52 -0
- data/ext/clipsruby/globlcom.c +289 -0
- data/ext/clipsruby/globlcom.h +63 -0
- data/ext/clipsruby/globldef.c +1087 -0
- data/ext/clipsruby/globldef.h +151 -0
- data/ext/clipsruby/globlpsr.c +530 -0
- data/ext/clipsruby/globlpsr.h +59 -0
- data/ext/clipsruby/immthpsr.c +431 -0
- data/ext/clipsruby/immthpsr.h +55 -0
- data/ext/clipsruby/incrrset.c +530 -0
- data/ext/clipsruby/incrrset.h +73 -0
- data/ext/clipsruby/inherpsr.c +850 -0
- data/ext/clipsruby/inherpsr.h +52 -0
- data/ext/clipsruby/inscom.c +2076 -0
- data/ext/clipsruby/inscom.h +182 -0
- data/ext/clipsruby/insfile.c +1764 -0
- data/ext/clipsruby/insfile.h +96 -0
- data/ext/clipsruby/insfun.c +1451 -0
- data/ext/clipsruby/insfun.h +134 -0
- data/ext/clipsruby/insmngr.c +2550 -0
- data/ext/clipsruby/insmngr.h +125 -0
- data/ext/clipsruby/insmoddp.c +1041 -0
- data/ext/clipsruby/insmoddp.h +91 -0
- data/ext/clipsruby/insmult.c +804 -0
- data/ext/clipsruby/insmult.h +62 -0
- data/ext/clipsruby/inspsr.c +602 -0
- data/ext/clipsruby/inspsr.h +60 -0
- data/ext/clipsruby/insquery.c +1278 -0
- data/ext/clipsruby/insquery.h +115 -0
- data/ext/clipsruby/insqypsr.c +729 -0
- data/ext/clipsruby/insqypsr.h +63 -0
- data/ext/clipsruby/iofun.c +2045 -0
- data/ext/clipsruby/iofun.h +116 -0
- data/ext/clipsruby/lgcldpnd.c +644 -0
- data/ext/clipsruby/lgcldpnd.h +75 -0
- data/ext/clipsruby/main.c +112 -0
- data/ext/clipsruby/match.h +142 -0
- data/ext/clipsruby/memalloc.c +481 -0
- data/ext/clipsruby/memalloc.h +197 -0
- data/ext/clipsruby/miscfun.c +1801 -0
- data/ext/clipsruby/miscfun.h +132 -0
- data/ext/clipsruby/modulbin.c +607 -0
- data/ext/clipsruby/modulbin.h +84 -0
- data/ext/clipsruby/modulbsc.c +347 -0
- data/ext/clipsruby/modulbsc.h +67 -0
- data/ext/clipsruby/modulcmp.c +499 -0
- data/ext/clipsruby/modulcmp.h +54 -0
- data/ext/clipsruby/moduldef.c +817 -0
- data/ext/clipsruby/moduldef.h +271 -0
- data/ext/clipsruby/modulpsr.c +1150 -0
- data/ext/clipsruby/modulpsr.h +69 -0
- data/ext/clipsruby/modulutl.c +1036 -0
- data/ext/clipsruby/modulutl.h +84 -0
- data/ext/clipsruby/msgcom.c +1221 -0
- data/ext/clipsruby/msgcom.h +125 -0
- data/ext/clipsruby/msgfun.c +1076 -0
- data/ext/clipsruby/msgfun.h +118 -0
- data/ext/clipsruby/msgpass.c +1441 -0
- data/ext/clipsruby/msgpass.h +103 -0
- data/ext/clipsruby/msgpsr.c +698 -0
- data/ext/clipsruby/msgpsr.h +73 -0
- data/ext/clipsruby/multifld.c +1404 -0
- data/ext/clipsruby/multifld.h +130 -0
- data/ext/clipsruby/multifun.c +2182 -0
- data/ext/clipsruby/multifun.h +102 -0
- data/ext/clipsruby/network.h +142 -0
- data/ext/clipsruby/objbin.c +1522 -0
- data/ext/clipsruby/objbin.h +79 -0
- data/ext/clipsruby/objcmp.c +1507 -0
- data/ext/clipsruby/objcmp.h +71 -0
- data/ext/clipsruby/object.h +260 -0
- data/ext/clipsruby/objrtbin.c +701 -0
- data/ext/clipsruby/objrtbin.h +79 -0
- data/ext/clipsruby/objrtbld.c +2393 -0
- data/ext/clipsruby/objrtbld.h +66 -0
- data/ext/clipsruby/objrtcmp.c +734 -0
- data/ext/clipsruby/objrtcmp.h +66 -0
- data/ext/clipsruby/objrtfnx.c +1330 -0
- data/ext/clipsruby/objrtfnx.h +222 -0
- data/ext/clipsruby/objrtgen.c +736 -0
- data/ext/clipsruby/objrtgen.h +63 -0
- data/ext/clipsruby/objrtmch.c +1524 -0
- data/ext/clipsruby/objrtmch.h +160 -0
- data/ext/clipsruby/parsefun.c +415 -0
- data/ext/clipsruby/parsefun.h +67 -0
- data/ext/clipsruby/pattern.c +1265 -0
- data/ext/clipsruby/pattern.h +163 -0
- data/ext/clipsruby/pprint.c +328 -0
- data/ext/clipsruby/pprint.h +79 -0
- data/ext/clipsruby/prccode.c +1478 -0
- data/ext/clipsruby/prccode.h +145 -0
- data/ext/clipsruby/prcdrfun.c +640 -0
- data/ext/clipsruby/prcdrfun.h +95 -0
- data/ext/clipsruby/prcdrpsr.c +1068 -0
- data/ext/clipsruby/prcdrpsr.h +79 -0
- data/ext/clipsruby/prdctfun.c +869 -0
- data/ext/clipsruby/prdctfun.h +77 -0
- data/ext/clipsruby/prntutil.c +878 -0
- data/ext/clipsruby/prntutil.h +125 -0
- data/ext/clipsruby/proflfun.c +827 -0
- data/ext/clipsruby/proflfun.h +118 -0
- data/ext/clipsruby/reorder.c +2082 -0
- data/ext/clipsruby/reorder.h +172 -0
- data/ext/clipsruby/reteutil.c +1732 -0
- data/ext/clipsruby/reteutil.h +111 -0
- data/ext/clipsruby/retract.c +710 -0
- data/ext/clipsruby/retract.h +74 -0
- data/ext/clipsruby/router.c +737 -0
- data/ext/clipsruby/router.h +147 -0
- data/ext/clipsruby/rulebin.c +1136 -0
- data/ext/clipsruby/rulebin.h +153 -0
- data/ext/clipsruby/rulebld.c +1328 -0
- data/ext/clipsruby/rulebld.h +62 -0
- data/ext/clipsruby/rulebsc.c +517 -0
- data/ext/clipsruby/rulebsc.h +91 -0
- data/ext/clipsruby/rulecmp.c +733 -0
- data/ext/clipsruby/rulecmp.h +63 -0
- data/ext/clipsruby/rulecom.c +1583 -0
- data/ext/clipsruby/rulecom.h +116 -0
- data/ext/clipsruby/rulecstr.c +892 -0
- data/ext/clipsruby/rulecstr.h +53 -0
- data/ext/clipsruby/ruledef.c +559 -0
- data/ext/clipsruby/ruledef.h +179 -0
- data/ext/clipsruby/ruledlt.c +599 -0
- data/ext/clipsruby/ruledlt.h +58 -0
- data/ext/clipsruby/rulelhs.c +1216 -0
- data/ext/clipsruby/rulelhs.h +52 -0
- data/ext/clipsruby/rulepsr.c +1073 -0
- data/ext/clipsruby/rulepsr.h +61 -0
- data/ext/clipsruby/scanner.c +856 -0
- data/ext/clipsruby/scanner.h +112 -0
- data/ext/clipsruby/setup.h +488 -0
- data/ext/clipsruby/sortfun.c +433 -0
- data/ext/clipsruby/sortfun.h +55 -0
- data/ext/clipsruby/strngfun.c +1173 -0
- data/ext/clipsruby/strngfun.h +96 -0
- data/ext/clipsruby/strngrtr.c +523 -0
- data/ext/clipsruby/strngrtr.h +97 -0
- data/ext/clipsruby/symblbin.c +648 -0
- data/ext/clipsruby/symblbin.h +64 -0
- data/ext/clipsruby/symblcmp.c +893 -0
- data/ext/clipsruby/symblcmp.h +61 -0
- data/ext/clipsruby/symbol.c +1961 -0
- data/ext/clipsruby/symbol.h +243 -0
- data/ext/clipsruby/sysdep.c +894 -0
- data/ext/clipsruby/sysdep.h +164 -0
- data/ext/clipsruby/textpro.c +1388 -0
- data/ext/clipsruby/textpro.h +77 -0
- data/ext/clipsruby/tmpltbin.c +609 -0
- data/ext/clipsruby/tmpltbin.h +108 -0
- data/ext/clipsruby/tmpltbsc.c +327 -0
- data/ext/clipsruby/tmpltbsc.h +87 -0
- data/ext/clipsruby/tmpltcmp.c +450 -0
- data/ext/clipsruby/tmpltcmp.h +57 -0
- data/ext/clipsruby/tmpltdef.c +584 -0
- data/ext/clipsruby/tmpltdef.h +155 -0
- data/ext/clipsruby/tmpltfun.c +2477 -0
- data/ext/clipsruby/tmpltfun.h +122 -0
- data/ext/clipsruby/tmpltlhs.c +379 -0
- data/ext/clipsruby/tmpltlhs.h +50 -0
- data/ext/clipsruby/tmpltpsr.c +819 -0
- data/ext/clipsruby/tmpltpsr.h +59 -0
- data/ext/clipsruby/tmpltrhs.c +595 -0
- data/ext/clipsruby/tmpltrhs.h +55 -0
- data/ext/clipsruby/tmpltutl.c +637 -0
- data/ext/clipsruby/tmpltutl.h +82 -0
- data/ext/clipsruby/userdata.c +156 -0
- data/ext/clipsruby/userdata.h +72 -0
- data/ext/clipsruby/userfunctions.c +70 -0
- data/ext/clipsruby/usrsetup.h +7 -0
- data/ext/clipsruby/utility.c +1594 -0
- data/ext/clipsruby/utility.h +250 -0
- data/ext/clipsruby/watch.c +865 -0
- data/ext/clipsruby/watch.h +124 -0
- data/lib/clipsruby.rb +1 -0
- metadata +388 -0
@@ -0,0 +1,759 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.41 12/04/22 */
|
5
|
+
/* */
|
6
|
+
/* FACT COMMANDS MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Provides the facts, assert, retract, save-facts, */
|
11
|
+
/* load-facts, set-fact-duplication, get-fact-duplication, */
|
12
|
+
/* assert-string, and fact-index commands and functions. */
|
13
|
+
/* */
|
14
|
+
/* Principal Programmer(s): */
|
15
|
+
/* Gary D. Riley */
|
16
|
+
/* */
|
17
|
+
/* Contributing Programmer(s): */
|
18
|
+
/* Brian L. Dantes */
|
19
|
+
/* */
|
20
|
+
/* Revision History: */
|
21
|
+
/* */
|
22
|
+
/* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */
|
23
|
+
/* */
|
24
|
+
/* 6.24: Added environment parameter to GenClose. */
|
25
|
+
/* Added environment parameter to GenOpen. */
|
26
|
+
/* */
|
27
|
+
/* Renamed BOOLEAN macro type to intBool. */
|
28
|
+
/* */
|
29
|
+
/* 6.30: Support for long long integers. */
|
30
|
+
/* */
|
31
|
+
/* Removed conditional code for unsupported */
|
32
|
+
/* compilers/operating systems (IBM_MCW and */
|
33
|
+
/* MAC_MCW). */
|
34
|
+
/* */
|
35
|
+
/* Added const qualifiers to remove C++ */
|
36
|
+
/* deprecation warnings. */
|
37
|
+
/* */
|
38
|
+
/* Converted API macros to function calls. */
|
39
|
+
/* */
|
40
|
+
/* Added code to prevent a clear command from */
|
41
|
+
/* being executed during fact assertions via */
|
42
|
+
/* Increment/DecrementClearReadyLocks API. */
|
43
|
+
/* */
|
44
|
+
/* Changed find construct functionality so that */
|
45
|
+
/* imported modules are search when locating a */
|
46
|
+
/* named construct. */
|
47
|
+
/* */
|
48
|
+
/* 6.31: Error messages are now generated when the */
|
49
|
+
/* fact-index function is given a retracted */
|
50
|
+
/* fact. */
|
51
|
+
/* */
|
52
|
+
/* Added code to keep track of pointers to */
|
53
|
+
/* constructs that are contained externally to */
|
54
|
+
/* to constructs, DanglingConstructs. */
|
55
|
+
/* */
|
56
|
+
/* If embedded, LoadFacts cleans the current */
|
57
|
+
/* garbage frame. */
|
58
|
+
/* */
|
59
|
+
/* 6.32: Fixed embedded reset of error flags. */
|
60
|
+
/* */
|
61
|
+
/* 6.40: Added Env prefix to GetEvaluationError and */
|
62
|
+
/* SetEvaluationError functions. */
|
63
|
+
/* */
|
64
|
+
/* Added Env prefix to GetHaltExecution and */
|
65
|
+
/* SetHaltExecution functions. */
|
66
|
+
/* */
|
67
|
+
/* Pragma once and other inclusion changes. */
|
68
|
+
/* */
|
69
|
+
/* Added support for booleans with <stdbool.h>. */
|
70
|
+
/* */
|
71
|
+
/* Removed use of void pointers for specific */
|
72
|
+
/* data structures. */
|
73
|
+
/* */
|
74
|
+
/* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
|
75
|
+
/* */
|
76
|
+
/* UDF redesign. */
|
77
|
+
/* */
|
78
|
+
/* Eval support for run time and bload only. */
|
79
|
+
/* */
|
80
|
+
/* Watch facts for modify command only prints */
|
81
|
+
/* changed slots. */
|
82
|
+
/* */
|
83
|
+
/* Moved load-facts and save-facts functions to */
|
84
|
+
/* factfile.c and factfile.h. */
|
85
|
+
/* */
|
86
|
+
/* 6.41: Used gensnprintf in place of gensprintf and. */
|
87
|
+
/* sprintf. */
|
88
|
+
/* */
|
89
|
+
/*************************************************************/
|
90
|
+
|
91
|
+
#include <stdio.h>
|
92
|
+
#include <string.h>
|
93
|
+
|
94
|
+
#include "setup.h"
|
95
|
+
|
96
|
+
#if DEFTEMPLATE_CONSTRUCT
|
97
|
+
|
98
|
+
#include "argacces.h"
|
99
|
+
#include "extnfunc.h"
|
100
|
+
#include "factmngr.h"
|
101
|
+
#include "factrhs.h"
|
102
|
+
#include "multifld.h"
|
103
|
+
#include "pprint.h"
|
104
|
+
#include "prntutil.h"
|
105
|
+
#include "router.h"
|
106
|
+
#include "scanner.h"
|
107
|
+
#include "sysdep.h"
|
108
|
+
#include "tmpltdef.h"
|
109
|
+
#include "tmpltutl.h"
|
110
|
+
|
111
|
+
#include "factcom.h"
|
112
|
+
|
113
|
+
#define INVALID -2L
|
114
|
+
#define UNSPECIFIED -1L
|
115
|
+
|
116
|
+
/***************************************/
|
117
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
118
|
+
/***************************************/
|
119
|
+
|
120
|
+
static struct expr *AssertParse(Environment *,struct expr *,const char *);
|
121
|
+
#if DEBUGGING_FUNCTIONS
|
122
|
+
static long long GetFactsArgument(UDFContext *);
|
123
|
+
#endif
|
124
|
+
|
125
|
+
/***************************************/
|
126
|
+
/* FactCommandDefinitions: Initializes */
|
127
|
+
/* fact commands and functions. */
|
128
|
+
/***************************************/
|
129
|
+
void FactCommandDefinitions(
|
130
|
+
Environment *theEnv)
|
131
|
+
{
|
132
|
+
#if ! RUN_TIME
|
133
|
+
#if DEBUGGING_FUNCTIONS
|
134
|
+
AddUDF(theEnv,"facts","v",0,4,"l;*",FactsCommand,"FactsCommand",NULL);
|
135
|
+
#endif
|
136
|
+
|
137
|
+
AddUDF(theEnv,"assert","bf",0,UNBOUNDED,NULL,AssertCommand,"AssertCommand",NULL);
|
138
|
+
AddUDF(theEnv,"retract", "v",1,UNBOUNDED,"fly",RetractCommand,"RetractCommand",NULL);
|
139
|
+
AddUDF(theEnv,"assert-string","bf",1,1,"s",AssertStringFunction,"AssertStringFunction",NULL);
|
140
|
+
AddUDF(theEnv,"str-assert","bf",1,1,"s",AssertStringFunction,"AssertStringFunction",NULL);
|
141
|
+
|
142
|
+
AddUDF(theEnv,"get-fact-duplication","b",0,0,NULL,GetFactDuplicationCommand,"GetFactDuplicationCommand", NULL);
|
143
|
+
AddUDF(theEnv,"set-fact-duplication","b",1,1,NULL,SetFactDuplicationCommand,"SetFactDuplicationCommand", NULL);
|
144
|
+
|
145
|
+
AddUDF(theEnv,"fact-index","l",1,1,"f",FactIndexFunction,"FactIndexFunction",NULL);
|
146
|
+
|
147
|
+
FuncSeqOvlFlags(theEnv,"assert",false,false);
|
148
|
+
#else
|
149
|
+
#if MAC_XCD
|
150
|
+
#pragma unused(theEnv)
|
151
|
+
#endif
|
152
|
+
#endif
|
153
|
+
AddFunctionParser(theEnv,"assert",AssertParse);
|
154
|
+
}
|
155
|
+
|
156
|
+
/***************************************/
|
157
|
+
/* AssertCommand: H/L access routine */
|
158
|
+
/* for the assert function. */
|
159
|
+
/***************************************/
|
160
|
+
void AssertCommand(
|
161
|
+
Environment *theEnv,
|
162
|
+
UDFContext *context,
|
163
|
+
UDFValue *returnValue)
|
164
|
+
{
|
165
|
+
Deftemplate *theDeftemplate;
|
166
|
+
CLIPSValue *theField;
|
167
|
+
UDFValue theValue;
|
168
|
+
struct expr *theExpression;
|
169
|
+
struct templateSlot *slotPtr;
|
170
|
+
Fact *newFact;
|
171
|
+
bool error = false;
|
172
|
+
int i;
|
173
|
+
Fact *theFact;
|
174
|
+
|
175
|
+
/*================================*/
|
176
|
+
/* Get the deftemplate associated */
|
177
|
+
/* with the fact being asserted. */
|
178
|
+
/*================================*/
|
179
|
+
|
180
|
+
theExpression = GetFirstArgument();
|
181
|
+
theDeftemplate = (Deftemplate *) theExpression->value;
|
182
|
+
|
183
|
+
/*=======================================*/
|
184
|
+
/* Create the fact and store the name of */
|
185
|
+
/* the deftemplate as the 1st field. */
|
186
|
+
/*=======================================*/
|
187
|
+
|
188
|
+
if (theDeftemplate->implied == false)
|
189
|
+
{
|
190
|
+
newFact = CreateFactBySize(theEnv,theDeftemplate->numberOfSlots);
|
191
|
+
slotPtr = theDeftemplate->slotList;
|
192
|
+
}
|
193
|
+
else
|
194
|
+
{
|
195
|
+
newFact = CreateFactBySize(theEnv,1);
|
196
|
+
if (theExpression->nextArg == NULL)
|
197
|
+
{ newFact->theProposition.contents[0].multifieldValue = CreateUnmanagedMultifield(theEnv,0L); }
|
198
|
+
slotPtr = NULL;
|
199
|
+
}
|
200
|
+
|
201
|
+
newFact->whichDeftemplate = theDeftemplate;
|
202
|
+
|
203
|
+
/*===================================================*/
|
204
|
+
/* Evaluate the expression associated with each slot */
|
205
|
+
/* and store the result in the appropriate slot of */
|
206
|
+
/* the newly created fact. */
|
207
|
+
/*===================================================*/
|
208
|
+
|
209
|
+
IncrementClearReadyLocks(theEnv);
|
210
|
+
|
211
|
+
theField = newFact->theProposition.contents;
|
212
|
+
|
213
|
+
for (theExpression = theExpression->nextArg, i = 0;
|
214
|
+
theExpression != NULL;
|
215
|
+
theExpression = theExpression->nextArg, i++)
|
216
|
+
{
|
217
|
+
/*===================================================*/
|
218
|
+
/* Evaluate the expression to be stored in the slot. */
|
219
|
+
/*===================================================*/
|
220
|
+
|
221
|
+
EvaluateExpression(theEnv,theExpression,&theValue);
|
222
|
+
|
223
|
+
/*============================================================*/
|
224
|
+
/* A multifield value can't be stored in a single field slot. */
|
225
|
+
/*============================================================*/
|
226
|
+
|
227
|
+
if ((slotPtr != NULL) ?
|
228
|
+
(slotPtr->multislot == false) && (theValue.header->type == MULTIFIELD_TYPE) :
|
229
|
+
false)
|
230
|
+
{
|
231
|
+
MultiIntoSingleFieldSlotError(theEnv,slotPtr,theDeftemplate);
|
232
|
+
theValue.value = FalseSymbol(theEnv);
|
233
|
+
error = true;
|
234
|
+
}
|
235
|
+
|
236
|
+
/*==============================*/
|
237
|
+
/* Store the value in the slot. */
|
238
|
+
/*==============================*/
|
239
|
+
|
240
|
+
theField[i].value = theValue.value;
|
241
|
+
|
242
|
+
/*========================================*/
|
243
|
+
/* Get the information for the next slot. */
|
244
|
+
/*========================================*/
|
245
|
+
|
246
|
+
if (slotPtr != NULL) slotPtr = slotPtr->next;
|
247
|
+
}
|
248
|
+
|
249
|
+
DecrementClearReadyLocks(theEnv);
|
250
|
+
|
251
|
+
/*============================================*/
|
252
|
+
/* If an error occured while generating the */
|
253
|
+
/* fact's slot values, then abort the assert. */
|
254
|
+
/*============================================*/
|
255
|
+
|
256
|
+
if (error)
|
257
|
+
{
|
258
|
+
ReturnFact(theEnv,newFact);
|
259
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
260
|
+
return;
|
261
|
+
}
|
262
|
+
|
263
|
+
/*================================*/
|
264
|
+
/* Add the fact to the fact-list. */
|
265
|
+
/*================================*/
|
266
|
+
|
267
|
+
theFact = Assert(newFact);
|
268
|
+
|
269
|
+
/*========================================*/
|
270
|
+
/* The asserted fact is the return value. */
|
271
|
+
/*========================================*/
|
272
|
+
|
273
|
+
if (theFact != NULL)
|
274
|
+
{ returnValue->factValue = theFact; }
|
275
|
+
else
|
276
|
+
{ returnValue->lexemeValue = FalseSymbol(theEnv); }
|
277
|
+
|
278
|
+
return;
|
279
|
+
}
|
280
|
+
|
281
|
+
/****************************************/
|
282
|
+
/* RetractCommand: H/L access routine */
|
283
|
+
/* for the retract command. */
|
284
|
+
/****************************************/
|
285
|
+
void RetractCommand(
|
286
|
+
Environment *theEnv,
|
287
|
+
UDFContext *context,
|
288
|
+
UDFValue *returnValue)
|
289
|
+
{
|
290
|
+
long long factIndex;
|
291
|
+
Fact *ptr;
|
292
|
+
UDFValue theArg;
|
293
|
+
|
294
|
+
/*================================*/
|
295
|
+
/* Iterate through each argument. */
|
296
|
+
/*================================*/
|
297
|
+
|
298
|
+
while (UDFHasNextArgument(context))
|
299
|
+
{
|
300
|
+
/*========================*/
|
301
|
+
/* Evaluate the argument. */
|
302
|
+
/*========================*/
|
303
|
+
|
304
|
+
if (! UDFNextArgument(context,INTEGER_BIT | FACT_ADDRESS_BIT | SYMBOL_BIT,&theArg))
|
305
|
+
{ return; }
|
306
|
+
|
307
|
+
/*======================================*/
|
308
|
+
/* If the argument evaluates to a fact */
|
309
|
+
/* address, we can directly retract it. */
|
310
|
+
/*======================================*/
|
311
|
+
|
312
|
+
if (CVIsType(&theArg,FACT_ADDRESS_BIT))
|
313
|
+
{ Retract(theArg.factValue); }
|
314
|
+
|
315
|
+
/*===============================================*/
|
316
|
+
/* If the argument evaluates to an integer, then */
|
317
|
+
/* it's assumed to be the fact index of the fact */
|
318
|
+
/* to be retracted. */
|
319
|
+
/*===============================================*/
|
320
|
+
|
321
|
+
else if (CVIsType(&theArg,INTEGER_BIT))
|
322
|
+
{
|
323
|
+
/*==========================================*/
|
324
|
+
/* A fact index must be a positive integer. */
|
325
|
+
/*==========================================*/
|
326
|
+
|
327
|
+
factIndex = theArg.integerValue->contents;
|
328
|
+
if (factIndex < 0)
|
329
|
+
{
|
330
|
+
UDFInvalidArgumentMessage(context,"fact-address, fact-index, or the symbol *");
|
331
|
+
return;
|
332
|
+
}
|
333
|
+
|
334
|
+
/*================================================*/
|
335
|
+
/* See if a fact with the specified index exists. */
|
336
|
+
/*================================================*/
|
337
|
+
|
338
|
+
ptr = FindIndexedFact(theEnv,factIndex);
|
339
|
+
|
340
|
+
/*=====================================*/
|
341
|
+
/* If the fact exists then retract it, */
|
342
|
+
/* otherwise print an error message. */
|
343
|
+
/*=====================================*/
|
344
|
+
|
345
|
+
if (ptr != NULL)
|
346
|
+
{ Retract(ptr); }
|
347
|
+
else
|
348
|
+
{
|
349
|
+
char tempBuffer[20];
|
350
|
+
gensnprintf(tempBuffer,sizeof(tempBuffer),"f-%lld",factIndex);
|
351
|
+
CantFindItemErrorMessage(theEnv,"fact",tempBuffer,false);
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
/*============================================*/
|
356
|
+
/* Otherwise if the argument evaluates to the */
|
357
|
+
/* symbol *, then all facts are retracted. */
|
358
|
+
/*============================================*/
|
359
|
+
|
360
|
+
else if ((CVIsType(&theArg,SYMBOL_BIT)) ?
|
361
|
+
(strcmp(theArg.lexemeValue->contents,"*") == 0) : false)
|
362
|
+
{
|
363
|
+
RetractAllFacts(theEnv);
|
364
|
+
return;
|
365
|
+
}
|
366
|
+
|
367
|
+
/*============================================*/
|
368
|
+
/* Otherwise the argument has evaluated to an */
|
369
|
+
/* illegal value for the retract command. */
|
370
|
+
/*============================================*/
|
371
|
+
|
372
|
+
else
|
373
|
+
{
|
374
|
+
UDFInvalidArgumentMessage(context,"fact-address, fact-index, or the symbol *");
|
375
|
+
SetEvaluationError(theEnv,true);
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
/***************************************************/
|
381
|
+
/* SetFactDuplicationCommand: H/L access routine */
|
382
|
+
/* for the set-fact-duplication command. */
|
383
|
+
/***************************************************/
|
384
|
+
void SetFactDuplicationCommand(
|
385
|
+
Environment *theEnv,
|
386
|
+
UDFContext *context,
|
387
|
+
UDFValue *returnValue)
|
388
|
+
{
|
389
|
+
UDFValue theArg;
|
390
|
+
|
391
|
+
/*=====================================================*/
|
392
|
+
/* Get the old value of the fact duplication behavior. */
|
393
|
+
/*=====================================================*/
|
394
|
+
|
395
|
+
returnValue->lexemeValue = CreateBoolean(theEnv,GetFactDuplication(theEnv));
|
396
|
+
|
397
|
+
/*========================*/
|
398
|
+
/* Evaluate the argument. */
|
399
|
+
/*========================*/
|
400
|
+
|
401
|
+
if (! UDFFirstArgument(context,ANY_TYPE_BITS,&theArg))
|
402
|
+
{ return; }
|
403
|
+
|
404
|
+
/*===============================================================*/
|
405
|
+
/* If the argument evaluated to false, then the fact duplication */
|
406
|
+
/* behavior is disabled, otherwise it is enabled. */
|
407
|
+
/*===============================================================*/
|
408
|
+
|
409
|
+
SetFactDuplication(theEnv,theArg.value != FalseSymbol(theEnv));
|
410
|
+
}
|
411
|
+
|
412
|
+
/***************************************************/
|
413
|
+
/* GetFactDuplicationCommand: H/L access routine */
|
414
|
+
/* for the get-fact-duplication command. */
|
415
|
+
/***************************************************/
|
416
|
+
void GetFactDuplicationCommand(
|
417
|
+
Environment *theEnv,
|
418
|
+
UDFContext *context,
|
419
|
+
UDFValue *returnValue)
|
420
|
+
{
|
421
|
+
returnValue->lexemeValue = CreateBoolean(theEnv,GetFactDuplication(theEnv));
|
422
|
+
}
|
423
|
+
|
424
|
+
/*******************************************/
|
425
|
+
/* FactIndexFunction: H/L access routine */
|
426
|
+
/* for the fact-index function. */
|
427
|
+
/*******************************************/
|
428
|
+
void FactIndexFunction(
|
429
|
+
Environment *theEnv,
|
430
|
+
UDFContext *context,
|
431
|
+
UDFValue *returnValue)
|
432
|
+
{
|
433
|
+
UDFValue theArg;
|
434
|
+
|
435
|
+
/*======================================*/
|
436
|
+
/* The argument must be a fact address. */
|
437
|
+
/*======================================*/
|
438
|
+
|
439
|
+
if (! UDFFirstArgument(context,FACT_ADDRESS_BIT,&theArg))
|
440
|
+
{ return; }
|
441
|
+
|
442
|
+
/*================================================*/
|
443
|
+
/* Return the fact index associated with the fact */
|
444
|
+
/* address. If the fact has been retracted, then */
|
445
|
+
/* return -1 for the fact index. */
|
446
|
+
/*================================================*/
|
447
|
+
|
448
|
+
if (theArg.factValue->garbage)
|
449
|
+
{
|
450
|
+
FactRetractedErrorMessage(theEnv,theArg.factValue);
|
451
|
+
returnValue->integerValue = CreateInteger(theEnv,-1L);
|
452
|
+
return;
|
453
|
+
}
|
454
|
+
|
455
|
+
returnValue->integerValue = CreateInteger(theEnv,FactIndex(theArg.factValue));
|
456
|
+
}
|
457
|
+
|
458
|
+
#if DEBUGGING_FUNCTIONS
|
459
|
+
|
460
|
+
/**************************************/
|
461
|
+
/* FactsCommand: H/L access routine */
|
462
|
+
/* for the facts command. */
|
463
|
+
/**************************************/
|
464
|
+
void FactsCommand(
|
465
|
+
Environment *theEnv,
|
466
|
+
UDFContext *context,
|
467
|
+
UDFValue *returnValue)
|
468
|
+
{
|
469
|
+
long long start = UNSPECIFIED, end = UNSPECIFIED, max = UNSPECIFIED;
|
470
|
+
Defmodule *theModule;
|
471
|
+
UDFValue theArg;
|
472
|
+
|
473
|
+
/*==================================*/
|
474
|
+
/* The default module for the facts */
|
475
|
+
/* command is the current module. */
|
476
|
+
/*==================================*/
|
477
|
+
|
478
|
+
theModule = GetCurrentModule(theEnv);
|
479
|
+
|
480
|
+
/*==========================================*/
|
481
|
+
/* If no arguments were specified, then use */
|
482
|
+
/* the default values to list the facts. */
|
483
|
+
/*==========================================*/
|
484
|
+
|
485
|
+
if (! UDFHasNextArgument(context))
|
486
|
+
{
|
487
|
+
Facts(theEnv,STDOUT,theModule,start,end,max);
|
488
|
+
return;
|
489
|
+
}
|
490
|
+
|
491
|
+
/*========================================================*/
|
492
|
+
/* Since there are one or more arguments, see if a module */
|
493
|
+
/* or start index was specified as the first argument. */
|
494
|
+
/*========================================================*/
|
495
|
+
|
496
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT | INTEGER_BIT,&theArg)) return;
|
497
|
+
|
498
|
+
/*===============================================*/
|
499
|
+
/* If the first argument is a symbol, then check */
|
500
|
+
/* to see that a valid module was specified. */
|
501
|
+
/*===============================================*/
|
502
|
+
|
503
|
+
if (CVIsType(&theArg,SYMBOL_BIT))
|
504
|
+
{
|
505
|
+
theModule = FindDefmodule(theEnv,theArg.lexemeValue->contents);
|
506
|
+
if ((theModule == NULL) && (strcmp(theArg.lexemeValue->contents,"*") != 0))
|
507
|
+
{
|
508
|
+
SetEvaluationError(theEnv,true);
|
509
|
+
CantFindItemErrorMessage(theEnv,"defmodule",theArg.lexemeValue->contents,true);
|
510
|
+
return;
|
511
|
+
}
|
512
|
+
|
513
|
+
if ((start = GetFactsArgument(context)) == INVALID) return;
|
514
|
+
}
|
515
|
+
|
516
|
+
/*================================================*/
|
517
|
+
/* Otherwise if the first argument is an integer, */
|
518
|
+
/* check to see that a valid index was specified. */
|
519
|
+
/*================================================*/
|
520
|
+
|
521
|
+
else if (CVIsType(&theArg,INTEGER_BIT))
|
522
|
+
{
|
523
|
+
start = theArg.integerValue->contents;
|
524
|
+
if (start < 0)
|
525
|
+
{
|
526
|
+
ExpectedTypeError1(theEnv,"facts",1,"symbol or 'positive number'");
|
527
|
+
UDFThrowError(context);
|
528
|
+
return;
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
/*==========================================*/
|
533
|
+
/* Otherwise the first argument is invalid. */
|
534
|
+
/*==========================================*/
|
535
|
+
|
536
|
+
else
|
537
|
+
{
|
538
|
+
UDFInvalidArgumentMessage(context,"symbol or 'positive number'");
|
539
|
+
UDFThrowError(context);
|
540
|
+
return;
|
541
|
+
}
|
542
|
+
|
543
|
+
/*==========================*/
|
544
|
+
/* Get the other arguments. */
|
545
|
+
/*==========================*/
|
546
|
+
|
547
|
+
if ((end = GetFactsArgument(context)) == INVALID) return;
|
548
|
+
if ((max = GetFactsArgument(context)) == INVALID) return;
|
549
|
+
|
550
|
+
/*=================*/
|
551
|
+
/* List the facts. */
|
552
|
+
/*=================*/
|
553
|
+
|
554
|
+
Facts(theEnv,STDOUT,theModule,start,end,max);
|
555
|
+
}
|
556
|
+
|
557
|
+
/**************************************************/
|
558
|
+
/* Facts: C access routine for the facts command. */
|
559
|
+
/**************************************************/
|
560
|
+
void Facts(
|
561
|
+
Environment *theEnv,
|
562
|
+
const char *logicalName,
|
563
|
+
Defmodule *theModule,
|
564
|
+
long long start,
|
565
|
+
long long end,
|
566
|
+
long long max)
|
567
|
+
{
|
568
|
+
Fact *factPtr;
|
569
|
+
unsigned long count = 0;
|
570
|
+
Defmodule *oldModule;
|
571
|
+
bool allModules = false;
|
572
|
+
|
573
|
+
/*=====================================*/
|
574
|
+
/* If embedded, clear the error flags. */
|
575
|
+
/*=====================================*/
|
576
|
+
|
577
|
+
if (EvaluationData(theEnv)->CurrentExpression == NULL)
|
578
|
+
{ ResetErrorFlags(theEnv); }
|
579
|
+
|
580
|
+
/*==========================*/
|
581
|
+
/* Save the current module. */
|
582
|
+
/*==========================*/
|
583
|
+
|
584
|
+
oldModule = GetCurrentModule(theEnv);
|
585
|
+
|
586
|
+
/*=========================================================*/
|
587
|
+
/* Determine if facts from all modules are to be displayed */
|
588
|
+
/* or just facts from the current module. */
|
589
|
+
/*=========================================================*/
|
590
|
+
|
591
|
+
if (theModule == NULL) allModules = true;
|
592
|
+
else SetCurrentModule(theEnv,theModule);
|
593
|
+
|
594
|
+
/*=====================================*/
|
595
|
+
/* Get the first fact to be displayed. */
|
596
|
+
/*=====================================*/
|
597
|
+
|
598
|
+
if (allModules) factPtr = GetNextFact(theEnv,NULL);
|
599
|
+
else factPtr = GetNextFactInScope(theEnv,NULL);
|
600
|
+
|
601
|
+
/*===============================*/
|
602
|
+
/* Display facts until there are */
|
603
|
+
/* no more facts to display. */
|
604
|
+
/*===============================*/
|
605
|
+
|
606
|
+
while (factPtr != NULL)
|
607
|
+
{
|
608
|
+
/*==================================================*/
|
609
|
+
/* Abort the display of facts if the Halt Execution */
|
610
|
+
/* flag has been set (normally by user action). */
|
611
|
+
/*==================================================*/
|
612
|
+
|
613
|
+
if (GetHaltExecution(theEnv) == true)
|
614
|
+
{
|
615
|
+
SetCurrentModule(theEnv,oldModule);
|
616
|
+
return;
|
617
|
+
}
|
618
|
+
|
619
|
+
/*===============================================*/
|
620
|
+
/* If the maximum fact index of facts to display */
|
621
|
+
/* has been reached, then stop displaying facts. */
|
622
|
+
/*===============================================*/
|
623
|
+
|
624
|
+
if ((factPtr->factIndex > end) && (end != UNSPECIFIED))
|
625
|
+
{
|
626
|
+
PrintTally(theEnv,logicalName,count,"fact","facts");
|
627
|
+
SetCurrentModule(theEnv,oldModule);
|
628
|
+
return;
|
629
|
+
}
|
630
|
+
|
631
|
+
/*================================================*/
|
632
|
+
/* If the maximum number of facts to be displayed */
|
633
|
+
/* has been reached, then stop displaying facts. */
|
634
|
+
/*================================================*/
|
635
|
+
|
636
|
+
if (max == 0)
|
637
|
+
{
|
638
|
+
PrintTally(theEnv,logicalName,count,"fact","facts");
|
639
|
+
SetCurrentModule(theEnv,oldModule);
|
640
|
+
return;
|
641
|
+
}
|
642
|
+
|
643
|
+
/*======================================================*/
|
644
|
+
/* If the index of the fact is greater than the minimum */
|
645
|
+
/* starting fact index, then display the fact. */
|
646
|
+
/*======================================================*/
|
647
|
+
|
648
|
+
if (factPtr->factIndex >= start)
|
649
|
+
{
|
650
|
+
PrintFactWithIdentifier(theEnv,logicalName,factPtr,NULL);
|
651
|
+
WriteString(theEnv,logicalName,"\n");
|
652
|
+
count++;
|
653
|
+
if (max > 0) max--;
|
654
|
+
}
|
655
|
+
|
656
|
+
/*========================================*/
|
657
|
+
/* Proceed to the next fact to be listed. */
|
658
|
+
/*========================================*/
|
659
|
+
|
660
|
+
if (allModules) factPtr = GetNextFact(theEnv,factPtr);
|
661
|
+
else factPtr = GetNextFactInScope(theEnv,factPtr);
|
662
|
+
}
|
663
|
+
|
664
|
+
/*===================================================*/
|
665
|
+
/* Print the total of the number of facts displayed. */
|
666
|
+
/*===================================================*/
|
667
|
+
|
668
|
+
PrintTally(theEnv,logicalName,count,"fact","facts");
|
669
|
+
|
670
|
+
/*=============================*/
|
671
|
+
/* Restore the current module. */
|
672
|
+
/*=============================*/
|
673
|
+
|
674
|
+
SetCurrentModule(theEnv,oldModule);
|
675
|
+
}
|
676
|
+
|
677
|
+
/****************************************************************/
|
678
|
+
/* GetFactsArgument: Returns an argument for the facts command. */
|
679
|
+
/* A return value of -1 indicates that no value was specified. */
|
680
|
+
/* A return value of -2 indicates that the value specified is */
|
681
|
+
/* invalid. */
|
682
|
+
/****************************************************************/
|
683
|
+
static long long GetFactsArgument(
|
684
|
+
UDFContext *context)
|
685
|
+
{
|
686
|
+
long long factIndex;
|
687
|
+
UDFValue theArg;
|
688
|
+
|
689
|
+
if (! UDFHasNextArgument(context)) return(UNSPECIFIED);
|
690
|
+
|
691
|
+
if (! UDFNextArgument(context,INTEGER_BIT,&theArg))
|
692
|
+
{ return(INVALID); }
|
693
|
+
|
694
|
+
factIndex = theArg.integerValue->contents;
|
695
|
+
|
696
|
+
if (factIndex < 0)
|
697
|
+
{
|
698
|
+
UDFInvalidArgumentMessage(context,"positive number");
|
699
|
+
UDFThrowError(context);
|
700
|
+
return(INVALID);
|
701
|
+
}
|
702
|
+
|
703
|
+
return(factIndex);
|
704
|
+
}
|
705
|
+
|
706
|
+
#endif /* DEBUGGING_FUNCTIONS */
|
707
|
+
|
708
|
+
/**********************************************/
|
709
|
+
/* AssertStringFunction: H/L access routine */
|
710
|
+
/* for the assert-string function. */
|
711
|
+
/**********************************************/
|
712
|
+
void AssertStringFunction(
|
713
|
+
Environment *theEnv,
|
714
|
+
UDFContext *context,
|
715
|
+
UDFValue *returnValue)
|
716
|
+
{
|
717
|
+
UDFValue theArg;
|
718
|
+
Fact *theFact;
|
719
|
+
|
720
|
+
/*=====================================================*/
|
721
|
+
/* Check for the correct number and type of arguments. */
|
722
|
+
/*=====================================================*/
|
723
|
+
|
724
|
+
if (! UDFFirstArgument(context,STRING_BIT,&theArg))
|
725
|
+
{ return; }
|
726
|
+
|
727
|
+
/*==========================================*/
|
728
|
+
/* Call the driver routine for converting a */
|
729
|
+
/* string to a fact and then assert it. */
|
730
|
+
/*==========================================*/
|
731
|
+
|
732
|
+
theFact = AssertString(theEnv,theArg.lexemeValue->contents);
|
733
|
+
if (theFact != NULL)
|
734
|
+
{ returnValue->factValue = theFact; }
|
735
|
+
else
|
736
|
+
{ returnValue->lexemeValue = FalseSymbol(theEnv); }
|
737
|
+
}
|
738
|
+
|
739
|
+
/****************************************************************/
|
740
|
+
/* AssertParse: Driver routine for parsing the assert function. */
|
741
|
+
/****************************************************************/
|
742
|
+
static struct expr *AssertParse(
|
743
|
+
Environment *theEnv,
|
744
|
+
struct expr *top,
|
745
|
+
const char *logicalName)
|
746
|
+
{
|
747
|
+
bool error;
|
748
|
+
struct expr *rv;
|
749
|
+
struct token theToken;
|
750
|
+
|
751
|
+
ReturnExpression(theEnv,top);
|
752
|
+
SavePPBuffer(theEnv," ");
|
753
|
+
IncrementIndentDepth(theEnv,8);
|
754
|
+
rv = BuildRHSAssert(theEnv,logicalName,&theToken,&error,true,true,"assert command");
|
755
|
+
DecrementIndentDepth(theEnv,8);
|
756
|
+
return(rv);
|
757
|
+
}
|
758
|
+
|
759
|
+
#endif /* DEFTEMPLATE_CONSTRUCT */
|