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,878 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.41 12/04/22 */
|
5
|
+
/* */
|
6
|
+
/* PRINT UTILITY MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Utility routines for printing various items */
|
11
|
+
/* and messages. */
|
12
|
+
/* */
|
13
|
+
/* Principal Programmer(s): */
|
14
|
+
/* Gary D. Riley */
|
15
|
+
/* */
|
16
|
+
/* Contributing Programmer(s): */
|
17
|
+
/* Brian L. Dantes */
|
18
|
+
/* */
|
19
|
+
/* Revision History: */
|
20
|
+
/* */
|
21
|
+
/* 6.24: Link error occurs for the SlotExistError */
|
22
|
+
/* function when OBJECT_SYSTEM is set to 0 in */
|
23
|
+
/* setup.h. DR0865 */
|
24
|
+
/* */
|
25
|
+
/* Added DataObjectToString function. */
|
26
|
+
/* */
|
27
|
+
/* Added SlotExistError function. */
|
28
|
+
/* */
|
29
|
+
/* 6.30: Support for long long integers. */
|
30
|
+
/* */
|
31
|
+
/* Support for DATA_OBJECT_ARRAY primitive. */
|
32
|
+
/* */
|
33
|
+
/* Support for typed EXTERNAL_ADDRESS_TYPE. */
|
34
|
+
/* */
|
35
|
+
/* Used gensprintf and genstrcat instead of */
|
36
|
+
/* sprintf and strcat. */
|
37
|
+
/* */
|
38
|
+
/* Changed integer type/precision. */
|
39
|
+
/* */
|
40
|
+
/* Added code for capturing errors/warnings. */
|
41
|
+
/* */
|
42
|
+
/* Added const qualifiers to remove C++ */
|
43
|
+
/* deprecation warnings. */
|
44
|
+
/* */
|
45
|
+
/* Fixed linkage issue when BLOAD_ONLY compiler */
|
46
|
+
/* flag is set to 1. */
|
47
|
+
/* */
|
48
|
+
/* 6.31: Added additional error messages for retracted */
|
49
|
+
/* facts, deleted instances, and invalid slots. */
|
50
|
+
/* */
|
51
|
+
/* Added under/overflow error message. */
|
52
|
+
/* */
|
53
|
+
/* 6.40: Added Env prefix to GetEvaluationError and */
|
54
|
+
/* SetEvaluationError functions. */
|
55
|
+
/* */
|
56
|
+
/* Pragma once and other inclusion changes. */
|
57
|
+
/* */
|
58
|
+
/* Added support for booleans with <stdbool.h>. */
|
59
|
+
/* */
|
60
|
+
/* Removed use of void pointers for specific */
|
61
|
+
/* data structures. */
|
62
|
+
/* */
|
63
|
+
/* UDF redesign. */
|
64
|
+
/* */
|
65
|
+
/* Removed DATA_OBJECT_ARRAY primitive type. */
|
66
|
+
/* */
|
67
|
+
/* File name/line count displayed for errors */
|
68
|
+
/* and warnings during load command. */
|
69
|
+
/* */
|
70
|
+
/* 6.41: Used gensnprintf in place of gensprintf and. */
|
71
|
+
/* sprintf. */
|
72
|
+
/* */
|
73
|
+
/*************************************************************/
|
74
|
+
|
75
|
+
#include <stdio.h>
|
76
|
+
#include <string.h>
|
77
|
+
|
78
|
+
#include "setup.h"
|
79
|
+
|
80
|
+
#include "argacces.h"
|
81
|
+
#include "constant.h"
|
82
|
+
#include "cstrcpsr.h"
|
83
|
+
#include "envrnmnt.h"
|
84
|
+
#include "evaluatn.h"
|
85
|
+
#include "factmngr.h"
|
86
|
+
#include "inscom.h"
|
87
|
+
#include "insmngr.h"
|
88
|
+
#include "memalloc.h"
|
89
|
+
#include "multifun.h"
|
90
|
+
#include "router.h"
|
91
|
+
#include "scanner.h"
|
92
|
+
#include "strngrtr.h"
|
93
|
+
#include "symbol.h"
|
94
|
+
#include "sysdep.h"
|
95
|
+
#include "utility.h"
|
96
|
+
|
97
|
+
#include "prntutil.h"
|
98
|
+
|
99
|
+
/*****************************************************/
|
100
|
+
/* InitializePrintUtilityData: Allocates environment */
|
101
|
+
/* data for print utility routines. */
|
102
|
+
/*****************************************************/
|
103
|
+
void InitializePrintUtilityData(
|
104
|
+
Environment *theEnv)
|
105
|
+
{
|
106
|
+
AllocateEnvironmentData(theEnv,PRINT_UTILITY_DATA,sizeof(struct printUtilityData),NULL);
|
107
|
+
}
|
108
|
+
|
109
|
+
/************************************************************/
|
110
|
+
/* WriteFloat: Controls printout of floating point numbers. */
|
111
|
+
/************************************************************/
|
112
|
+
void WriteFloat(
|
113
|
+
Environment *theEnv,
|
114
|
+
const char *fileid,
|
115
|
+
double number)
|
116
|
+
{
|
117
|
+
const char *theString;
|
118
|
+
|
119
|
+
theString = FloatToString(theEnv,number);
|
120
|
+
WriteString(theEnv,fileid,theString);
|
121
|
+
}
|
122
|
+
|
123
|
+
/************************************************/
|
124
|
+
/* WriteInteger: Controls printout of integers. */
|
125
|
+
/************************************************/
|
126
|
+
void WriteInteger(
|
127
|
+
Environment *theEnv,
|
128
|
+
const char *logicalName,
|
129
|
+
long long number)
|
130
|
+
{
|
131
|
+
char printBuffer[32];
|
132
|
+
|
133
|
+
gensnprintf(printBuffer,sizeof(printBuffer),"%lld",number);
|
134
|
+
WriteString(theEnv,logicalName,printBuffer);
|
135
|
+
}
|
136
|
+
|
137
|
+
/*******************************************/
|
138
|
+
/* PrintUnsignedInteger: Controls printout */
|
139
|
+
/* of unsigned integers. */
|
140
|
+
/*******************************************/
|
141
|
+
void PrintUnsignedInteger(
|
142
|
+
Environment *theEnv,
|
143
|
+
const char *logicalName,
|
144
|
+
unsigned long long number)
|
145
|
+
{
|
146
|
+
char printBuffer[32];
|
147
|
+
|
148
|
+
gensnprintf(printBuffer,sizeof(printBuffer),"%llu",number);
|
149
|
+
WriteString(theEnv,logicalName,printBuffer);
|
150
|
+
}
|
151
|
+
|
152
|
+
/**************************************/
|
153
|
+
/* PrintAtom: Prints an atomic value. */
|
154
|
+
/**************************************/
|
155
|
+
void PrintAtom(
|
156
|
+
Environment *theEnv,
|
157
|
+
const char *logicalName,
|
158
|
+
unsigned short type,
|
159
|
+
void *value)
|
160
|
+
{
|
161
|
+
CLIPSExternalAddress *theAddress;
|
162
|
+
char buffer[20];
|
163
|
+
|
164
|
+
switch (type)
|
165
|
+
{
|
166
|
+
case FLOAT_TYPE:
|
167
|
+
WriteFloat(theEnv,logicalName,((CLIPSFloat *) value)->contents);
|
168
|
+
break;
|
169
|
+
case INTEGER_TYPE:
|
170
|
+
WriteInteger(theEnv,logicalName,((CLIPSInteger *) value)->contents);
|
171
|
+
break;
|
172
|
+
case SYMBOL_TYPE:
|
173
|
+
WriteString(theEnv,logicalName,((CLIPSLexeme *) value)->contents);
|
174
|
+
break;
|
175
|
+
case STRING_TYPE:
|
176
|
+
if (PrintUtilityData(theEnv)->PreserveEscapedCharacters)
|
177
|
+
{ WriteString(theEnv,logicalName,StringPrintForm(theEnv,((CLIPSLexeme *) value)->contents)); }
|
178
|
+
else
|
179
|
+
{
|
180
|
+
WriteString(theEnv,logicalName,"\"");
|
181
|
+
WriteString(theEnv,logicalName,((CLIPSLexeme *) value)->contents);
|
182
|
+
WriteString(theEnv,logicalName,"\"");
|
183
|
+
}
|
184
|
+
break;
|
185
|
+
|
186
|
+
case EXTERNAL_ADDRESS_TYPE:
|
187
|
+
theAddress = (CLIPSExternalAddress *) value;
|
188
|
+
|
189
|
+
if (PrintUtilityData(theEnv)->AddressesToStrings) WriteString(theEnv,logicalName,"\"");
|
190
|
+
|
191
|
+
if ((EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type] != NULL) &&
|
192
|
+
(EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction != NULL))
|
193
|
+
{ (*EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction)(theEnv,logicalName,value); }
|
194
|
+
else
|
195
|
+
{
|
196
|
+
WriteString(theEnv,logicalName,"<Pointer-");
|
197
|
+
|
198
|
+
gensnprintf(buffer,sizeof(buffer),"%d-",theAddress->type);
|
199
|
+
WriteString(theEnv,logicalName,buffer);
|
200
|
+
|
201
|
+
gensnprintf(buffer,sizeof(buffer),"%p",((CLIPSExternalAddress *) value)->contents);
|
202
|
+
WriteString(theEnv,logicalName,buffer);
|
203
|
+
WriteString(theEnv,logicalName,">");
|
204
|
+
}
|
205
|
+
|
206
|
+
if (PrintUtilityData(theEnv)->AddressesToStrings) WriteString(theEnv,logicalName,"\"");
|
207
|
+
break;
|
208
|
+
|
209
|
+
#if OBJECT_SYSTEM
|
210
|
+
case INSTANCE_NAME_TYPE:
|
211
|
+
WriteString(theEnv,logicalName,"[");
|
212
|
+
WriteString(theEnv,logicalName,((CLIPSLexeme *) value)->contents);
|
213
|
+
WriteString(theEnv,logicalName,"]");
|
214
|
+
break;
|
215
|
+
#endif
|
216
|
+
|
217
|
+
case VOID_TYPE:
|
218
|
+
break;
|
219
|
+
|
220
|
+
default:
|
221
|
+
if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break;
|
222
|
+
if (EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction == NULL)
|
223
|
+
{
|
224
|
+
WriteString(theEnv,logicalName,"<unknown atom type>");
|
225
|
+
break;
|
226
|
+
}
|
227
|
+
(*EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction)(theEnv,logicalName,value);
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
/**********************************************************/
|
233
|
+
/* PrintTally: Prints a tally count indicating the number */
|
234
|
+
/* of items that have been displayed. Used by functions */
|
235
|
+
/* such as list-defrules. */
|
236
|
+
/**********************************************************/
|
237
|
+
void PrintTally(
|
238
|
+
Environment *theEnv,
|
239
|
+
const char *logicalName,
|
240
|
+
unsigned long long count,
|
241
|
+
const char *singular,
|
242
|
+
const char *plural)
|
243
|
+
{
|
244
|
+
if (count == 0) return;
|
245
|
+
|
246
|
+
WriteString(theEnv,logicalName,"For a total of ");
|
247
|
+
PrintUnsignedInteger(theEnv,logicalName,count);
|
248
|
+
WriteString(theEnv,logicalName," ");
|
249
|
+
|
250
|
+
if (count == 1) WriteString(theEnv,logicalName,singular);
|
251
|
+
else WriteString(theEnv,logicalName,plural);
|
252
|
+
|
253
|
+
WriteString(theEnv,logicalName,".\n");
|
254
|
+
}
|
255
|
+
|
256
|
+
/********************************************/
|
257
|
+
/* PrintErrorID: Prints the module name and */
|
258
|
+
/* error ID for an error message. */
|
259
|
+
/********************************************/
|
260
|
+
void PrintErrorID(
|
261
|
+
Environment *theEnv,
|
262
|
+
const char *module,
|
263
|
+
int errorID,
|
264
|
+
bool printCR)
|
265
|
+
{
|
266
|
+
#if (! RUN_TIME) && (! BLOAD_ONLY)
|
267
|
+
FlushParsingMessages(theEnv);
|
268
|
+
SetErrorFileName(theEnv,GetParsingFileName(theEnv));
|
269
|
+
ConstructData(theEnv)->ErrLineNumber = GetLineCount(theEnv);
|
270
|
+
#endif
|
271
|
+
if (printCR) WriteString(theEnv,STDERR,"\n");
|
272
|
+
WriteString(theEnv,STDERR,"[");
|
273
|
+
WriteString(theEnv,STDERR,module);
|
274
|
+
WriteInteger(theEnv,STDERR,errorID);
|
275
|
+
WriteString(theEnv,STDERR,"] ");
|
276
|
+
|
277
|
+
/*==================================================*/
|
278
|
+
/* Print the file name and line number if available */
|
279
|
+
/* and there is no callback for errors/warnings. */
|
280
|
+
/*==================================================*/
|
281
|
+
|
282
|
+
#if (! RUN_TIME) && (! BLOAD_ONLY)
|
283
|
+
if ((ConstructData(theEnv)->ParserErrorCallback == NULL) &&
|
284
|
+
(GetLoadInProgress(theEnv) == true))
|
285
|
+
{
|
286
|
+
const char *fileName;
|
287
|
+
|
288
|
+
fileName = GetParsingFileName(theEnv);
|
289
|
+
if (fileName != NULL)
|
290
|
+
{
|
291
|
+
WriteString(theEnv,STDERR,fileName);
|
292
|
+
WriteString(theEnv,STDERR,", Line ");
|
293
|
+
WriteInteger(theEnv,STDERR,GetLineCount(theEnv));
|
294
|
+
WriteString(theEnv,STDERR,": ");
|
295
|
+
}
|
296
|
+
}
|
297
|
+
#endif
|
298
|
+
}
|
299
|
+
|
300
|
+
/**********************************************/
|
301
|
+
/* PrintWarningID: Prints the module name and */
|
302
|
+
/* warning ID for a warning message. */
|
303
|
+
/**********************************************/
|
304
|
+
void PrintWarningID(
|
305
|
+
Environment *theEnv,
|
306
|
+
const char *module,
|
307
|
+
int warningID,
|
308
|
+
bool printCR)
|
309
|
+
{
|
310
|
+
#if (! RUN_TIME) && (! BLOAD_ONLY)
|
311
|
+
FlushParsingMessages(theEnv);
|
312
|
+
SetWarningFileName(theEnv,GetParsingFileName(theEnv));
|
313
|
+
ConstructData(theEnv)->WrnLineNumber = GetLineCount(theEnv);
|
314
|
+
#endif
|
315
|
+
if (printCR) WriteString(theEnv,STDWRN,"\n");
|
316
|
+
WriteString(theEnv,STDWRN,"[");
|
317
|
+
WriteString(theEnv,STDWRN,module);
|
318
|
+
WriteInteger(theEnv,STDWRN,warningID);
|
319
|
+
WriteString(theEnv,STDWRN,"] ");
|
320
|
+
|
321
|
+
/*==================================================*/
|
322
|
+
/* Print the file name and line number if available */
|
323
|
+
/* and there is no callback for errors/warnings. */
|
324
|
+
/*==================================================*/
|
325
|
+
|
326
|
+
#if (! RUN_TIME) && (! BLOAD_ONLY)
|
327
|
+
if ((ConstructData(theEnv)->ParserErrorCallback == NULL) &&
|
328
|
+
(GetLoadInProgress(theEnv) == true))
|
329
|
+
{
|
330
|
+
const char *fileName;
|
331
|
+
|
332
|
+
fileName = GetParsingFileName(theEnv);
|
333
|
+
if (fileName != NULL)
|
334
|
+
{
|
335
|
+
WriteString(theEnv,STDERR,fileName);
|
336
|
+
WriteString(theEnv,STDERR,", Line ");
|
337
|
+
WriteInteger(theEnv,STDERR,GetLineCount(theEnv));
|
338
|
+
WriteString(theEnv,STDERR,", ");
|
339
|
+
}
|
340
|
+
}
|
341
|
+
#endif
|
342
|
+
|
343
|
+
WriteString(theEnv,STDWRN,"WARNING: ");
|
344
|
+
}
|
345
|
+
|
346
|
+
/***************************************************/
|
347
|
+
/* CantFindItemErrorMessage: Generic error message */
|
348
|
+
/* when an "item" can not be found. */
|
349
|
+
/***************************************************/
|
350
|
+
void CantFindItemErrorMessage(
|
351
|
+
Environment *theEnv,
|
352
|
+
const char *itemType,
|
353
|
+
const char *itemName,
|
354
|
+
bool useQuotes)
|
355
|
+
{
|
356
|
+
PrintErrorID(theEnv,"PRNTUTIL",1,false);
|
357
|
+
WriteString(theEnv,STDERR,"Unable to find ");
|
358
|
+
WriteString(theEnv,STDERR,itemType);
|
359
|
+
WriteString(theEnv,STDERR," ");
|
360
|
+
if (useQuotes) WriteString(theEnv,STDERR,"'");
|
361
|
+
WriteString(theEnv,STDERR,itemName);
|
362
|
+
if (useQuotes) WriteString(theEnv,STDERR,"'");
|
363
|
+
WriteString(theEnv,STDERR,".\n");
|
364
|
+
}
|
365
|
+
|
366
|
+
/*****************************************************/
|
367
|
+
/* CantFindItemInFunctionErrorMessage: Generic error */
|
368
|
+
/* message when an "item" can not be found. */
|
369
|
+
/*****************************************************/
|
370
|
+
void CantFindItemInFunctionErrorMessage(
|
371
|
+
Environment *theEnv,
|
372
|
+
const char *itemType,
|
373
|
+
const char *itemName,
|
374
|
+
const char *func,
|
375
|
+
bool useQuotes)
|
376
|
+
{
|
377
|
+
PrintErrorID(theEnv,"PRNTUTIL",1,false);
|
378
|
+
WriteString(theEnv,STDERR,"Unable to find ");
|
379
|
+
WriteString(theEnv,STDERR,itemType);
|
380
|
+
WriteString(theEnv,STDERR," ");
|
381
|
+
if (useQuotes) WriteString(theEnv,STDERR,"'");
|
382
|
+
WriteString(theEnv,STDERR,itemName);
|
383
|
+
if (useQuotes) WriteString(theEnv,STDERR,"'");
|
384
|
+
WriteString(theEnv,STDERR," in function '");
|
385
|
+
WriteString(theEnv,STDERR,func);
|
386
|
+
WriteString(theEnv,STDERR,"'.\n");
|
387
|
+
}
|
388
|
+
|
389
|
+
/*****************************************************/
|
390
|
+
/* CantDeleteItemErrorMessage: Generic error message */
|
391
|
+
/* when an "item" can not be deleted. */
|
392
|
+
/*****************************************************/
|
393
|
+
void CantDeleteItemErrorMessage(
|
394
|
+
Environment *theEnv,
|
395
|
+
const char *itemType,
|
396
|
+
const char *itemName)
|
397
|
+
{
|
398
|
+
PrintErrorID(theEnv,"PRNTUTIL",4,false);
|
399
|
+
WriteString(theEnv,STDERR,"Unable to delete ");
|
400
|
+
WriteString(theEnv,STDERR,itemType);
|
401
|
+
WriteString(theEnv,STDERR," '");
|
402
|
+
WriteString(theEnv,STDERR,itemName);
|
403
|
+
WriteString(theEnv,STDERR,"'.\n");
|
404
|
+
}
|
405
|
+
|
406
|
+
/****************************************************/
|
407
|
+
/* AlreadyParsedErrorMessage: Generic error message */
|
408
|
+
/* when an "item" has already been parsed. */
|
409
|
+
/****************************************************/
|
410
|
+
void AlreadyParsedErrorMessage(
|
411
|
+
Environment *theEnv,
|
412
|
+
const char *itemType,
|
413
|
+
const char *itemName)
|
414
|
+
{
|
415
|
+
PrintErrorID(theEnv,"PRNTUTIL",5,true);
|
416
|
+
WriteString(theEnv,STDERR,"The ");
|
417
|
+
if (itemType != NULL) WriteString(theEnv,STDERR,itemType);
|
418
|
+
if (itemName != NULL)
|
419
|
+
{
|
420
|
+
WriteString(theEnv,STDERR,"'");
|
421
|
+
WriteString(theEnv,STDERR,itemName);
|
422
|
+
WriteString(theEnv,STDERR,"'");
|
423
|
+
}
|
424
|
+
WriteString(theEnv,STDERR," has already been parsed.\n");
|
425
|
+
}
|
426
|
+
|
427
|
+
/*********************************************************/
|
428
|
+
/* SyntaxErrorMessage: Generalized syntax error message. */
|
429
|
+
/*********************************************************/
|
430
|
+
void SyntaxErrorMessage(
|
431
|
+
Environment *theEnv,
|
432
|
+
const char *location)
|
433
|
+
{
|
434
|
+
PrintErrorID(theEnv,"PRNTUTIL",2,true);
|
435
|
+
WriteString(theEnv,STDERR,"Syntax Error");
|
436
|
+
if (location != NULL)
|
437
|
+
{
|
438
|
+
WriteString(theEnv,STDERR,": Check appropriate syntax for ");
|
439
|
+
WriteString(theEnv,STDERR,location);
|
440
|
+
}
|
441
|
+
|
442
|
+
WriteString(theEnv,STDERR,".\n");
|
443
|
+
SetEvaluationError(theEnv,true);
|
444
|
+
}
|
445
|
+
|
446
|
+
/****************************************************/
|
447
|
+
/* LocalVariableErrorMessage: Generic error message */
|
448
|
+
/* when a local variable is accessed by an "item" */
|
449
|
+
/* which can not access local variables. */
|
450
|
+
/****************************************************/
|
451
|
+
void LocalVariableErrorMessage(
|
452
|
+
Environment *theEnv,
|
453
|
+
const char *byWhat)
|
454
|
+
{
|
455
|
+
PrintErrorID(theEnv,"PRNTUTIL",6,true);
|
456
|
+
WriteString(theEnv,STDERR,"Local variables can not be accessed by ");
|
457
|
+
WriteString(theEnv,STDERR,byWhat);
|
458
|
+
WriteString(theEnv,STDERR,".\n");
|
459
|
+
}
|
460
|
+
|
461
|
+
/******************************************/
|
462
|
+
/* SystemError: Generalized error message */
|
463
|
+
/* for major internal errors. */
|
464
|
+
/******************************************/
|
465
|
+
void SystemError(
|
466
|
+
Environment *theEnv,
|
467
|
+
const char *module,
|
468
|
+
int errorID)
|
469
|
+
{
|
470
|
+
PrintErrorID(theEnv,"PRNTUTIL",3,true);
|
471
|
+
|
472
|
+
WriteString(theEnv,STDERR,"\n*** ");
|
473
|
+
WriteString(theEnv,STDERR,APPLICATION_NAME);
|
474
|
+
WriteString(theEnv,STDERR," SYSTEM ERROR ***\n");
|
475
|
+
|
476
|
+
WriteString(theEnv,STDERR,"ID = ");
|
477
|
+
WriteString(theEnv,STDERR,module);
|
478
|
+
WriteInteger(theEnv,STDERR,errorID);
|
479
|
+
WriteString(theEnv,STDERR,"\n");
|
480
|
+
|
481
|
+
WriteString(theEnv,STDERR,APPLICATION_NAME);
|
482
|
+
WriteString(theEnv,STDERR," data structures are in an inconsistent or corrupted state.\n");
|
483
|
+
WriteString(theEnv,STDERR,"This error may have occurred from errors in user defined code.\n");
|
484
|
+
WriteString(theEnv,STDERR,"**************************\n");
|
485
|
+
}
|
486
|
+
|
487
|
+
/*******************************************************/
|
488
|
+
/* DivideByZeroErrorMessage: Generalized error message */
|
489
|
+
/* for when a function attempts to divide by zero. */
|
490
|
+
/*******************************************************/
|
491
|
+
void DivideByZeroErrorMessage(
|
492
|
+
Environment *theEnv,
|
493
|
+
const char *functionName)
|
494
|
+
{
|
495
|
+
PrintErrorID(theEnv,"PRNTUTIL",7,false);
|
496
|
+
WriteString(theEnv,STDERR,"Attempt to divide by zero in '");
|
497
|
+
WriteString(theEnv,STDERR,functionName);
|
498
|
+
WriteString(theEnv,STDERR,"' function.\n");
|
499
|
+
}
|
500
|
+
|
501
|
+
/********************************************************/
|
502
|
+
/* ArgumentOverUnderflowErrorMessage: Generalized error */
|
503
|
+
/* message for an integer under or overflow. */
|
504
|
+
/********************************************************/
|
505
|
+
void ArgumentOverUnderflowErrorMessage(
|
506
|
+
Environment *theEnv,
|
507
|
+
const char *functionName,
|
508
|
+
bool error)
|
509
|
+
{
|
510
|
+
if (error)
|
511
|
+
{
|
512
|
+
PrintErrorID(theEnv,"PRNTUTIL",17,false);
|
513
|
+
WriteString(theEnv,STDERR,"Over or underflow of long long integer in '");
|
514
|
+
WriteString(theEnv,STDERR,functionName);
|
515
|
+
WriteString(theEnv,STDERR,"' function.\n");
|
516
|
+
}
|
517
|
+
else
|
518
|
+
{
|
519
|
+
PrintWarningID(theEnv,"PRNTUTIL",17,false);
|
520
|
+
WriteString(theEnv,STDWRN,"Over or underflow of long long integer in '");
|
521
|
+
WriteString(theEnv,STDWRN,functionName);
|
522
|
+
WriteString(theEnv,STDWRN,"' function.\n");
|
523
|
+
}
|
524
|
+
}
|
525
|
+
|
526
|
+
/*******************************************************/
|
527
|
+
/* FloatToString: Converts number to KB string format. */
|
528
|
+
/*******************************************************/
|
529
|
+
const char *FloatToString(
|
530
|
+
Environment *theEnv,
|
531
|
+
double number)
|
532
|
+
{
|
533
|
+
char floatString[40];
|
534
|
+
int i;
|
535
|
+
char x;
|
536
|
+
CLIPSLexeme *thePtr;
|
537
|
+
|
538
|
+
gensnprintf(floatString,sizeof(floatString),"%.15g",number);
|
539
|
+
|
540
|
+
for (i = 0; (x = floatString[i]) != '\0'; i++)
|
541
|
+
{
|
542
|
+
if ((x == '.') || (x == 'e'))
|
543
|
+
{
|
544
|
+
thePtr = CreateString(theEnv,floatString);
|
545
|
+
return thePtr->contents;
|
546
|
+
}
|
547
|
+
}
|
548
|
+
|
549
|
+
genstrcat(floatString,".0");
|
550
|
+
|
551
|
+
thePtr = CreateString(theEnv,floatString);
|
552
|
+
return thePtr->contents;
|
553
|
+
}
|
554
|
+
|
555
|
+
/*******************************************************************/
|
556
|
+
/* LongIntegerToString: Converts long integer to KB string format. */
|
557
|
+
/*******************************************************************/
|
558
|
+
const char *LongIntegerToString(
|
559
|
+
Environment *theEnv,
|
560
|
+
long long number)
|
561
|
+
{
|
562
|
+
char buffer[50];
|
563
|
+
CLIPSLexeme *thePtr;
|
564
|
+
|
565
|
+
gensnprintf(buffer,sizeof(buffer),"%lld",number);
|
566
|
+
|
567
|
+
thePtr = CreateString(theEnv,buffer);
|
568
|
+
return thePtr->contents;
|
569
|
+
}
|
570
|
+
|
571
|
+
/******************************************************************/
|
572
|
+
/* DataObjectToString: Converts a UDFValue to KB string format. */
|
573
|
+
/******************************************************************/
|
574
|
+
const char *DataObjectToString(
|
575
|
+
Environment *theEnv,
|
576
|
+
UDFValue *theDO)
|
577
|
+
{
|
578
|
+
CLIPSLexeme *thePtr;
|
579
|
+
const char *theString;
|
580
|
+
char *newString;
|
581
|
+
const char *prefix, *postfix;
|
582
|
+
size_t length;
|
583
|
+
CLIPSExternalAddress *theAddress;
|
584
|
+
StringBuilder *theSB;
|
585
|
+
|
586
|
+
char buffer[30];
|
587
|
+
|
588
|
+
switch (theDO->header->type)
|
589
|
+
{
|
590
|
+
case MULTIFIELD_TYPE:
|
591
|
+
prefix = "(";
|
592
|
+
theString = ImplodeMultifield(theEnv,theDO)->contents;
|
593
|
+
postfix = ")";
|
594
|
+
break;
|
595
|
+
|
596
|
+
case STRING_TYPE:
|
597
|
+
prefix = "\"";
|
598
|
+
theString = theDO->lexemeValue->contents;
|
599
|
+
postfix = "\"";
|
600
|
+
break;
|
601
|
+
|
602
|
+
case INSTANCE_NAME_TYPE:
|
603
|
+
prefix = "[";
|
604
|
+
theString = theDO->lexemeValue->contents;
|
605
|
+
postfix = "]";
|
606
|
+
break;
|
607
|
+
|
608
|
+
case SYMBOL_TYPE:
|
609
|
+
return theDO->lexemeValue->contents;
|
610
|
+
|
611
|
+
case FLOAT_TYPE:
|
612
|
+
return(FloatToString(theEnv,theDO->floatValue->contents));
|
613
|
+
|
614
|
+
case INTEGER_TYPE:
|
615
|
+
return(LongIntegerToString(theEnv,theDO->integerValue->contents));
|
616
|
+
|
617
|
+
case VOID_TYPE:
|
618
|
+
return("");
|
619
|
+
|
620
|
+
#if OBJECT_SYSTEM
|
621
|
+
case INSTANCE_ADDRESS_TYPE:
|
622
|
+
if (theDO->instanceValue == &InstanceData(theEnv)->DummyInstance)
|
623
|
+
{ return("<Dummy Instance>"); }
|
624
|
+
|
625
|
+
if (theDO->instanceValue->garbage)
|
626
|
+
{
|
627
|
+
prefix = "<Stale Instance-";
|
628
|
+
theString = theDO->instanceValue->name->contents;
|
629
|
+
postfix = ">";
|
630
|
+
}
|
631
|
+
else
|
632
|
+
{
|
633
|
+
prefix = "<Instance-";
|
634
|
+
theString = GetFullInstanceName(theEnv,theDO->instanceValue)->contents;
|
635
|
+
postfix = ">";
|
636
|
+
}
|
637
|
+
|
638
|
+
break;
|
639
|
+
#endif
|
640
|
+
|
641
|
+
case EXTERNAL_ADDRESS_TYPE:
|
642
|
+
theAddress = theDO->externalAddressValue;
|
643
|
+
|
644
|
+
theSB = CreateStringBuilder(theEnv,30);
|
645
|
+
|
646
|
+
OpenStringBuilderDestination(theEnv,"DOTS",theSB);
|
647
|
+
|
648
|
+
if ((EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type] != NULL) &&
|
649
|
+
(EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction != NULL))
|
650
|
+
{ (*EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction)(theEnv,"DOTS",theAddress); }
|
651
|
+
else
|
652
|
+
{
|
653
|
+
WriteString(theEnv,"DOTS","<Pointer-");
|
654
|
+
|
655
|
+
gensnprintf(buffer,sizeof(buffer),"%d-",theAddress->type);
|
656
|
+
WriteString(theEnv,"DOTS",buffer);
|
657
|
+
|
658
|
+
gensnprintf(buffer,sizeof(buffer),"%p",theAddress->contents);
|
659
|
+
WriteString(theEnv,"DOTS",buffer);
|
660
|
+
WriteString(theEnv,"DOTS",">");
|
661
|
+
}
|
662
|
+
|
663
|
+
thePtr = CreateString(theEnv,theSB->contents);
|
664
|
+
SBDispose(theSB);
|
665
|
+
|
666
|
+
CloseStringBuilderDestination(theEnv,"DOTS");
|
667
|
+
return thePtr->contents;
|
668
|
+
|
669
|
+
#if DEFTEMPLATE_CONSTRUCT
|
670
|
+
case FACT_ADDRESS_TYPE:
|
671
|
+
if (theDO->factValue == &FactData(theEnv)->DummyFact)
|
672
|
+
{ return("<Dummy Fact>"); }
|
673
|
+
|
674
|
+
gensnprintf(buffer,sizeof(buffer),"<Fact-%lld>",theDO->factValue->factIndex);
|
675
|
+
thePtr = CreateString(theEnv,buffer);
|
676
|
+
return thePtr->contents;
|
677
|
+
#endif
|
678
|
+
|
679
|
+
default:
|
680
|
+
return("UNK");
|
681
|
+
}
|
682
|
+
|
683
|
+
length = strlen(prefix) + strlen(theString) + strlen(postfix) + 1;
|
684
|
+
newString = (char *) genalloc(theEnv,length);
|
685
|
+
newString[0] = '\0';
|
686
|
+
genstrcat(newString,prefix);
|
687
|
+
genstrcat(newString,theString);
|
688
|
+
genstrcat(newString,postfix);
|
689
|
+
thePtr = CreateString(theEnv,newString);
|
690
|
+
genfree(theEnv,newString,length);
|
691
|
+
return thePtr->contents;
|
692
|
+
}
|
693
|
+
|
694
|
+
/************************************************************/
|
695
|
+
/* SalienceInformationError: Error message for errors which */
|
696
|
+
/* occur during the evaluation of a salience value. */
|
697
|
+
/************************************************************/
|
698
|
+
void SalienceInformationError(
|
699
|
+
Environment *theEnv,
|
700
|
+
const char *constructType,
|
701
|
+
const char *constructName)
|
702
|
+
{
|
703
|
+
PrintErrorID(theEnv,"PRNTUTIL",8,true);
|
704
|
+
WriteString(theEnv,STDERR,"This error occurred while evaluating the salience");
|
705
|
+
if (constructName != NULL)
|
706
|
+
{
|
707
|
+
WriteString(theEnv,STDERR," for ");
|
708
|
+
WriteString(theEnv,STDERR,constructType);
|
709
|
+
WriteString(theEnv,STDERR," '");
|
710
|
+
WriteString(theEnv,STDERR,constructName);
|
711
|
+
WriteString(theEnv,STDERR,"'");
|
712
|
+
}
|
713
|
+
WriteString(theEnv,STDERR,".\n");
|
714
|
+
}
|
715
|
+
|
716
|
+
/**********************************************************/
|
717
|
+
/* SalienceRangeError: Error message that is printed when */
|
718
|
+
/* a salience value does not fall between the minimum */
|
719
|
+
/* and maximum salience values. */
|
720
|
+
/**********************************************************/
|
721
|
+
void SalienceRangeError(
|
722
|
+
Environment *theEnv,
|
723
|
+
int min,
|
724
|
+
int max)
|
725
|
+
{
|
726
|
+
PrintErrorID(theEnv,"PRNTUTIL",9,true);
|
727
|
+
WriteString(theEnv,STDERR,"Salience value out of range ");
|
728
|
+
WriteInteger(theEnv,STDERR,min);
|
729
|
+
WriteString(theEnv,STDERR," to ");
|
730
|
+
WriteInteger(theEnv,STDERR,max);
|
731
|
+
WriteString(theEnv,STDERR,".\n");
|
732
|
+
}
|
733
|
+
|
734
|
+
/***************************************************************/
|
735
|
+
/* SalienceNonIntegerError: Error message that is printed when */
|
736
|
+
/* a rule's salience does not evaluate to an integer. */
|
737
|
+
/***************************************************************/
|
738
|
+
void SalienceNonIntegerError(
|
739
|
+
Environment *theEnv)
|
740
|
+
{
|
741
|
+
PrintErrorID(theEnv,"PRNTUTIL",10,true);
|
742
|
+
WriteString(theEnv,STDERR,"Salience value must be an integer value.\n");
|
743
|
+
}
|
744
|
+
|
745
|
+
/****************************************************/
|
746
|
+
/* FactRetractedErrorMessage: Generic error message */
|
747
|
+
/* when a fact has been retracted. */
|
748
|
+
/****************************************************/
|
749
|
+
void FactRetractedErrorMessage(
|
750
|
+
Environment *theEnv,
|
751
|
+
Fact *theFact)
|
752
|
+
{
|
753
|
+
char tempBuffer[20];
|
754
|
+
|
755
|
+
PrintErrorID(theEnv,"PRNTUTIL",11,false);
|
756
|
+
WriteString(theEnv,STDERR,"The fact ");
|
757
|
+
gensnprintf(tempBuffer,sizeof(tempBuffer),"f-%lld",theFact->factIndex);
|
758
|
+
WriteString(theEnv,STDERR,tempBuffer);
|
759
|
+
WriteString(theEnv,STDERR," has been retracted.\n");
|
760
|
+
}
|
761
|
+
|
762
|
+
/****************************************************/
|
763
|
+
/* FactVarSlotErrorMessage1: Generic error message */
|
764
|
+
/* when a var/slot reference accesses a fact that */
|
765
|
+
/* has been retracted. */
|
766
|
+
/****************************************************/
|
767
|
+
void FactVarSlotErrorMessage1(
|
768
|
+
Environment *theEnv,
|
769
|
+
Fact *theFact,
|
770
|
+
const char *varSlot)
|
771
|
+
{
|
772
|
+
char tempBuffer[20];
|
773
|
+
|
774
|
+
PrintErrorID(theEnv,"PRNTUTIL",12,false);
|
775
|
+
|
776
|
+
WriteString(theEnv,STDERR,"The variable/slot reference ?");
|
777
|
+
WriteString(theEnv,STDERR,varSlot);
|
778
|
+
WriteString(theEnv,STDERR," cannot be resolved because the referenced fact ");
|
779
|
+
gensnprintf(tempBuffer,sizeof(tempBuffer),"f-%lld",theFact->factIndex);
|
780
|
+
WriteString(theEnv,STDERR,tempBuffer);
|
781
|
+
WriteString(theEnv,STDERR," has been retracted.\n");
|
782
|
+
}
|
783
|
+
|
784
|
+
/****************************************************/
|
785
|
+
/* FactVarSlotErrorMessage2: Generic error message */
|
786
|
+
/* when a var/slot reference accesses an invalid */
|
787
|
+
/* slot. */
|
788
|
+
/****************************************************/
|
789
|
+
void FactVarSlotErrorMessage2(
|
790
|
+
Environment *theEnv,
|
791
|
+
Fact *theFact,
|
792
|
+
const char *varSlot)
|
793
|
+
{
|
794
|
+
char tempBuffer[20];
|
795
|
+
|
796
|
+
PrintErrorID(theEnv,"PRNTUTIL",13,false);
|
797
|
+
|
798
|
+
WriteString(theEnv,STDERR,"The variable/slot reference ?");
|
799
|
+
WriteString(theEnv,STDERR,varSlot);
|
800
|
+
WriteString(theEnv,STDERR," is invalid because the referenced fact ");
|
801
|
+
gensnprintf(tempBuffer,sizeof(tempBuffer),"f-%lld",theFact->factIndex);
|
802
|
+
WriteString(theEnv,STDERR,tempBuffer);
|
803
|
+
WriteString(theEnv,STDERR," does not contain the specified slot.\n");
|
804
|
+
}
|
805
|
+
|
806
|
+
/******************************************************/
|
807
|
+
/* InvalidVarSlotErrorMessage: Generic error message */
|
808
|
+
/* when a var/slot reference accesses an invalid */
|
809
|
+
/* slot. */
|
810
|
+
/******************************************************/
|
811
|
+
void InvalidVarSlotErrorMessage(
|
812
|
+
Environment *theEnv,
|
813
|
+
const char *varSlot)
|
814
|
+
{
|
815
|
+
PrintErrorID(theEnv,"PRNTUTIL",14,false);
|
816
|
+
|
817
|
+
WriteString(theEnv,STDERR,"The variable/slot reference ?");
|
818
|
+
WriteString(theEnv,STDERR,varSlot);
|
819
|
+
WriteString(theEnv,STDERR," is invalid because slot names must be symbols.\n");
|
820
|
+
}
|
821
|
+
|
822
|
+
/*******************************************************/
|
823
|
+
/* InstanceVarSlotErrorMessage1: Generic error message */
|
824
|
+
/* when a var/slot reference accesses an instance */
|
825
|
+
/* that has been deleted. */
|
826
|
+
/*******************************************************/
|
827
|
+
void InstanceVarSlotErrorMessage1(
|
828
|
+
Environment *theEnv,
|
829
|
+
Instance *theInstance,
|
830
|
+
const char *varSlot)
|
831
|
+
{
|
832
|
+
PrintErrorID(theEnv,"PRNTUTIL",15,false);
|
833
|
+
|
834
|
+
WriteString(theEnv,STDERR,"The variable/slot reference ?");
|
835
|
+
WriteString(theEnv,STDERR,varSlot);
|
836
|
+
WriteString(theEnv,STDERR," cannot be resolved because the referenced instance [");
|
837
|
+
WriteString(theEnv,STDERR,theInstance->name->contents);
|
838
|
+
WriteString(theEnv,STDERR,"] has been deleted.\n");
|
839
|
+
}
|
840
|
+
|
841
|
+
/************************************************/
|
842
|
+
/* InstanceVarSlotErrorMessage2: Generic error */
|
843
|
+
/* message when a var/slot reference accesses */
|
844
|
+
/* an invalid slot. */
|
845
|
+
/************************************************/
|
846
|
+
void InstanceVarSlotErrorMessage2(
|
847
|
+
Environment *theEnv,
|
848
|
+
Instance *theInstance,
|
849
|
+
const char *varSlot)
|
850
|
+
{
|
851
|
+
PrintErrorID(theEnv,"PRNTUTIL",16,false);
|
852
|
+
|
853
|
+
WriteString(theEnv,STDERR,"The variable/slot reference ?");
|
854
|
+
WriteString(theEnv,STDERR,varSlot);
|
855
|
+
WriteString(theEnv,STDERR," is invalid because the referenced instance [");
|
856
|
+
WriteString(theEnv,STDERR,theInstance->name->contents);
|
857
|
+
WriteString(theEnv,STDERR,"] does not contain the specified slot.\n");
|
858
|
+
}
|
859
|
+
|
860
|
+
/***************************************************/
|
861
|
+
/* SlotExistError: Prints out an appropriate error */
|
862
|
+
/* message when a slot cannot be found for a */
|
863
|
+
/* function. Input to the function is the slot */
|
864
|
+
/* name and the function name. */
|
865
|
+
/***************************************************/
|
866
|
+
void SlotExistError(
|
867
|
+
Environment *theEnv,
|
868
|
+
const char *sname,
|
869
|
+
const char *func)
|
870
|
+
{
|
871
|
+
PrintErrorID(theEnv,"INSFUN",3,false);
|
872
|
+
WriteString(theEnv,STDERR,"No such slot '");
|
873
|
+
WriteString(theEnv,STDERR,sname);
|
874
|
+
WriteString(theEnv,STDERR,"' in function '");
|
875
|
+
WriteString(theEnv,STDERR,func);
|
876
|
+
WriteString(theEnv,STDERR,"'.\n");
|
877
|
+
SetEvaluationError(theEnv,true);
|
878
|
+
}
|