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,835 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 11/13/17 */
|
5
|
+
/* */
|
6
|
+
/* CONSTRUCT PARSER MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Parsing routines and utilities for parsing */
|
11
|
+
/* constructs. */
|
12
|
+
/* */
|
13
|
+
/* Principal Programmer(s): */
|
14
|
+
/* Gary D. Riley */
|
15
|
+
/* */
|
16
|
+
/* Contributing Programmer(s): */
|
17
|
+
/* */
|
18
|
+
/* Revision History: */
|
19
|
+
/* */
|
20
|
+
/* 6.24: Added environment parameter to GenClose. */
|
21
|
+
/* Added environment parameter to GenOpen. */
|
22
|
+
/* */
|
23
|
+
/* Made the construct redefinition message more */
|
24
|
+
/* prominent. */
|
25
|
+
/* */
|
26
|
+
/* Added pragmas to remove compilation warnings. */
|
27
|
+
/* */
|
28
|
+
/* 6.30: Added code for capturing errors/warnings. */
|
29
|
+
/* */
|
30
|
+
/* Removed conditional code for unsupported */
|
31
|
+
/* compilers/operating systems (IBM_MCW, MAC_MCW, */
|
32
|
+
/* and IBM_TBC). */
|
33
|
+
/* */
|
34
|
+
/* Changed garbage collection algorithm. */
|
35
|
+
/* */
|
36
|
+
/* GetConstructNameAndComment API change. */
|
37
|
+
/* */
|
38
|
+
/* Added const qualifiers to remove C++ */
|
39
|
+
/* deprecation warnings. */
|
40
|
+
/* */
|
41
|
+
/* Fixed linkage issue when BLOAD_ONLY compiler */
|
42
|
+
/* flag is set to 1. */
|
43
|
+
/* */
|
44
|
+
/* 6.40: Added Env prefix to GetEvaluationError and */
|
45
|
+
/* SetEvaluationError functions. */
|
46
|
+
/* */
|
47
|
+
/* Added Env prefix to GetHaltExecution and */
|
48
|
+
/* SetHaltExecution functions. */
|
49
|
+
/* */
|
50
|
+
/* Pragma once and other inclusion changes. */
|
51
|
+
/* */
|
52
|
+
/* Added support for booleans with <stdbool.h>. */
|
53
|
+
/* */
|
54
|
+
/* Changed return values for router functions. */
|
55
|
+
/* */
|
56
|
+
/* Removed use of void pointers for specific */
|
57
|
+
/* data structures. */
|
58
|
+
/* */
|
59
|
+
/* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
|
60
|
+
/* */
|
61
|
+
/* Added GCBlockStart and GCBlockEnd functions */
|
62
|
+
/* for garbage collection blocks. */
|
63
|
+
/* */
|
64
|
+
/* File name/line count displayed for errors */
|
65
|
+
/* and warnings during load command. */
|
66
|
+
/* */
|
67
|
+
/*************************************************************/
|
68
|
+
|
69
|
+
#include "setup.h"
|
70
|
+
|
71
|
+
#if (! RUN_TIME) && (! BLOAD_ONLY)
|
72
|
+
|
73
|
+
#include <stdio.h>
|
74
|
+
#include <stdlib.h>
|
75
|
+
#include <string.h>
|
76
|
+
|
77
|
+
#include "envrnmnt.h"
|
78
|
+
#include "router.h"
|
79
|
+
#include "watch.h"
|
80
|
+
#include "constrct.h"
|
81
|
+
#include "prcdrpsr.h"
|
82
|
+
#include "exprnpsr.h"
|
83
|
+
#include "memalloc.h"
|
84
|
+
#include "modulutl.h"
|
85
|
+
#include "modulpsr.h"
|
86
|
+
#include "pprint.h"
|
87
|
+
#include "prntutil.h"
|
88
|
+
#include "strngrtr.h"
|
89
|
+
#include "sysdep.h"
|
90
|
+
#include "utility.h"
|
91
|
+
|
92
|
+
#include "cstrcpsr.h"
|
93
|
+
|
94
|
+
/***************************************/
|
95
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
96
|
+
/***************************************/
|
97
|
+
|
98
|
+
static bool FindConstructBeginning(Environment *,const char *,struct token *,bool,bool *);
|
99
|
+
|
100
|
+
/**********************************************************/
|
101
|
+
/* Load: C access routine for the load command. Returns */
|
102
|
+
/* LE_OPEN_FILE_ERROR if the file couldn't be opened, */
|
103
|
+
/* LE_PARSING_ERROR if the file was opened but an error */
|
104
|
+
/* occurred while loading constructs, and LE_NO_ERROR */
|
105
|
+
/* if the file was opened and no errors occured while */
|
106
|
+
/* loading. */
|
107
|
+
/**********************************************************/
|
108
|
+
LoadError Load(
|
109
|
+
Environment *theEnv,
|
110
|
+
const char *fileName)
|
111
|
+
{
|
112
|
+
FILE *theFile;
|
113
|
+
char *oldParsingFileName;
|
114
|
+
int noErrorsDetected;
|
115
|
+
|
116
|
+
/*=======================================*/
|
117
|
+
/* Open the file specified by file name. */
|
118
|
+
/*=======================================*/
|
119
|
+
|
120
|
+
if ((theFile = GenOpen(theEnv,fileName,"r")) == NULL)
|
121
|
+
{ return LE_OPEN_FILE_ERROR; }
|
122
|
+
|
123
|
+
/*===================================================*/
|
124
|
+
/* Read in the constructs. Enabling fast load allows */
|
125
|
+
/* the router system to be bypassed for quicker load */
|
126
|
+
/* times. */
|
127
|
+
/*===================================================*/
|
128
|
+
|
129
|
+
SetFastLoad(theEnv,theFile);
|
130
|
+
|
131
|
+
oldParsingFileName = CopyString(theEnv,GetParsingFileName(theEnv));
|
132
|
+
SetParsingFileName(theEnv,fileName);
|
133
|
+
|
134
|
+
SetLoadInProgress(theEnv,true);
|
135
|
+
noErrorsDetected = LoadConstructsFromLogicalName(theEnv,(char *) theFile);
|
136
|
+
SetLoadInProgress(theEnv,false);
|
137
|
+
|
138
|
+
SetParsingFileName(theEnv,oldParsingFileName);
|
139
|
+
DeleteString(theEnv,oldParsingFileName);
|
140
|
+
|
141
|
+
SetWarningFileName(theEnv,NULL);
|
142
|
+
SetErrorFileName(theEnv,NULL);
|
143
|
+
|
144
|
+
SetFastLoad(theEnv,NULL);
|
145
|
+
|
146
|
+
/*=================*/
|
147
|
+
/* Close the file. */
|
148
|
+
/*=================*/
|
149
|
+
|
150
|
+
GenClose(theEnv,theFile);
|
151
|
+
|
152
|
+
/*=================================================*/
|
153
|
+
/* If no errors occurred during the load, return */
|
154
|
+
/* LE_NO_ERROR, otherwise return LE_PARSING_ERROR. */
|
155
|
+
/*=================================================*/
|
156
|
+
|
157
|
+
if (noErrorsDetected)
|
158
|
+
{ return LE_NO_ERROR; }
|
159
|
+
|
160
|
+
return LE_PARSING_ERROR;
|
161
|
+
}
|
162
|
+
|
163
|
+
/*******************/
|
164
|
+
/* LoadFromString: */
|
165
|
+
/*******************/
|
166
|
+
bool LoadFromString(
|
167
|
+
Environment *theEnv,
|
168
|
+
const char *theString,
|
169
|
+
size_t theMax)
|
170
|
+
{
|
171
|
+
bool rv;
|
172
|
+
const char *theStrRouter = "*** load-from-string ***";
|
173
|
+
|
174
|
+
/*==========================*/
|
175
|
+
/* Initialize string router */
|
176
|
+
/*==========================*/
|
177
|
+
|
178
|
+
if ((theMax == SIZE_MAX) ? (! OpenStringSource(theEnv,theStrRouter,theString,0)) :
|
179
|
+
(! OpenTextSource(theEnv,theStrRouter,theString,0,theMax)))
|
180
|
+
return false;
|
181
|
+
|
182
|
+
/*======================*/
|
183
|
+
/* Load the constructs. */
|
184
|
+
/*======================*/
|
185
|
+
|
186
|
+
rv = LoadConstructsFromLogicalName(theEnv,theStrRouter);
|
187
|
+
|
188
|
+
/*=================*/
|
189
|
+
/* Close router. */
|
190
|
+
/*=================*/
|
191
|
+
|
192
|
+
CloseStringSource(theEnv,theStrRouter);
|
193
|
+
|
194
|
+
return rv;
|
195
|
+
}
|
196
|
+
|
197
|
+
/****************************************************/
|
198
|
+
/* SetParsingFileName: Sets the file name currently */
|
199
|
+
/* being parsed by the load/batch command. */
|
200
|
+
/****************************************************/
|
201
|
+
void SetParsingFileName(
|
202
|
+
Environment *theEnv,
|
203
|
+
const char *fileName)
|
204
|
+
{
|
205
|
+
char *fileNameCopy = NULL;
|
206
|
+
|
207
|
+
if (fileName != NULL)
|
208
|
+
{
|
209
|
+
fileNameCopy = (char *) genalloc(theEnv,strlen(fileName) + 1);
|
210
|
+
genstrcpy(fileNameCopy,fileName);
|
211
|
+
}
|
212
|
+
|
213
|
+
if (ConstructData(theEnv)->ParsingFileName != NULL)
|
214
|
+
{ genfree(theEnv,ConstructData(theEnv)->ParsingFileName,strlen(ConstructData(theEnv)->ParsingFileName) + 1); }
|
215
|
+
|
216
|
+
ConstructData(theEnv)->ParsingFileName = fileNameCopy;
|
217
|
+
}
|
218
|
+
|
219
|
+
/*******************************************************/
|
220
|
+
/* GetParsingFileName: Returns the file name currently */
|
221
|
+
/* being parsed by the load/batch command. */
|
222
|
+
/*******************************************************/
|
223
|
+
char *GetParsingFileName(
|
224
|
+
Environment *theEnv)
|
225
|
+
{
|
226
|
+
return ConstructData(theEnv)->ParsingFileName;
|
227
|
+
}
|
228
|
+
|
229
|
+
/**********************************************/
|
230
|
+
/* SetErrorFileName: Sets the file name */
|
231
|
+
/* associated with the last error detected. */
|
232
|
+
/**********************************************/
|
233
|
+
void SetErrorFileName(
|
234
|
+
Environment *theEnv,
|
235
|
+
const char *fileName)
|
236
|
+
{
|
237
|
+
char *fileNameCopy = NULL;
|
238
|
+
|
239
|
+
if (fileName != NULL)
|
240
|
+
{
|
241
|
+
fileNameCopy = (char *) genalloc(theEnv,strlen(fileName) + 1);
|
242
|
+
genstrcpy(fileNameCopy,fileName);
|
243
|
+
}
|
244
|
+
|
245
|
+
if (ConstructData(theEnv)->ErrorFileName != NULL)
|
246
|
+
{ genfree(theEnv,ConstructData(theEnv)->ErrorFileName,strlen(ConstructData(theEnv)->ErrorFileName) + 1); }
|
247
|
+
|
248
|
+
ConstructData(theEnv)->ErrorFileName = fileNameCopy;
|
249
|
+
}
|
250
|
+
|
251
|
+
/**********************************************/
|
252
|
+
/* GetErrorFileName: Returns the file name */
|
253
|
+
/* associated with the last error detected. */
|
254
|
+
/**********************************************/
|
255
|
+
char *GetErrorFileName(
|
256
|
+
Environment *theEnv)
|
257
|
+
{
|
258
|
+
return ConstructData(theEnv)->ErrorFileName;
|
259
|
+
}
|
260
|
+
|
261
|
+
/************************************************/
|
262
|
+
/* SetWarningFileName: Sets the file name */
|
263
|
+
/* associated with the last warning detected. */
|
264
|
+
/************************************************/
|
265
|
+
void SetWarningFileName(
|
266
|
+
Environment *theEnv,
|
267
|
+
const char *fileName)
|
268
|
+
{
|
269
|
+
char *fileNameCopy = NULL;
|
270
|
+
|
271
|
+
if (fileName != NULL)
|
272
|
+
{
|
273
|
+
fileNameCopy = (char *) genalloc(theEnv,strlen(fileName) + 1);
|
274
|
+
genstrcpy(fileNameCopy,fileName);
|
275
|
+
}
|
276
|
+
|
277
|
+
if (ConstructData(theEnv)->WarningFileName != NULL)
|
278
|
+
{ genfree(theEnv,ConstructData(theEnv)->WarningFileName,strlen(ConstructData(theEnv)->WarningFileName) + 1); }
|
279
|
+
|
280
|
+
ConstructData(theEnv)->WarningFileName = fileNameCopy;
|
281
|
+
}
|
282
|
+
|
283
|
+
/************************************************/
|
284
|
+
/* GetWarningFileName: Returns the file name */
|
285
|
+
/* associated with the last warning detected. */
|
286
|
+
/************************************************/
|
287
|
+
char *GetWarningFileName(
|
288
|
+
Environment *theEnv)
|
289
|
+
{
|
290
|
+
return ConstructData(theEnv)->WarningFileName;
|
291
|
+
}
|
292
|
+
|
293
|
+
/*****************************************************************/
|
294
|
+
/* LoadConstructsFromLogicalName: Loads a set of constructs into */
|
295
|
+
/* the current environment from a specified logical name. */
|
296
|
+
/*****************************************************************/
|
297
|
+
bool LoadConstructsFromLogicalName(
|
298
|
+
Environment *theEnv,
|
299
|
+
const char *readSource)
|
300
|
+
{
|
301
|
+
BuildError constructFlag;
|
302
|
+
struct token theToken;
|
303
|
+
bool noErrors = true;
|
304
|
+
bool foundConstruct;
|
305
|
+
GCBlock gcb;
|
306
|
+
long oldLineCountValue;
|
307
|
+
const char *oldLineCountRouter;
|
308
|
+
|
309
|
+
/*===================================================*/
|
310
|
+
/* Create a router to capture the error information. */
|
311
|
+
/*===================================================*/
|
312
|
+
|
313
|
+
CreateErrorCaptureRouter(theEnv);
|
314
|
+
|
315
|
+
/*==============================*/
|
316
|
+
/* Initialize the line counter. */
|
317
|
+
/*==============================*/
|
318
|
+
|
319
|
+
oldLineCountValue = SetLineCount(theEnv,1);
|
320
|
+
oldLineCountRouter = RouterData(theEnv)->LineCountRouter;
|
321
|
+
RouterData(theEnv)->LineCountRouter = readSource;
|
322
|
+
|
323
|
+
/*=====================================*/
|
324
|
+
/* If embedded, clear the error flags. */
|
325
|
+
/*=====================================*/
|
326
|
+
|
327
|
+
if (EvaluationData(theEnv)->CurrentExpression == NULL)
|
328
|
+
{ ResetErrorFlags(theEnv); }
|
329
|
+
|
330
|
+
/*==========================================*/
|
331
|
+
/* Set up the frame for garbage collection. */
|
332
|
+
/*==========================================*/
|
333
|
+
|
334
|
+
GCBlockStart(theEnv,&gcb);
|
335
|
+
|
336
|
+
/*========================================================*/
|
337
|
+
/* Find the beginning of the first construct in the file. */
|
338
|
+
/*========================================================*/
|
339
|
+
|
340
|
+
GetToken(theEnv,readSource,&theToken);
|
341
|
+
foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,false,&noErrors);
|
342
|
+
|
343
|
+
/*==================================================*/
|
344
|
+
/* Parse the file until the end of file is reached. */
|
345
|
+
/*==================================================*/
|
346
|
+
|
347
|
+
while ((foundConstruct == true) && (GetHaltExecution(theEnv) == false))
|
348
|
+
{
|
349
|
+
/*===========================================================*/
|
350
|
+
/* Clear the pretty print buffer in preparation for parsing. */
|
351
|
+
/*===========================================================*/
|
352
|
+
|
353
|
+
FlushPPBuffer(theEnv);
|
354
|
+
|
355
|
+
/*======================*/
|
356
|
+
/* Parse the construct. */
|
357
|
+
/*======================*/
|
358
|
+
|
359
|
+
constructFlag = ParseConstruct(theEnv,theToken.lexemeValue->contents,readSource);
|
360
|
+
|
361
|
+
/*==============================================================*/
|
362
|
+
/* If an error occurred while parsing, then find the beginning */
|
363
|
+
/* of the next construct (but don't generate any more error */
|
364
|
+
/* messages--in effect, skip everything until another construct */
|
365
|
+
/* is found). */
|
366
|
+
/*==============================================================*/
|
367
|
+
|
368
|
+
if (constructFlag == BE_PARSING_ERROR)
|
369
|
+
{
|
370
|
+
WriteString(theEnv,STDERR,"\nERROR:\n");
|
371
|
+
WriteString(theEnv,STDERR,GetPPBuffer(theEnv));
|
372
|
+
WriteString(theEnv,STDERR,"\n");
|
373
|
+
|
374
|
+
FlushParsingMessages(theEnv);
|
375
|
+
|
376
|
+
noErrors = false;
|
377
|
+
GetToken(theEnv,readSource,&theToken);
|
378
|
+
foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,true,&noErrors);
|
379
|
+
}
|
380
|
+
|
381
|
+
/*======================================================*/
|
382
|
+
/* Otherwise, find the beginning of the next construct. */
|
383
|
+
/*======================================================*/
|
384
|
+
|
385
|
+
else
|
386
|
+
{
|
387
|
+
FlushParsingMessages(theEnv);
|
388
|
+
GetToken(theEnv,readSource,&theToken);
|
389
|
+
foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,false,&noErrors);
|
390
|
+
}
|
391
|
+
|
392
|
+
/*=====================================================*/
|
393
|
+
/* Yield time if necessary to foreground applications. */
|
394
|
+
/*=====================================================*/
|
395
|
+
|
396
|
+
if (foundConstruct)
|
397
|
+
{ IncrementLexemeCount(theToken.value); }
|
398
|
+
|
399
|
+
CleanCurrentGarbageFrame(theEnv,NULL);
|
400
|
+
CallPeriodicTasks(theEnv);
|
401
|
+
|
402
|
+
YieldTime(theEnv);
|
403
|
+
|
404
|
+
if (foundConstruct)
|
405
|
+
{ ReleaseLexeme(theEnv,theToken.lexemeValue); }
|
406
|
+
}
|
407
|
+
|
408
|
+
/*========================================================*/
|
409
|
+
/* Print a carriage return if a single character is being */
|
410
|
+
/* printed to indicate constructs are being processed. */
|
411
|
+
/*========================================================*/
|
412
|
+
|
413
|
+
#if DEBUGGING_FUNCTIONS
|
414
|
+
if ((GetWatchItem(theEnv,"compilations") != 1) && GetPrintWhileLoading(theEnv))
|
415
|
+
#else
|
416
|
+
if (GetPrintWhileLoading(theEnv))
|
417
|
+
#endif
|
418
|
+
{ WriteString(theEnv,STDOUT,"\n"); }
|
419
|
+
|
420
|
+
/*=============================================================*/
|
421
|
+
/* Once the load is complete, destroy the pretty print buffer. */
|
422
|
+
/* This frees up any memory that was used to create the pretty */
|
423
|
+
/* print forms for constructs during parsing. Thus calls to */
|
424
|
+
/* the mem-used function will accurately reflect the amount of */
|
425
|
+
/* memory being used after a load command. */
|
426
|
+
/*=============================================================*/
|
427
|
+
|
428
|
+
DestroyPPBuffer(theEnv);
|
429
|
+
|
430
|
+
/*======================================*/
|
431
|
+
/* Remove the garbage collection frame. */
|
432
|
+
/*======================================*/
|
433
|
+
|
434
|
+
GCBlockEnd(theEnv,&gcb);
|
435
|
+
CallPeriodicTasks(theEnv);
|
436
|
+
|
437
|
+
/*==============================*/
|
438
|
+
/* Deactivate the line counter. */
|
439
|
+
/*==============================*/
|
440
|
+
|
441
|
+
SetLineCount(theEnv,oldLineCountValue);
|
442
|
+
RouterData(theEnv)->LineCountRouter = oldLineCountRouter;
|
443
|
+
|
444
|
+
/*===========================================*/
|
445
|
+
/* Invoke the parser error callback function */
|
446
|
+
/* and delete the error capture router. */
|
447
|
+
/*===========================================*/
|
448
|
+
|
449
|
+
FlushParsingMessages(theEnv);
|
450
|
+
DeleteErrorCaptureRouter(theEnv);
|
451
|
+
|
452
|
+
/*==========================================================*/
|
453
|
+
/* Return a boolean flag which indicates whether any errors */
|
454
|
+
/* were encountered while loading the constructs. */
|
455
|
+
/*==========================================================*/
|
456
|
+
|
457
|
+
return noErrors;
|
458
|
+
}
|
459
|
+
|
460
|
+
/********************************************************************/
|
461
|
+
/* FindConstructBeginning: Searches for a left parenthesis followed */
|
462
|
+
/* by the name of a valid construct. Used by the load command to */
|
463
|
+
/* find the next construct to be parsed. Returns true is the */
|
464
|
+
/* beginning of a construct was found, otherwise false. */
|
465
|
+
/********************************************************************/
|
466
|
+
static bool FindConstructBeginning(
|
467
|
+
Environment *theEnv,
|
468
|
+
const char *readSource,
|
469
|
+
struct token *theToken,
|
470
|
+
bool errorCorrection,
|
471
|
+
bool *noErrors)
|
472
|
+
{
|
473
|
+
bool leftParenthesisFound = false;
|
474
|
+
bool firstAttempt = true;
|
475
|
+
|
476
|
+
/*===================================================*/
|
477
|
+
/* Process tokens until the beginning of a construct */
|
478
|
+
/* is found or there are no more tokens. */
|
479
|
+
/*===================================================*/
|
480
|
+
|
481
|
+
while (theToken->tknType != STOP_TOKEN)
|
482
|
+
{
|
483
|
+
/*=====================================================*/
|
484
|
+
/* Constructs begin with a left parenthesis. Make note */
|
485
|
+
/* that the opening parenthesis has been found. */
|
486
|
+
/*=====================================================*/
|
487
|
+
|
488
|
+
if (theToken->tknType == LEFT_PARENTHESIS_TOKEN)
|
489
|
+
{ leftParenthesisFound = true; }
|
490
|
+
|
491
|
+
/*=================================================================*/
|
492
|
+
/* The name of the construct follows the opening left parenthesis. */
|
493
|
+
/* If it is the name of a valid construct, then return true. */
|
494
|
+
/* Otherwise, reset the flags to look for the beginning of a */
|
495
|
+
/* construct. If error correction is being performed (i.e. the */
|
496
|
+
/* last construct parsed had an error in it), then don't bother to */
|
497
|
+
/* print an error message, otherwise, print an error message. */
|
498
|
+
/*=================================================================*/
|
499
|
+
|
500
|
+
else if ((theToken->tknType == SYMBOL_TOKEN) && (leftParenthesisFound == true))
|
501
|
+
{
|
502
|
+
/*===========================================================*/
|
503
|
+
/* Is this a valid construct name (e.g., defrule, deffacts). */
|
504
|
+
/*===========================================================*/
|
505
|
+
|
506
|
+
if (FindConstruct(theEnv,theToken->lexemeValue->contents) != NULL) return true;
|
507
|
+
|
508
|
+
/*===============================================*/
|
509
|
+
/* The construct name is invalid. Print an error */
|
510
|
+
/* message if one hasn't already been printed. */
|
511
|
+
/*===============================================*/
|
512
|
+
|
513
|
+
if (firstAttempt && (! errorCorrection))
|
514
|
+
{
|
515
|
+
errorCorrection = true;
|
516
|
+
*noErrors = false;
|
517
|
+
PrintErrorID(theEnv,"CSTRCPSR",1,true);
|
518
|
+
WriteString(theEnv,STDERR,"Expected the beginning of a construct.\n");
|
519
|
+
}
|
520
|
+
|
521
|
+
/*======================================================*/
|
522
|
+
/* Indicate that an error has been found and that we're */
|
523
|
+
/* looking for a left parenthesis again. */
|
524
|
+
/*======================================================*/
|
525
|
+
|
526
|
+
firstAttempt = false;
|
527
|
+
leftParenthesisFound = false;
|
528
|
+
}
|
529
|
+
|
530
|
+
/*====================================================================*/
|
531
|
+
/* Any token encountered other than a left parenthesis or a construct */
|
532
|
+
/* name following a left parenthesis is illegal. Again, if error */
|
533
|
+
/* correction is in progress, no error message is printed, otherwise, */
|
534
|
+
/* an error message is printed. */
|
535
|
+
/*====================================================================*/
|
536
|
+
|
537
|
+
else
|
538
|
+
{
|
539
|
+
if (firstAttempt && (! errorCorrection))
|
540
|
+
{
|
541
|
+
errorCorrection = true;
|
542
|
+
*noErrors = false;
|
543
|
+
PrintErrorID(theEnv,"CSTRCPSR",1,true);
|
544
|
+
WriteString(theEnv,STDERR,"Expected the beginning of a construct.\n");
|
545
|
+
}
|
546
|
+
|
547
|
+
firstAttempt = false;
|
548
|
+
leftParenthesisFound = false;
|
549
|
+
}
|
550
|
+
|
551
|
+
/*============================================*/
|
552
|
+
/* Move on to the next token to be processed. */
|
553
|
+
/*============================================*/
|
554
|
+
|
555
|
+
GetToken(theEnv,readSource,theToken);
|
556
|
+
}
|
557
|
+
|
558
|
+
/*===================================================================*/
|
559
|
+
/* Couldn't find the beginning of a construct, so false is returned. */
|
560
|
+
/*===================================================================*/
|
561
|
+
|
562
|
+
return false;
|
563
|
+
}
|
564
|
+
|
565
|
+
/***********************************************************/
|
566
|
+
/* QueryErrorCallback: Query routine for the error router. */
|
567
|
+
/***********************************************************/
|
568
|
+
static bool QueryErrorCallback(
|
569
|
+
Environment *theEnv,
|
570
|
+
const char *logicalName,
|
571
|
+
void *context)
|
572
|
+
{
|
573
|
+
#if MAC_XCD
|
574
|
+
#pragma unused(theEnv,context)
|
575
|
+
#endif
|
576
|
+
|
577
|
+
if ((strcmp(logicalName,STDERR) == 0) ||
|
578
|
+
(strcmp(logicalName,STDWRN) == 0))
|
579
|
+
{ return true; }
|
580
|
+
|
581
|
+
return false;
|
582
|
+
}
|
583
|
+
|
584
|
+
/***********************************************************/
|
585
|
+
/* WriteErrorCallback: Write routine for the error router. */
|
586
|
+
/***********************************************************/
|
587
|
+
static void WriteErrorCallback(
|
588
|
+
Environment *theEnv,
|
589
|
+
const char *logicalName,
|
590
|
+
const char *str,
|
591
|
+
void *context)
|
592
|
+
{
|
593
|
+
if (strcmp(logicalName,STDERR) == 0)
|
594
|
+
{
|
595
|
+
ConstructData(theEnv)->ErrorString =
|
596
|
+
AppendToString(theEnv,str,ConstructData(theEnv)->ErrorString,
|
597
|
+
&ConstructData(theEnv)->CurErrPos,
|
598
|
+
&ConstructData(theEnv)->MaxErrChars);
|
599
|
+
}
|
600
|
+
else if (strcmp(logicalName,STDWRN) == 0)
|
601
|
+
{
|
602
|
+
ConstructData(theEnv)->WarningString =
|
603
|
+
AppendToString(theEnv,str,ConstructData(theEnv)->WarningString,
|
604
|
+
&ConstructData(theEnv)->CurWrnPos,
|
605
|
+
&ConstructData(theEnv)->MaxWrnChars);
|
606
|
+
}
|
607
|
+
|
608
|
+
DeactivateRouter(theEnv,"error-capture");
|
609
|
+
WriteString(theEnv,logicalName,str);
|
610
|
+
ActivateRouter(theEnv,"error-capture");
|
611
|
+
}
|
612
|
+
|
613
|
+
/***********************************************/
|
614
|
+
/* CreateErrorCaptureRouter: Creates the error */
|
615
|
+
/* capture router if it doesn't exists. */
|
616
|
+
/***********************************************/
|
617
|
+
void CreateErrorCaptureRouter(
|
618
|
+
Environment *theEnv)
|
619
|
+
{
|
620
|
+
/*===========================================================*/
|
621
|
+
/* Don't bother creating the error capture router if there's */
|
622
|
+
/* no parser callback. The implication of this is that the */
|
623
|
+
/* parser callback should be created before any routines */
|
624
|
+
/* which could generate errors are called. */
|
625
|
+
/*===========================================================*/
|
626
|
+
|
627
|
+
if (ConstructData(theEnv)->ParserErrorCallback == NULL) return;
|
628
|
+
|
629
|
+
/*=======================================================*/
|
630
|
+
/* If the router hasn't already been created, create it. */
|
631
|
+
/*=======================================================*/
|
632
|
+
|
633
|
+
if (ConstructData(theEnv)->errorCaptureRouterCount == 0)
|
634
|
+
{
|
635
|
+
AddRouter(theEnv,"error-capture",40,
|
636
|
+
QueryErrorCallback,WriteErrorCallback,
|
637
|
+
NULL,NULL,NULL,NULL);
|
638
|
+
}
|
639
|
+
|
640
|
+
/*==================================================*/
|
641
|
+
/* Increment the count for the number of references */
|
642
|
+
/* that want the error capture router functioning. */
|
643
|
+
/*==================================================*/
|
644
|
+
|
645
|
+
ConstructData(theEnv)->errorCaptureRouterCount++;
|
646
|
+
}
|
647
|
+
|
648
|
+
/***********************************************/
|
649
|
+
/* DeleteErrorCaptureRouter: Deletes the error */
|
650
|
+
/* capture router if it exists. */
|
651
|
+
/***********************************************/
|
652
|
+
void DeleteErrorCaptureRouter(
|
653
|
+
Environment *theEnv)
|
654
|
+
{
|
655
|
+
/*===========================================================*/
|
656
|
+
/* Don't bother deleting the error capture router if there's */
|
657
|
+
/* no parser callback. The implication of this is that the */
|
658
|
+
/* parser callback should be created before any routines */
|
659
|
+
/* which could generate errors are called. */
|
660
|
+
/*===========================================================*/
|
661
|
+
|
662
|
+
if (ConstructData(theEnv)->ParserErrorCallback == NULL) return;
|
663
|
+
|
664
|
+
ConstructData(theEnv)->errorCaptureRouterCount--;
|
665
|
+
|
666
|
+
if (ConstructData(theEnv)->errorCaptureRouterCount == 0)
|
667
|
+
{ DeleteRouter(theEnv,"error-capture"); }
|
668
|
+
}
|
669
|
+
|
670
|
+
/*******************************************************/
|
671
|
+
/* FlushParsingMessages: Invokes the callback routines */
|
672
|
+
/* for any existing warning/error messages. */
|
673
|
+
/*******************************************************/
|
674
|
+
void FlushParsingMessages(
|
675
|
+
Environment *theEnv)
|
676
|
+
{
|
677
|
+
/*===========================================================*/
|
678
|
+
/* Don't bother flushing the error capture router if there's */
|
679
|
+
/* no parser callback. The implication of this is that the */
|
680
|
+
/* parser callback should be created before any routines */
|
681
|
+
/* which could generate errors are called. */
|
682
|
+
/*===========================================================*/
|
683
|
+
|
684
|
+
if (ConstructData(theEnv)->ParserErrorCallback == NULL) return;
|
685
|
+
|
686
|
+
/*=================================*/
|
687
|
+
/* If an error occurred invoke the */
|
688
|
+
/* parser error callback function. */
|
689
|
+
/*=================================*/
|
690
|
+
|
691
|
+
if (ConstructData(theEnv)->ErrorString != NULL)
|
692
|
+
{
|
693
|
+
(*ConstructData(theEnv)->ParserErrorCallback)(theEnv,GetErrorFileName(theEnv),
|
694
|
+
NULL,ConstructData(theEnv)->ErrorString,
|
695
|
+
ConstructData(theEnv)->ErrLineNumber,
|
696
|
+
ConstructData(theEnv)->ParserErrorContext);
|
697
|
+
}
|
698
|
+
|
699
|
+
if (ConstructData(theEnv)->WarningString != NULL)
|
700
|
+
{
|
701
|
+
(*ConstructData(theEnv)->ParserErrorCallback)(theEnv,GetWarningFileName(theEnv),
|
702
|
+
ConstructData(theEnv)->WarningString,NULL,
|
703
|
+
ConstructData(theEnv)->WrnLineNumber,
|
704
|
+
ConstructData(theEnv)->ParserErrorContext);
|
705
|
+
}
|
706
|
+
|
707
|
+
/*===================================*/
|
708
|
+
/* Delete the error capture strings. */
|
709
|
+
/*===================================*/
|
710
|
+
|
711
|
+
SetErrorFileName(theEnv,NULL);
|
712
|
+
if (ConstructData(theEnv)->ErrorString != NULL)
|
713
|
+
{ genfree(theEnv,ConstructData(theEnv)->ErrorString,strlen(ConstructData(theEnv)->ErrorString) + 1); }
|
714
|
+
ConstructData(theEnv)->ErrorString = NULL;
|
715
|
+
ConstructData(theEnv)->CurErrPos = 0;
|
716
|
+
ConstructData(theEnv)->MaxErrChars = 0;
|
717
|
+
|
718
|
+
SetWarningFileName(theEnv,NULL);
|
719
|
+
if (ConstructData(theEnv)->WarningString != NULL)
|
720
|
+
{ genfree(theEnv,ConstructData(theEnv)->WarningString,strlen(ConstructData(theEnv)->WarningString) + 1); }
|
721
|
+
ConstructData(theEnv)->WarningString = NULL;
|
722
|
+
ConstructData(theEnv)->CurWrnPos = 0;
|
723
|
+
ConstructData(theEnv)->MaxWrnChars = 0;
|
724
|
+
}
|
725
|
+
|
726
|
+
/***************************************/
|
727
|
+
/* ParseConstruct: Parses a construct. */
|
728
|
+
/***************************************/
|
729
|
+
BuildError ParseConstruct(
|
730
|
+
Environment *theEnv,
|
731
|
+
const char *name,
|
732
|
+
const char *logicalName)
|
733
|
+
{
|
734
|
+
Construct *currentPtr;
|
735
|
+
BuildError rv;
|
736
|
+
bool ov;
|
737
|
+
GCBlock gcb;
|
738
|
+
|
739
|
+
/*=================================*/
|
740
|
+
/* Look for a valid construct name */
|
741
|
+
/* (e.g. defrule, deffacts). */
|
742
|
+
/*=================================*/
|
743
|
+
|
744
|
+
currentPtr = FindConstruct(theEnv,name);
|
745
|
+
if (currentPtr == NULL) return BE_CONSTRUCT_NOT_FOUND_ERROR;
|
746
|
+
|
747
|
+
/*==========================================*/
|
748
|
+
/* Set up the frame for garbage collection. */
|
749
|
+
/*==========================================*/
|
750
|
+
|
751
|
+
GCBlockStart(theEnv,&gcb);
|
752
|
+
|
753
|
+
/*==================================*/
|
754
|
+
/* Prepare the parsing environment. */
|
755
|
+
/*==================================*/
|
756
|
+
|
757
|
+
ov = GetHaltExecution(theEnv);
|
758
|
+
SetEvaluationError(theEnv,false);
|
759
|
+
SetHaltExecution(theEnv,false);
|
760
|
+
ClearParsedBindNames(theEnv);
|
761
|
+
PushRtnBrkContexts(theEnv);
|
762
|
+
ExpressionData(theEnv)->ReturnContext = false;
|
763
|
+
ExpressionData(theEnv)->BreakContext = false;
|
764
|
+
|
765
|
+
/*=======================================*/
|
766
|
+
/* Call the construct's parsing routine. */
|
767
|
+
/*=======================================*/
|
768
|
+
|
769
|
+
ConstructData(theEnv)->ParsingConstruct = true;
|
770
|
+
|
771
|
+
if ((*currentPtr->parseFunction)(theEnv,logicalName))
|
772
|
+
{ rv = BE_PARSING_ERROR; }
|
773
|
+
else
|
774
|
+
{ rv = BE_NO_ERROR; }
|
775
|
+
|
776
|
+
ConstructData(theEnv)->ParsingConstruct = false;
|
777
|
+
|
778
|
+
/*===============================*/
|
779
|
+
/* Restore environment settings. */
|
780
|
+
/*===============================*/
|
781
|
+
|
782
|
+
PopRtnBrkContexts(theEnv);
|
783
|
+
|
784
|
+
ClearParsedBindNames(theEnv);
|
785
|
+
SetPPBufferStatus(theEnv,false);
|
786
|
+
SetHaltExecution(theEnv,ov);
|
787
|
+
|
788
|
+
/*======================================*/
|
789
|
+
/* Remove the garbage collection frame. */
|
790
|
+
/*======================================*/
|
791
|
+
|
792
|
+
GCBlockEnd(theEnv,&gcb);
|
793
|
+
CallPeriodicTasks(theEnv);
|
794
|
+
|
795
|
+
/*==============================*/
|
796
|
+
/* Return the status of parsing */
|
797
|
+
/* the construct. */
|
798
|
+
/*==============================*/
|
799
|
+
|
800
|
+
return rv;
|
801
|
+
}
|
802
|
+
|
803
|
+
/******************************************************/
|
804
|
+
/* ImportExportConflictMessage: Generic error message */
|
805
|
+
/* for an import/export module conflict detected */
|
806
|
+
/* when a construct is being defined. */
|
807
|
+
/******************************************************/
|
808
|
+
void ImportExportConflictMessage(
|
809
|
+
Environment *theEnv,
|
810
|
+
const char *constructName,
|
811
|
+
const char *itemName,
|
812
|
+
const char *causedByConstruct,
|
813
|
+
const char *causedByName)
|
814
|
+
{
|
815
|
+
PrintErrorID(theEnv,"CSTRCPSR",3,true);
|
816
|
+
WriteString(theEnv,STDERR,"Cannot define ");
|
817
|
+
WriteString(theEnv,STDERR,constructName);
|
818
|
+
WriteString(theEnv,STDERR," '");
|
819
|
+
WriteString(theEnv,STDERR,itemName);
|
820
|
+
WriteString(theEnv,STDERR,"' because of an import/export conflict");
|
821
|
+
|
822
|
+
if (causedByConstruct == NULL) WriteString(theEnv,STDERR,".\n");
|
823
|
+
else
|
824
|
+
{
|
825
|
+
WriteString(theEnv,STDERR," caused by the ");
|
826
|
+
WriteString(theEnv,STDERR,causedByConstruct);
|
827
|
+
WriteString(theEnv,STDERR," '");
|
828
|
+
WriteString(theEnv,STDERR,causedByName);
|
829
|
+
WriteString(theEnv,STDERR,"'.\n");
|
830
|
+
}
|
831
|
+
}
|
832
|
+
|
833
|
+
#endif /* (! RUN_TIME) && (! BLOAD_ONLY) */
|
834
|
+
|
835
|
+
|