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.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clipsruby/agenda.c +1373 -0
  3. data/ext/clipsruby/agenda.h +169 -0
  4. data/ext/clipsruby/analysis.c +1142 -0
  5. data/ext/clipsruby/analysis.h +61 -0
  6. data/ext/clipsruby/argacces.c +526 -0
  7. data/ext/clipsruby/argacces.h +77 -0
  8. data/ext/clipsruby/bload.c +884 -0
  9. data/ext/clipsruby/bload.h +94 -0
  10. data/ext/clipsruby/bmathfun.c +557 -0
  11. data/ext/clipsruby/bmathfun.h +66 -0
  12. data/ext/clipsruby/bsave.c +634 -0
  13. data/ext/clipsruby/bsave.h +130 -0
  14. data/ext/clipsruby/classcom.c +976 -0
  15. data/ext/clipsruby/classcom.h +115 -0
  16. data/ext/clipsruby/classexm.c +1376 -0
  17. data/ext/clipsruby/classexm.h +97 -0
  18. data/ext/clipsruby/classfun.c +1392 -0
  19. data/ext/clipsruby/classfun.h +164 -0
  20. data/ext/clipsruby/classinf.c +1245 -0
  21. data/ext/clipsruby/classinf.h +94 -0
  22. data/ext/clipsruby/classini.c +843 -0
  23. data/ext/clipsruby/classini.h +75 -0
  24. data/ext/clipsruby/classpsr.c +957 -0
  25. data/ext/clipsruby/classpsr.h +73 -0
  26. data/ext/clipsruby/clips.h +133 -0
  27. data/ext/clipsruby/clipsruby.c +619 -0
  28. data/ext/clipsruby/clsltpsr.c +931 -0
  29. data/ext/clipsruby/clsltpsr.h +72 -0
  30. data/ext/clipsruby/commline.c +1217 -0
  31. data/ext/clipsruby/commline.h +131 -0
  32. data/ext/clipsruby/conscomp.c +1593 -0
  33. data/ext/clipsruby/conscomp.h +150 -0
  34. data/ext/clipsruby/constant.h +264 -0
  35. data/ext/clipsruby/constrct.c +1090 -0
  36. data/ext/clipsruby/constrct.h +216 -0
  37. data/ext/clipsruby/constrnt.c +554 -0
  38. data/ext/clipsruby/constrnt.h +132 -0
  39. data/ext/clipsruby/crstrtgy.c +1088 -0
  40. data/ext/clipsruby/crstrtgy.h +85 -0
  41. data/ext/clipsruby/cstrcbin.c +185 -0
  42. data/ext/clipsruby/cstrcbin.h +61 -0
  43. data/ext/clipsruby/cstrccmp.h +43 -0
  44. data/ext/clipsruby/cstrccom.c +1791 -0
  45. data/ext/clipsruby/cstrccom.h +115 -0
  46. data/ext/clipsruby/cstrcpsr.c +835 -0
  47. data/ext/clipsruby/cstrcpsr.h +97 -0
  48. data/ext/clipsruby/cstrnbin.c +282 -0
  49. data/ext/clipsruby/cstrnbin.h +55 -0
  50. data/ext/clipsruby/cstrnchk.c +826 -0
  51. data/ext/clipsruby/cstrnchk.h +91 -0
  52. data/ext/clipsruby/cstrncmp.c +238 -0
  53. data/ext/clipsruby/cstrncmp.h +57 -0
  54. data/ext/clipsruby/cstrnops.c +1176 -0
  55. data/ext/clipsruby/cstrnops.h +47 -0
  56. data/ext/clipsruby/cstrnpsr.c +1394 -0
  57. data/ext/clipsruby/cstrnpsr.h +88 -0
  58. data/ext/clipsruby/cstrnutl.c +564 -0
  59. data/ext/clipsruby/cstrnutl.h +54 -0
  60. data/ext/clipsruby/default.c +454 -0
  61. data/ext/clipsruby/default.h +57 -0
  62. data/ext/clipsruby/defins.c +971 -0
  63. data/ext/clipsruby/defins.h +127 -0
  64. data/ext/clipsruby/developr.c +677 -0
  65. data/ext/clipsruby/developr.h +69 -0
  66. data/ext/clipsruby/dffctbin.c +477 -0
  67. data/ext/clipsruby/dffctbin.h +76 -0
  68. data/ext/clipsruby/dffctbsc.c +308 -0
  69. data/ext/clipsruby/dffctbsc.h +72 -0
  70. data/ext/clipsruby/dffctcmp.c +297 -0
  71. data/ext/clipsruby/dffctcmp.h +44 -0
  72. data/ext/clipsruby/dffctdef.c +364 -0
  73. data/ext/clipsruby/dffctdef.h +104 -0
  74. data/ext/clipsruby/dffctpsr.c +179 -0
  75. data/ext/clipsruby/dffctpsr.h +49 -0
  76. data/ext/clipsruby/dffnxbin.c +520 -0
  77. data/ext/clipsruby/dffnxbin.h +67 -0
  78. data/ext/clipsruby/dffnxcmp.c +378 -0
  79. data/ext/clipsruby/dffnxcmp.h +54 -0
  80. data/ext/clipsruby/dffnxexe.c +241 -0
  81. data/ext/clipsruby/dffnxexe.h +58 -0
  82. data/ext/clipsruby/dffnxfun.c +1192 -0
  83. data/ext/clipsruby/dffnxfun.h +155 -0
  84. data/ext/clipsruby/dffnxpsr.c +514 -0
  85. data/ext/clipsruby/dffnxpsr.h +57 -0
  86. data/ext/clipsruby/dfinsbin.c +509 -0
  87. data/ext/clipsruby/dfinsbin.h +66 -0
  88. data/ext/clipsruby/dfinscmp.c +345 -0
  89. data/ext/clipsruby/dfinscmp.h +48 -0
  90. data/ext/clipsruby/drive.c +1191 -0
  91. data/ext/clipsruby/drive.h +65 -0
  92. data/ext/clipsruby/emathfun.c +1213 -0
  93. data/ext/clipsruby/emathfun.h +99 -0
  94. data/ext/clipsruby/engine.c +1568 -0
  95. data/ext/clipsruby/engine.h +203 -0
  96. data/ext/clipsruby/entities.h +276 -0
  97. data/ext/clipsruby/envrnbld.c +514 -0
  98. data/ext/clipsruby/envrnbld.h +40 -0
  99. data/ext/clipsruby/envrnmnt.c +257 -0
  100. data/ext/clipsruby/envrnmnt.h +112 -0
  101. data/ext/clipsruby/evaluatn.c +1736 -0
  102. data/ext/clipsruby/evaluatn.h +211 -0
  103. data/ext/clipsruby/expressn.c +494 -0
  104. data/ext/clipsruby/expressn.h +154 -0
  105. data/ext/clipsruby/exprnbin.c +538 -0
  106. data/ext/clipsruby/exprnbin.h +60 -0
  107. data/ext/clipsruby/exprnops.c +564 -0
  108. data/ext/clipsruby/exprnops.h +67 -0
  109. data/ext/clipsruby/exprnpsr.c +1112 -0
  110. data/ext/clipsruby/exprnpsr.h +98 -0
  111. data/ext/clipsruby/extconf.rb +2 -0
  112. data/ext/clipsruby/extnfunc.c +1015 -0
  113. data/ext/clipsruby/extnfunc.h +157 -0
  114. data/ext/clipsruby/factbin.c +447 -0
  115. data/ext/clipsruby/factbin.h +56 -0
  116. data/ext/clipsruby/factbld.c +1035 -0
  117. data/ext/clipsruby/factbld.h +63 -0
  118. data/ext/clipsruby/factcmp.c +386 -0
  119. data/ext/clipsruby/factcmp.h +46 -0
  120. data/ext/clipsruby/factcom.c +759 -0
  121. data/ext/clipsruby/factcom.h +80 -0
  122. data/ext/clipsruby/factfile.c +1761 -0
  123. data/ext/clipsruby/factfile.h +54 -0
  124. data/ext/clipsruby/factfun.c +682 -0
  125. data/ext/clipsruby/factfun.h +77 -0
  126. data/ext/clipsruby/factgen.c +1305 -0
  127. data/ext/clipsruby/factgen.h +229 -0
  128. data/ext/clipsruby/facthsh.c +438 -0
  129. data/ext/clipsruby/facthsh.h +81 -0
  130. data/ext/clipsruby/factlhs.c +250 -0
  131. data/ext/clipsruby/factlhs.h +54 -0
  132. data/ext/clipsruby/factmch.c +905 -0
  133. data/ext/clipsruby/factmch.h +68 -0
  134. data/ext/clipsruby/factmngr.c +3373 -0
  135. data/ext/clipsruby/factmngr.h +325 -0
  136. data/ext/clipsruby/factprt.c +498 -0
  137. data/ext/clipsruby/factprt.h +60 -0
  138. data/ext/clipsruby/factqpsr.c +796 -0
  139. data/ext/clipsruby/factqpsr.h +61 -0
  140. data/ext/clipsruby/factqury.c +1267 -0
  141. data/ext/clipsruby/factqury.h +112 -0
  142. data/ext/clipsruby/factrete.c +978 -0
  143. data/ext/clipsruby/factrete.h +70 -0
  144. data/ext/clipsruby/factrhs.c +667 -0
  145. data/ext/clipsruby/factrhs.h +55 -0
  146. data/ext/clipsruby/filecom.c +353 -0
  147. data/ext/clipsruby/filecom.h +137 -0
  148. data/ext/clipsruby/filertr.c +481 -0
  149. data/ext/clipsruby/filertr.h +94 -0
  150. data/ext/clipsruby/fileutil.c +1020 -0
  151. data/ext/clipsruby/fileutil.h +50 -0
  152. data/ext/clipsruby/generate.c +1079 -0
  153. data/ext/clipsruby/generate.h +57 -0
  154. data/ext/clipsruby/genrcbin.c +902 -0
  155. data/ext/clipsruby/genrcbin.h +69 -0
  156. data/ext/clipsruby/genrccmp.c +640 -0
  157. data/ext/clipsruby/genrccmp.h +59 -0
  158. data/ext/clipsruby/genrccom.c +2017 -0
  159. data/ext/clipsruby/genrccom.h +119 -0
  160. data/ext/clipsruby/genrcexe.c +737 -0
  161. data/ext/clipsruby/genrcexe.h +73 -0
  162. data/ext/clipsruby/genrcfun.c +890 -0
  163. data/ext/clipsruby/genrcfun.h +185 -0
  164. data/ext/clipsruby/genrcpsr.c +1618 -0
  165. data/ext/clipsruby/genrcpsr.h +80 -0
  166. data/ext/clipsruby/globlbin.c +458 -0
  167. data/ext/clipsruby/globlbin.h +71 -0
  168. data/ext/clipsruby/globlbsc.c +361 -0
  169. data/ext/clipsruby/globlbsc.h +83 -0
  170. data/ext/clipsruby/globlcmp.c +330 -0
  171. data/ext/clipsruby/globlcmp.h +52 -0
  172. data/ext/clipsruby/globlcom.c +289 -0
  173. data/ext/clipsruby/globlcom.h +63 -0
  174. data/ext/clipsruby/globldef.c +1087 -0
  175. data/ext/clipsruby/globldef.h +151 -0
  176. data/ext/clipsruby/globlpsr.c +530 -0
  177. data/ext/clipsruby/globlpsr.h +59 -0
  178. data/ext/clipsruby/immthpsr.c +431 -0
  179. data/ext/clipsruby/immthpsr.h +55 -0
  180. data/ext/clipsruby/incrrset.c +530 -0
  181. data/ext/clipsruby/incrrset.h +73 -0
  182. data/ext/clipsruby/inherpsr.c +850 -0
  183. data/ext/clipsruby/inherpsr.h +52 -0
  184. data/ext/clipsruby/inscom.c +2076 -0
  185. data/ext/clipsruby/inscom.h +182 -0
  186. data/ext/clipsruby/insfile.c +1764 -0
  187. data/ext/clipsruby/insfile.h +96 -0
  188. data/ext/clipsruby/insfun.c +1451 -0
  189. data/ext/clipsruby/insfun.h +134 -0
  190. data/ext/clipsruby/insmngr.c +2550 -0
  191. data/ext/clipsruby/insmngr.h +125 -0
  192. data/ext/clipsruby/insmoddp.c +1041 -0
  193. data/ext/clipsruby/insmoddp.h +91 -0
  194. data/ext/clipsruby/insmult.c +804 -0
  195. data/ext/clipsruby/insmult.h +62 -0
  196. data/ext/clipsruby/inspsr.c +602 -0
  197. data/ext/clipsruby/inspsr.h +60 -0
  198. data/ext/clipsruby/insquery.c +1278 -0
  199. data/ext/clipsruby/insquery.h +115 -0
  200. data/ext/clipsruby/insqypsr.c +729 -0
  201. data/ext/clipsruby/insqypsr.h +63 -0
  202. data/ext/clipsruby/iofun.c +2045 -0
  203. data/ext/clipsruby/iofun.h +116 -0
  204. data/ext/clipsruby/lgcldpnd.c +644 -0
  205. data/ext/clipsruby/lgcldpnd.h +75 -0
  206. data/ext/clipsruby/main.c +112 -0
  207. data/ext/clipsruby/match.h +142 -0
  208. data/ext/clipsruby/memalloc.c +481 -0
  209. data/ext/clipsruby/memalloc.h +197 -0
  210. data/ext/clipsruby/miscfun.c +1801 -0
  211. data/ext/clipsruby/miscfun.h +132 -0
  212. data/ext/clipsruby/modulbin.c +607 -0
  213. data/ext/clipsruby/modulbin.h +84 -0
  214. data/ext/clipsruby/modulbsc.c +347 -0
  215. data/ext/clipsruby/modulbsc.h +67 -0
  216. data/ext/clipsruby/modulcmp.c +499 -0
  217. data/ext/clipsruby/modulcmp.h +54 -0
  218. data/ext/clipsruby/moduldef.c +817 -0
  219. data/ext/clipsruby/moduldef.h +271 -0
  220. data/ext/clipsruby/modulpsr.c +1150 -0
  221. data/ext/clipsruby/modulpsr.h +69 -0
  222. data/ext/clipsruby/modulutl.c +1036 -0
  223. data/ext/clipsruby/modulutl.h +84 -0
  224. data/ext/clipsruby/msgcom.c +1221 -0
  225. data/ext/clipsruby/msgcom.h +125 -0
  226. data/ext/clipsruby/msgfun.c +1076 -0
  227. data/ext/clipsruby/msgfun.h +118 -0
  228. data/ext/clipsruby/msgpass.c +1441 -0
  229. data/ext/clipsruby/msgpass.h +103 -0
  230. data/ext/clipsruby/msgpsr.c +698 -0
  231. data/ext/clipsruby/msgpsr.h +73 -0
  232. data/ext/clipsruby/multifld.c +1404 -0
  233. data/ext/clipsruby/multifld.h +130 -0
  234. data/ext/clipsruby/multifun.c +2182 -0
  235. data/ext/clipsruby/multifun.h +102 -0
  236. data/ext/clipsruby/network.h +142 -0
  237. data/ext/clipsruby/objbin.c +1522 -0
  238. data/ext/clipsruby/objbin.h +79 -0
  239. data/ext/clipsruby/objcmp.c +1507 -0
  240. data/ext/clipsruby/objcmp.h +71 -0
  241. data/ext/clipsruby/object.h +260 -0
  242. data/ext/clipsruby/objrtbin.c +701 -0
  243. data/ext/clipsruby/objrtbin.h +79 -0
  244. data/ext/clipsruby/objrtbld.c +2393 -0
  245. data/ext/clipsruby/objrtbld.h +66 -0
  246. data/ext/clipsruby/objrtcmp.c +734 -0
  247. data/ext/clipsruby/objrtcmp.h +66 -0
  248. data/ext/clipsruby/objrtfnx.c +1330 -0
  249. data/ext/clipsruby/objrtfnx.h +222 -0
  250. data/ext/clipsruby/objrtgen.c +736 -0
  251. data/ext/clipsruby/objrtgen.h +63 -0
  252. data/ext/clipsruby/objrtmch.c +1524 -0
  253. data/ext/clipsruby/objrtmch.h +160 -0
  254. data/ext/clipsruby/parsefun.c +415 -0
  255. data/ext/clipsruby/parsefun.h +67 -0
  256. data/ext/clipsruby/pattern.c +1265 -0
  257. data/ext/clipsruby/pattern.h +163 -0
  258. data/ext/clipsruby/pprint.c +328 -0
  259. data/ext/clipsruby/pprint.h +79 -0
  260. data/ext/clipsruby/prccode.c +1478 -0
  261. data/ext/clipsruby/prccode.h +145 -0
  262. data/ext/clipsruby/prcdrfun.c +640 -0
  263. data/ext/clipsruby/prcdrfun.h +95 -0
  264. data/ext/clipsruby/prcdrpsr.c +1068 -0
  265. data/ext/clipsruby/prcdrpsr.h +79 -0
  266. data/ext/clipsruby/prdctfun.c +869 -0
  267. data/ext/clipsruby/prdctfun.h +77 -0
  268. data/ext/clipsruby/prntutil.c +878 -0
  269. data/ext/clipsruby/prntutil.h +125 -0
  270. data/ext/clipsruby/proflfun.c +827 -0
  271. data/ext/clipsruby/proflfun.h +118 -0
  272. data/ext/clipsruby/reorder.c +2082 -0
  273. data/ext/clipsruby/reorder.h +172 -0
  274. data/ext/clipsruby/reteutil.c +1732 -0
  275. data/ext/clipsruby/reteutil.h +111 -0
  276. data/ext/clipsruby/retract.c +710 -0
  277. data/ext/clipsruby/retract.h +74 -0
  278. data/ext/clipsruby/router.c +737 -0
  279. data/ext/clipsruby/router.h +147 -0
  280. data/ext/clipsruby/rulebin.c +1136 -0
  281. data/ext/clipsruby/rulebin.h +153 -0
  282. data/ext/clipsruby/rulebld.c +1328 -0
  283. data/ext/clipsruby/rulebld.h +62 -0
  284. data/ext/clipsruby/rulebsc.c +517 -0
  285. data/ext/clipsruby/rulebsc.h +91 -0
  286. data/ext/clipsruby/rulecmp.c +733 -0
  287. data/ext/clipsruby/rulecmp.h +63 -0
  288. data/ext/clipsruby/rulecom.c +1583 -0
  289. data/ext/clipsruby/rulecom.h +116 -0
  290. data/ext/clipsruby/rulecstr.c +892 -0
  291. data/ext/clipsruby/rulecstr.h +53 -0
  292. data/ext/clipsruby/ruledef.c +559 -0
  293. data/ext/clipsruby/ruledef.h +179 -0
  294. data/ext/clipsruby/ruledlt.c +599 -0
  295. data/ext/clipsruby/ruledlt.h +58 -0
  296. data/ext/clipsruby/rulelhs.c +1216 -0
  297. data/ext/clipsruby/rulelhs.h +52 -0
  298. data/ext/clipsruby/rulepsr.c +1073 -0
  299. data/ext/clipsruby/rulepsr.h +61 -0
  300. data/ext/clipsruby/scanner.c +856 -0
  301. data/ext/clipsruby/scanner.h +112 -0
  302. data/ext/clipsruby/setup.h +488 -0
  303. data/ext/clipsruby/sortfun.c +433 -0
  304. data/ext/clipsruby/sortfun.h +55 -0
  305. data/ext/clipsruby/strngfun.c +1173 -0
  306. data/ext/clipsruby/strngfun.h +96 -0
  307. data/ext/clipsruby/strngrtr.c +523 -0
  308. data/ext/clipsruby/strngrtr.h +97 -0
  309. data/ext/clipsruby/symblbin.c +648 -0
  310. data/ext/clipsruby/symblbin.h +64 -0
  311. data/ext/clipsruby/symblcmp.c +893 -0
  312. data/ext/clipsruby/symblcmp.h +61 -0
  313. data/ext/clipsruby/symbol.c +1961 -0
  314. data/ext/clipsruby/symbol.h +243 -0
  315. data/ext/clipsruby/sysdep.c +894 -0
  316. data/ext/clipsruby/sysdep.h +164 -0
  317. data/ext/clipsruby/textpro.c +1388 -0
  318. data/ext/clipsruby/textpro.h +77 -0
  319. data/ext/clipsruby/tmpltbin.c +609 -0
  320. data/ext/clipsruby/tmpltbin.h +108 -0
  321. data/ext/clipsruby/tmpltbsc.c +327 -0
  322. data/ext/clipsruby/tmpltbsc.h +87 -0
  323. data/ext/clipsruby/tmpltcmp.c +450 -0
  324. data/ext/clipsruby/tmpltcmp.h +57 -0
  325. data/ext/clipsruby/tmpltdef.c +584 -0
  326. data/ext/clipsruby/tmpltdef.h +155 -0
  327. data/ext/clipsruby/tmpltfun.c +2477 -0
  328. data/ext/clipsruby/tmpltfun.h +122 -0
  329. data/ext/clipsruby/tmpltlhs.c +379 -0
  330. data/ext/clipsruby/tmpltlhs.h +50 -0
  331. data/ext/clipsruby/tmpltpsr.c +819 -0
  332. data/ext/clipsruby/tmpltpsr.h +59 -0
  333. data/ext/clipsruby/tmpltrhs.c +595 -0
  334. data/ext/clipsruby/tmpltrhs.h +55 -0
  335. data/ext/clipsruby/tmpltutl.c +637 -0
  336. data/ext/clipsruby/tmpltutl.h +82 -0
  337. data/ext/clipsruby/userdata.c +156 -0
  338. data/ext/clipsruby/userdata.h +72 -0
  339. data/ext/clipsruby/userfunctions.c +70 -0
  340. data/ext/clipsruby/usrsetup.h +7 -0
  341. data/ext/clipsruby/utility.c +1594 -0
  342. data/ext/clipsruby/utility.h +250 -0
  343. data/ext/clipsruby/watch.c +865 -0
  344. data/ext/clipsruby/watch.h +124 -0
  345. data/lib/clipsruby.rb +1 -0
  346. metadata +388 -0
@@ -0,0 +1,1394 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.41 12/04/22 */
5
+ /* */
6
+ /* CONSTRAINT PARSER MODULE */
7
+ /*******************************************************/
8
+
9
+ /*************************************************************/
10
+ /* Purpose: Provides functions for parsing constraint */
11
+ /* declarations. */
12
+ /* */
13
+ /* Principal Programmer(s): */
14
+ /* Gary D. Riley */
15
+ /* */
16
+ /* Contributing Programmer(s): */
17
+ /* Brian Dantes */
18
+ /* */
19
+ /* Revision History: */
20
+ /* */
21
+ /* 6.23: Changed name of variable exp to theExp */
22
+ /* because of Unix compiler warnings of shadowed */
23
+ /* definitions. */
24
+ /* */
25
+ /* 6.24: Added allowed-classes slot facet. */
26
+ /* */
27
+ /* Renamed BOOLEAN macro type to intBool. */
28
+ /* */
29
+ /* 6.30: Used gensprintf instead of sprintf. */
30
+ /* */
31
+ /* Added const qualifiers to remove C++ */
32
+ /* deprecation warnings. */
33
+ /* */
34
+ /* Slot cardinality bug fix for minimum < 0. */
35
+ /* */
36
+ /* 6.40: Pragma once and other inclusion changes. */
37
+ /* */
38
+ /* Added support for booleans with <stdbool.h>. */
39
+ /* */
40
+ /* Removed use of void pointers for specific */
41
+ /* data structures. */
42
+ /* */
43
+ /* 6.41: Used gensnprintf in place of gensprintf and. */
44
+ /* sprintf. */
45
+ /* */
46
+ /*************************************************************/
47
+
48
+ #include <stdio.h>
49
+ #include <stdlib.h>
50
+
51
+ #include "setup.h"
52
+
53
+ #include "constant.h"
54
+ #include "cstrnchk.h"
55
+ #include "cstrnutl.h"
56
+ #include "envrnmnt.h"
57
+ #include "expressn.h"
58
+ #include "memalloc.h"
59
+ #include "pprint.h"
60
+ #include "prntutil.h"
61
+ #include "router.h"
62
+ #include "scanner.h"
63
+ #include "sysdep.h"
64
+
65
+ #include "cstrnpsr.h"
66
+
67
+ /***************************************/
68
+ /* LOCAL INTERNAL FUNCTION DEFINITIONS */
69
+ /***************************************/
70
+
71
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
72
+ static bool ParseRangeCardinalityAttribute(Environment *,
73
+ const char *,CONSTRAINT_RECORD *,
74
+ CONSTRAINT_PARSE_RECORD *,
75
+ const char *,bool);
76
+ static bool ParseTypeAttribute(Environment *,const char *,CONSTRAINT_RECORD *);
77
+ static void AddToRestrictionList(Environment *,int,CONSTRAINT_RECORD *,
78
+ CONSTRAINT_RECORD *);
79
+ static bool ParseAllowedValuesAttribute(Environment *,const char *,const char *,
80
+ CONSTRAINT_RECORD *,
81
+ CONSTRAINT_PARSE_RECORD *);
82
+ static int GetConstraintTypeFromAllowedName(const char *);
83
+ static int GetConstraintTypeFromTypeName(const char *);
84
+ static bool GetAttributeParseValue(const char *,CONSTRAINT_PARSE_RECORD *);
85
+ static void SetRestrictionFlag(int,CONSTRAINT_RECORD *,bool);
86
+ static void SetParseFlag(CONSTRAINT_PARSE_RECORD *,const char *);
87
+ static void NoConjunctiveUseError(Environment *,const char *,const char *);
88
+ #endif
89
+
90
+ /********************************************************************/
91
+ /* CheckConstraintParseConflicts: Determines if a constraint record */
92
+ /* has any conflicts in the attribute specifications. Returns */
93
+ /* true if no conflicts were detected, otherwise false. */
94
+ /********************************************************************/
95
+ bool CheckConstraintParseConflicts(
96
+ Environment *theEnv,
97
+ CONSTRAINT_RECORD *constraints)
98
+ {
99
+ /*===================================================*/
100
+ /* Check to see if any of the allowed-... attributes */
101
+ /* conflict with the type attribute. */
102
+ /*===================================================*/
103
+
104
+ if (constraints->anyAllowed == true)
105
+ { /* Do Nothing */ }
106
+ else if (constraints->symbolRestriction &&
107
+ (constraints->symbolsAllowed == false))
108
+ {
109
+ AttributeConflictErrorMessage(theEnv,"type","allowed-symbols");
110
+ return false;
111
+ }
112
+ else if (constraints->stringRestriction &&
113
+ (constraints->stringsAllowed == false))
114
+ {
115
+ AttributeConflictErrorMessage(theEnv,"type","allowed-strings");
116
+ return false;
117
+ }
118
+ else if (constraints->integerRestriction &&
119
+ (constraints->integersAllowed == false))
120
+ {
121
+ AttributeConflictErrorMessage(theEnv,"type","allowed-integers/numbers");
122
+ return false;
123
+ }
124
+ else if (constraints->floatRestriction &&
125
+ (constraints->floatsAllowed == false))
126
+ {
127
+ AttributeConflictErrorMessage(theEnv,"type","allowed-floats/numbers");
128
+ return false;
129
+ }
130
+ else if (constraints->classRestriction &&
131
+ (constraints->instanceAddressesAllowed == false) &&
132
+ (constraints->instanceNamesAllowed == false))
133
+ {
134
+ AttributeConflictErrorMessage(theEnv,"type","allowed-classes");
135
+ return false;
136
+ }
137
+ else if (constraints->instanceNameRestriction &&
138
+ (constraints->instanceNamesAllowed == false))
139
+ {
140
+ AttributeConflictErrorMessage(theEnv,"type","allowed-instance-names");
141
+ return false;
142
+ }
143
+ else if (constraints->anyRestriction)
144
+ {
145
+ struct expr *theExp;
146
+
147
+ for (theExp = constraints->restrictionList;
148
+ theExp != NULL;
149
+ theExp = theExp->nextArg)
150
+ {
151
+ if (ConstraintCheckValue(theEnv,theExp->type,theExp->value,constraints) != NO_VIOLATION)
152
+ {
153
+ AttributeConflictErrorMessage(theEnv,"type","allowed-values");
154
+ return false;
155
+ }
156
+ }
157
+ }
158
+
159
+ /*================================================================*/
160
+ /* Check to see if range attribute conflicts with type attribute. */
161
+ /*================================================================*/
162
+
163
+ if ((constraints->maxValue != NULL) &&
164
+ (constraints->anyAllowed == false))
165
+ {
166
+ if (((constraints->maxValue->type == INTEGER_TYPE) &&
167
+ (constraints->integersAllowed == false)) ||
168
+ ((constraints->maxValue->type == FLOAT_TYPE) &&
169
+ (constraints->floatsAllowed == false)))
170
+ {
171
+ AttributeConflictErrorMessage(theEnv,"type","range");
172
+ return false;
173
+ }
174
+ }
175
+
176
+ if ((constraints->minValue != NULL) &&
177
+ (constraints->anyAllowed == false))
178
+ {
179
+ if (((constraints->minValue->type == INTEGER_TYPE) &&
180
+ (constraints->integersAllowed == false)) ||
181
+ ((constraints->minValue->type == FLOAT_TYPE) &&
182
+ (constraints->floatsAllowed == false)))
183
+ {
184
+ AttributeConflictErrorMessage(theEnv,"type","range");
185
+ return false;
186
+ }
187
+ }
188
+
189
+ /*=========================================*/
190
+ /* Check to see if allowed-class attribute */
191
+ /* conflicts with type attribute. */
192
+ /*=========================================*/
193
+
194
+ if ((constraints->classList != NULL) &&
195
+ (constraints->anyAllowed == false) &&
196
+ (constraints->instanceNamesAllowed == false) &&
197
+ (constraints->instanceAddressesAllowed == false))
198
+ {
199
+ AttributeConflictErrorMessage(theEnv,"type","allowed-class");
200
+ return false;
201
+ }
202
+
203
+ /*=====================================================*/
204
+ /* Return true to indicate no conflicts were detected. */
205
+ /*=====================================================*/
206
+
207
+ return true;
208
+ }
209
+
210
+ /********************************************************/
211
+ /* AttributeConflictErrorMessage: Generic error message */
212
+ /* for a constraint attribute conflict. */
213
+ /********************************************************/
214
+ void AttributeConflictErrorMessage(
215
+ Environment *theEnv,
216
+ const char *attribute1,
217
+ const char *attribute2)
218
+ {
219
+ PrintErrorID(theEnv,"CSTRNPSR",1,true);
220
+ WriteString(theEnv,STDERR,"The '");
221
+ WriteString(theEnv,STDERR,attribute1);
222
+ WriteString(theEnv,STDERR,"' attribute conflicts with the '");
223
+ WriteString(theEnv,STDERR,attribute2);
224
+ WriteString(theEnv,STDERR,"' attribute.\n");
225
+ }
226
+
227
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
228
+
229
+ /***************************************************************************/
230
+ /* InitializeConstraintParseRecord: Initializes the values of a constraint */
231
+ /* parse record which is used to determine whether one of the standard */
232
+ /* constraint specifications has already been parsed. */
233
+ /***************************************************************************/
234
+ void InitializeConstraintParseRecord(
235
+ CONSTRAINT_PARSE_RECORD *parsedConstraints)
236
+ {
237
+ parsedConstraints->type = false;
238
+ parsedConstraints->range = false;
239
+ parsedConstraints->allowedSymbols = false;
240
+ parsedConstraints->allowedStrings = false;
241
+ parsedConstraints->allowedLexemes = false;
242
+ parsedConstraints->allowedIntegers = false;
243
+ parsedConstraints->allowedFloats = false;
244
+ parsedConstraints->allowedNumbers = false;
245
+ parsedConstraints->allowedValues = false;
246
+ parsedConstraints->allowedInstanceNames = false;
247
+ parsedConstraints->allowedClasses = false;
248
+ parsedConstraints->cardinality = false;
249
+ }
250
+
251
+ /************************************************************************/
252
+ /* StandardConstraint: Returns true if the specified name is one of the */
253
+ /* standard constraints parseable by the routines in this module. */
254
+ /************************************************************************/
255
+ bool StandardConstraint(
256
+ const char *constraintName)
257
+ {
258
+ if ((strcmp(constraintName,"type") == 0) ||
259
+ (strcmp(constraintName,"range") == 0) ||
260
+ (strcmp(constraintName,"cardinality") == 0) ||
261
+ (strcmp(constraintName,"allowed-symbols") == 0) ||
262
+ (strcmp(constraintName,"allowed-strings") == 0) ||
263
+ (strcmp(constraintName,"allowed-lexemes") == 0) ||
264
+ (strcmp(constraintName,"allowed-integers") == 0) ||
265
+ (strcmp(constraintName,"allowed-floats") == 0) ||
266
+ (strcmp(constraintName,"allowed-numbers") == 0) ||
267
+ (strcmp(constraintName,"allowed-instance-names") == 0) ||
268
+ (strcmp(constraintName,"allowed-classes") == 0) ||
269
+ (strcmp(constraintName,"allowed-values") == 0))
270
+
271
+ { return true; }
272
+
273
+ return false;
274
+ }
275
+
276
+ /***********************************************************************/
277
+ /* ParseStandardConstraint: Parses a standard constraint. Returns true */
278
+ /* if the constraint was successfully parsed, otherwise false. */
279
+ /***********************************************************************/
280
+ bool ParseStandardConstraint(
281
+ Environment *theEnv,
282
+ const char *readSource,
283
+ const char *constraintName,
284
+ CONSTRAINT_RECORD *constraints,
285
+ CONSTRAINT_PARSE_RECORD *parsedConstraints,
286
+ bool multipleValuesAllowed)
287
+ {
288
+ bool rv = false;
289
+
290
+ /*=====================================================*/
291
+ /* Determine if the attribute has already been parsed. */
292
+ /*=====================================================*/
293
+
294
+ if (GetAttributeParseValue(constraintName,parsedConstraints))
295
+ {
296
+ AlreadyParsedErrorMessage(theEnv,"attribute ",constraintName);
297
+ return false;
298
+ }
299
+
300
+ /*==========================================*/
301
+ /* If specified, parse the range attribute. */
302
+ /*==========================================*/
303
+
304
+ if (strcmp(constraintName,"range") == 0)
305
+ {
306
+ rv = ParseRangeCardinalityAttribute(theEnv,readSource,constraints,parsedConstraints,
307
+ constraintName,multipleValuesAllowed);
308
+ }
309
+
310
+ /*================================================*/
311
+ /* If specified, parse the cardinality attribute. */
312
+ /*================================================*/
313
+
314
+ else if (strcmp(constraintName,"cardinality") == 0)
315
+ {
316
+ rv = ParseRangeCardinalityAttribute(theEnv,readSource,constraints,parsedConstraints,
317
+ constraintName,multipleValuesAllowed);
318
+ }
319
+
320
+ /*=========================================*/
321
+ /* If specified, parse the type attribute. */
322
+ /*=========================================*/
323
+
324
+ else if (strcmp(constraintName,"type") == 0)
325
+ { rv = ParseTypeAttribute(theEnv,readSource,constraints); }
326
+
327
+ /*================================================*/
328
+ /* If specified, parse the allowed-... attribute. */
329
+ /*================================================*/
330
+
331
+ else if ((strcmp(constraintName,"allowed-symbols") == 0) ||
332
+ (strcmp(constraintName,"allowed-strings") == 0) ||
333
+ (strcmp(constraintName,"allowed-lexemes") == 0) ||
334
+ (strcmp(constraintName,"allowed-integers") == 0) ||
335
+ (strcmp(constraintName,"allowed-floats") == 0) ||
336
+ (strcmp(constraintName,"allowed-numbers") == 0) ||
337
+ (strcmp(constraintName,"allowed-instance-names") == 0) ||
338
+ (strcmp(constraintName,"allowed-classes") == 0) ||
339
+ (strcmp(constraintName,"allowed-values") == 0))
340
+ {
341
+ rv = ParseAllowedValuesAttribute(theEnv,readSource,constraintName,
342
+ constraints,parsedConstraints);
343
+ }
344
+
345
+ /*=========================================*/
346
+ /* Remember which constraint attribute was */
347
+ /* parsed and return the error status. */
348
+ /*=========================================*/
349
+
350
+ SetParseFlag(parsedConstraints,constraintName);
351
+ return(rv);
352
+ }
353
+
354
+ /***********************************************************/
355
+ /* OverlayConstraint: Overlays fields of source constraint */
356
+ /* record on destination based on which fields are set in */
357
+ /* the parsed constraint record. Assumes AddConstraint has */
358
+ /* not yet been called for the destination constraint */
359
+ /* record. */
360
+ /***********************************************************/
361
+ void OverlayConstraint(
362
+ Environment *theEnv,
363
+ CONSTRAINT_PARSE_RECORD *pc,
364
+ CONSTRAINT_RECORD *cdst,
365
+ CONSTRAINT_RECORD *csrc)
366
+ {
367
+ if (pc->type == 0)
368
+ {
369
+ cdst->anyAllowed = csrc->anyAllowed;
370
+ cdst->symbolsAllowed = csrc->symbolsAllowed;
371
+ cdst->stringsAllowed = csrc->stringsAllowed;
372
+ cdst->floatsAllowed = csrc->floatsAllowed;
373
+ cdst->integersAllowed = csrc->integersAllowed;
374
+ cdst->instanceNamesAllowed = csrc->instanceNamesAllowed;
375
+ cdst->instanceAddressesAllowed = csrc->instanceAddressesAllowed;
376
+ cdst->externalAddressesAllowed = csrc->externalAddressesAllowed;
377
+ cdst->voidAllowed = csrc->voidAllowed;
378
+ cdst->factAddressesAllowed = csrc->factAddressesAllowed;
379
+ }
380
+
381
+ if (pc->range == 0)
382
+ {
383
+ ReturnExpression(theEnv,cdst->minValue);
384
+ ReturnExpression(theEnv,cdst->maxValue);
385
+ cdst->minValue = CopyExpression(theEnv,csrc->minValue);
386
+ cdst->maxValue = CopyExpression(theEnv,csrc->maxValue);
387
+ }
388
+
389
+ if (pc->allowedClasses == 0)
390
+ {
391
+ ReturnExpression(theEnv,cdst->classList);
392
+ cdst->classList = CopyExpression(theEnv,csrc->classList);
393
+ }
394
+
395
+ if (pc->allowedValues == 0)
396
+ {
397
+ if ((pc->allowedSymbols == 0) &&
398
+ (pc->allowedStrings == 0) &&
399
+ (pc->allowedLexemes == 0) &&
400
+ (pc->allowedIntegers == 0) &&
401
+ (pc->allowedFloats == 0) &&
402
+ (pc->allowedNumbers == 0) &&
403
+ (pc->allowedInstanceNames == 0))
404
+ {
405
+ cdst->anyRestriction = csrc->anyRestriction;
406
+ cdst->symbolRestriction = csrc->symbolRestriction;
407
+ cdst->stringRestriction = csrc->stringRestriction;
408
+ cdst->floatRestriction = csrc->floatRestriction;
409
+ cdst->integerRestriction = csrc->integerRestriction;
410
+ cdst->classRestriction = csrc->classRestriction;
411
+ cdst->instanceNameRestriction = csrc->instanceNameRestriction;
412
+ cdst->restrictionList = CopyExpression(theEnv,csrc->restrictionList);
413
+ }
414
+ else
415
+ {
416
+ if ((pc->allowedSymbols == 0) && csrc->symbolRestriction)
417
+ {
418
+ cdst->symbolRestriction = 1;
419
+ AddToRestrictionList(theEnv,SYMBOL_TYPE,cdst,csrc);
420
+ }
421
+ if ((pc->allowedStrings == 0) && csrc->stringRestriction)
422
+ {
423
+ cdst->stringRestriction = 1;
424
+ AddToRestrictionList(theEnv,STRING_TYPE,cdst,csrc);
425
+ }
426
+ if ((pc->allowedLexemes == 0) && csrc->symbolRestriction && csrc->stringRestriction)
427
+ {
428
+ cdst->symbolRestriction = 1;
429
+ cdst->stringRestriction = 1;
430
+ AddToRestrictionList(theEnv,SYMBOL_TYPE,cdst,csrc);
431
+ AddToRestrictionList(theEnv,STRING_TYPE,cdst,csrc);
432
+ }
433
+ if ((pc->allowedIntegers == 0) && csrc->integerRestriction)
434
+ {
435
+ cdst->integerRestriction = 1;
436
+ AddToRestrictionList(theEnv,INTEGER_TYPE,cdst,csrc);
437
+ }
438
+ if ((pc->allowedFloats == 0) && csrc->floatRestriction)
439
+ {
440
+ cdst->floatRestriction = 1;
441
+ AddToRestrictionList(theEnv,FLOAT_TYPE,cdst,csrc);
442
+ }
443
+ if ((pc->allowedNumbers == 0) && csrc->integerRestriction && csrc->floatRestriction)
444
+ {
445
+ cdst->integerRestriction = 1;
446
+ cdst->floatRestriction = 1;
447
+ AddToRestrictionList(theEnv,INTEGER_TYPE,cdst,csrc);
448
+ AddToRestrictionList(theEnv,FLOAT_TYPE,cdst,csrc);
449
+ }
450
+ if ((pc->allowedInstanceNames == 0) && csrc->instanceNameRestriction)
451
+ {
452
+ cdst->instanceNameRestriction = 1;
453
+ AddToRestrictionList(theEnv,INSTANCE_NAME_TYPE,cdst,csrc);
454
+ }
455
+ }
456
+ }
457
+
458
+ if (pc->cardinality == 0)
459
+ {
460
+ ReturnExpression(theEnv,cdst->minFields);
461
+ ReturnExpression(theEnv,cdst->maxFields);
462
+ cdst->minFields = CopyExpression(theEnv,csrc->minFields);
463
+ cdst->maxFields = CopyExpression(theEnv,csrc->maxFields);
464
+ }
465
+ }
466
+
467
+ /**********************************************/
468
+ /* OverlayConstraintParseRecord: Performs a */
469
+ /* field-wise "or" of the destination parse */
470
+ /* record with the source parse record. */
471
+ /**********************************************/
472
+ void OverlayConstraintParseRecord(
473
+ CONSTRAINT_PARSE_RECORD *dst,
474
+ CONSTRAINT_PARSE_RECORD *src)
475
+ {
476
+ if (src->type) dst->type = true;
477
+ if (src->range) dst->range = true;
478
+ if (src->allowedSymbols) dst->allowedSymbols = true;
479
+ if (src->allowedStrings) dst->allowedStrings = true;
480
+ if (src->allowedLexemes) dst->allowedLexemes = true;
481
+ if (src->allowedIntegers) dst->allowedIntegers = true;
482
+ if (src->allowedFloats) dst->allowedFloats = true;
483
+ if (src->allowedNumbers) dst->allowedNumbers = true;
484
+ if (src->allowedValues) dst->allowedValues = true;
485
+ if (src->allowedInstanceNames) dst->allowedInstanceNames = true;
486
+ if (src->allowedClasses) dst->allowedClasses = true;
487
+ if (src->cardinality) dst->cardinality = true;
488
+ }
489
+
490
+ /************************************************************/
491
+ /* AddToRestrictionList: Prepends atoms of the specified */
492
+ /* type from the source restriction list to the destination */
493
+ /************************************************************/
494
+ static void AddToRestrictionList(
495
+ Environment *theEnv,
496
+ int type,
497
+ CONSTRAINT_RECORD *cdst,
498
+ CONSTRAINT_RECORD *csrc)
499
+ {
500
+ struct expr *theExp,*tmp;
501
+
502
+ for (theExp = csrc->restrictionList; theExp != NULL; theExp = theExp->nextArg)
503
+ {
504
+ if (theExp->type == type)
505
+ {
506
+ tmp = GenConstant(theEnv,theExp->type,theExp->value);
507
+ tmp->nextArg = cdst->restrictionList;
508
+ cdst->restrictionList = tmp;
509
+ }
510
+ }
511
+ }
512
+
513
+ /*******************************************************************/
514
+ /* ParseAllowedValuesAttribute: Parses the allowed-... attributes. */
515
+ /*******************************************************************/
516
+ static bool ParseAllowedValuesAttribute(
517
+ Environment *theEnv,
518
+ const char *readSource,
519
+ const char *constraintName,
520
+ CONSTRAINT_RECORD *constraints,
521
+ CONSTRAINT_PARSE_RECORD *parsedConstraints)
522
+ {
523
+ struct token inputToken;
524
+ int expectedType, restrictionType;
525
+ bool error = false;
526
+ struct expr *newValue, *lastValue;
527
+ bool constantParsed = false, variableParsed = false;
528
+ const char *tempPtr = NULL;
529
+ unsigned short genType;
530
+
531
+ /*======================================================*/
532
+ /* The allowed-values attribute is not allowed if other */
533
+ /* allowed-... attributes have already been parsed. */
534
+ /*======================================================*/
535
+
536
+ if ((strcmp(constraintName,"allowed-values") == 0) &&
537
+ ((parsedConstraints->allowedSymbols) ||
538
+ (parsedConstraints->allowedStrings) ||
539
+ (parsedConstraints->allowedLexemes) ||
540
+ (parsedConstraints->allowedIntegers) ||
541
+ (parsedConstraints->allowedFloats) ||
542
+ (parsedConstraints->allowedNumbers) ||
543
+ (parsedConstraints->allowedInstanceNames)))
544
+ {
545
+ if (parsedConstraints->allowedSymbols) tempPtr = "allowed-symbols";
546
+ else if (parsedConstraints->allowedStrings) tempPtr = "allowed-strings";
547
+ else if (parsedConstraints->allowedLexemes) tempPtr = "allowed-lexemes";
548
+ else if (parsedConstraints->allowedIntegers) tempPtr = "allowed-integers";
549
+ else if (parsedConstraints->allowedFloats) tempPtr = "allowed-floats";
550
+ else if (parsedConstraints->allowedNumbers) tempPtr = "allowed-numbers";
551
+ else if (parsedConstraints->allowedInstanceNames) tempPtr = "allowed-instance-names";
552
+ NoConjunctiveUseError(theEnv,"allowed-values",tempPtr);
553
+ return false;
554
+ }
555
+
556
+ /*=======================================================*/
557
+ /* The allowed-values/numbers/integers/floats attributes */
558
+ /* are not allowed with the range attribute. */
559
+ /*=======================================================*/
560
+
561
+ if (((strcmp(constraintName,"allowed-values") == 0) ||
562
+ (strcmp(constraintName,"allowed-numbers") == 0) ||
563
+ (strcmp(constraintName,"allowed-integers") == 0) ||
564
+ (strcmp(constraintName,"allowed-floats") == 0)) &&
565
+ (parsedConstraints->range))
566
+ {
567
+ NoConjunctiveUseError(theEnv,constraintName,"range");
568
+ return false;
569
+ }
570
+
571
+ /*===================================================*/
572
+ /* The allowed-... attributes are not allowed if the */
573
+ /* allowed-values attribute has already been parsed. */
574
+ /*===================================================*/
575
+
576
+ if ((strcmp(constraintName,"allowed-values") != 0) &&
577
+ (parsedConstraints->allowedValues))
578
+ {
579
+ NoConjunctiveUseError(theEnv,constraintName,"allowed-values");
580
+ return false;
581
+ }
582
+
583
+ /*==================================================*/
584
+ /* The allowed-numbers attribute is not allowed if */
585
+ /* the allowed-integers or allowed-floats attribute */
586
+ /* has already been parsed. */
587
+ /*==================================================*/
588
+
589
+ if ((strcmp(constraintName,"allowed-numbers") == 0) &&
590
+ ((parsedConstraints->allowedFloats) || (parsedConstraints->allowedIntegers)))
591
+ {
592
+ if (parsedConstraints->allowedFloats) tempPtr = "allowed-floats";
593
+ else tempPtr = "allowed-integers";
594
+ NoConjunctiveUseError(theEnv,"allowed-numbers",tempPtr);
595
+ return false;
596
+ }
597
+
598
+ /*============================================================*/
599
+ /* The allowed-integers/floats attributes are not allowed if */
600
+ /* the allowed-numbers attribute has already been parsed. */
601
+ /*============================================================*/
602
+
603
+ if (((strcmp(constraintName,"allowed-integers") == 0) ||
604
+ (strcmp(constraintName,"allowed-floats") == 0)) &&
605
+ (parsedConstraints->allowedNumbers))
606
+ {
607
+ NoConjunctiveUseError(theEnv,constraintName,"allowed-number");
608
+ return false;
609
+ }
610
+
611
+ /*==================================================*/
612
+ /* The allowed-lexemes attribute is not allowed if */
613
+ /* the allowed-symbols or allowed-strings attribute */
614
+ /* has already been parsed. */
615
+ /*==================================================*/
616
+
617
+ if ((strcmp(constraintName,"allowed-lexemes") == 0) &&
618
+ ((parsedConstraints->allowedSymbols) || (parsedConstraints->allowedStrings)))
619
+ {
620
+ if (parsedConstraints->allowedSymbols) tempPtr = "allowed-symbols";
621
+ else tempPtr = "allowed-strings";
622
+ NoConjunctiveUseError(theEnv,"allowed-lexemes",tempPtr);
623
+ return false;
624
+ }
625
+
626
+ /*===========================================================*/
627
+ /* The allowed-symbols/strings attributes are not allowed if */
628
+ /* the allowed-lexemes attribute has already been parsed. */
629
+ /*===========================================================*/
630
+
631
+ if (((strcmp(constraintName,"allowed-symbols") == 0) ||
632
+ (strcmp(constraintName,"allowed-strings") == 0)) &&
633
+ (parsedConstraints->allowedLexemes))
634
+ {
635
+ NoConjunctiveUseError(theEnv,constraintName,"allowed-lexemes");
636
+ return false;
637
+ }
638
+
639
+ /*========================*/
640
+ /* Get the expected type. */
641
+ /*========================*/
642
+
643
+ restrictionType = GetConstraintTypeFromAllowedName(constraintName);
644
+ SetRestrictionFlag(restrictionType,constraints,true);
645
+ if (strcmp(constraintName,"allowed-classes") == 0)
646
+ { expectedType = SYMBOL_TYPE; }
647
+ else
648
+ { expectedType = restrictionType; }
649
+
650
+ /*=================================================*/
651
+ /* Get the last value in the restriction list (the */
652
+ /* allowed values will be appended there). */
653
+ /*=================================================*/
654
+
655
+ if (strcmp(constraintName,"allowed-classes") == 0)
656
+ { lastValue = constraints->classList; }
657
+ else
658
+ { lastValue = constraints->restrictionList; }
659
+
660
+ if (lastValue != NULL)
661
+ { while (lastValue->nextArg != NULL) lastValue = lastValue->nextArg; }
662
+
663
+ /*==================================================*/
664
+ /* Read the allowed values and add them to the list */
665
+ /* until a right parenthesis is encountered. */
666
+ /*==================================================*/
667
+
668
+ SavePPBuffer(theEnv," ");
669
+ GetToken(theEnv,readSource,&inputToken);
670
+
671
+ while (inputToken.tknType != RIGHT_PARENTHESIS_TOKEN)
672
+ {
673
+ SavePPBuffer(theEnv," ");
674
+
675
+ /*=============================================*/
676
+ /* Determine the type of the token just parsed */
677
+ /* and if it is an appropriate value. */
678
+ /*=============================================*/
679
+
680
+ switch(inputToken.tknType)
681
+ {
682
+ case INTEGER_TOKEN:
683
+ if ((expectedType != UNKNOWN_VALUE) &&
684
+ (expectedType != INTEGER_TYPE) &&
685
+ (expectedType != INTEGER_OR_FLOAT)) error = true;
686
+ constantParsed = true;
687
+ genType = INTEGER_TYPE;
688
+ break;
689
+
690
+ case FLOAT_TOKEN:
691
+ if ((expectedType != UNKNOWN_VALUE) &&
692
+ (expectedType != FLOAT_TYPE) &&
693
+ (expectedType != INTEGER_OR_FLOAT)) error = true;
694
+ constantParsed = true;
695
+ genType = FLOAT_TYPE;
696
+ break;
697
+
698
+ case STRING_TOKEN:
699
+ if ((expectedType != UNKNOWN_VALUE) &&
700
+ (expectedType != STRING_TYPE) &&
701
+ (expectedType != SYMBOL_OR_STRING)) error = true;
702
+ constantParsed = true;
703
+ genType = STRING_TYPE;
704
+ break;
705
+
706
+ case SYMBOL_TOKEN:
707
+ if ((expectedType != UNKNOWN_VALUE) &&
708
+ (expectedType != SYMBOL_TYPE) &&
709
+ (expectedType != SYMBOL_OR_STRING)) error = true;
710
+ constantParsed = true;
711
+ genType = SYMBOL_TYPE;
712
+ break;
713
+
714
+ #if OBJECT_SYSTEM
715
+ case INSTANCE_NAME_TOKEN:
716
+ if ((expectedType != UNKNOWN_VALUE) &&
717
+ (expectedType != INSTANCE_NAME_TYPE)) error = true;
718
+ constantParsed = true;
719
+ genType = INSTANCE_NAME_TYPE;
720
+ break;
721
+ #endif
722
+
723
+ case SF_VARIABLE_TOKEN:
724
+ if (strcmp(inputToken.printForm,"?VARIABLE") == 0)
725
+ {
726
+ variableParsed = true;
727
+ genType = SF_VARIABLE;
728
+ }
729
+ else
730
+ {
731
+ char tempBuffer[120];
732
+ gensnprintf(tempBuffer,sizeof(tempBuffer),"%s attribute",constraintName);
733
+ SyntaxErrorMessage(theEnv,tempBuffer);
734
+ return false;
735
+ }
736
+
737
+ break;
738
+
739
+ default:
740
+ {
741
+ char tempBuffer[120];
742
+ gensnprintf(tempBuffer,sizeof(tempBuffer),"%s attribute",constraintName);
743
+ SyntaxErrorMessage(theEnv,tempBuffer);
744
+ }
745
+ return false;
746
+ }
747
+
748
+ /*=====================================*/
749
+ /* Signal an error if an inappropriate */
750
+ /* value was found. */
751
+ /*=====================================*/
752
+
753
+ if (error)
754
+ {
755
+ PrintErrorID(theEnv,"CSTRNPSR",4,true);
756
+ WriteString(theEnv,STDERR,"Value does not match the expected type for the '");
757
+ WriteString(theEnv,STDERR,constraintName);
758
+ WriteString(theEnv,STDERR,"' attribute.\n");
759
+ return false;
760
+ }
761
+
762
+ /*======================================*/
763
+ /* The ?VARIABLE argument can't be used */
764
+ /* in conjunction with constants. */
765
+ /*======================================*/
766
+
767
+ if (constantParsed && variableParsed)
768
+ {
769
+ char tempBuffer[120];
770
+ gensnprintf(tempBuffer,sizeof(tempBuffer),"%s attribute",constraintName);
771
+ SyntaxErrorMessage(theEnv,tempBuffer);
772
+ return false;
773
+ }
774
+
775
+ /*===========================================*/
776
+ /* Add the constant to the restriction list. */
777
+ /*===========================================*/
778
+
779
+ newValue = GenConstant(theEnv,genType,inputToken.value);
780
+
781
+ if (lastValue == NULL)
782
+ {
783
+ if (strcmp(constraintName,"allowed-classes") == 0)
784
+ { constraints->classList = newValue; }
785
+ else
786
+ { constraints->restrictionList = newValue; }
787
+ }
788
+ else
789
+ { lastValue->nextArg = newValue; }
790
+ lastValue = newValue;
791
+
792
+ /*=======================================*/
793
+ /* Begin parsing the next allowed value. */
794
+ /*=======================================*/
795
+
796
+ GetToken(theEnv,readSource,&inputToken);
797
+ }
798
+
799
+ /*======================================================*/
800
+ /* There must be at least one value for this attribute. */
801
+ /*======================================================*/
802
+
803
+ if ((! constantParsed) && (! variableParsed))
804
+ {
805
+ char tempBuffer[120];
806
+ gensnprintf(tempBuffer,sizeof(tempBuffer),"%s attribute",constraintName);
807
+ SyntaxErrorMessage(theEnv,tempBuffer);
808
+ return false;
809
+ }
810
+
811
+ /*======================================*/
812
+ /* If ?VARIABLE was parsed, then remove */
813
+ /* the restrictions for the type being */
814
+ /* restricted. */
815
+ /*======================================*/
816
+
817
+ if (variableParsed)
818
+ {
819
+ switch(restrictionType)
820
+ {
821
+ case UNKNOWN_VALUE:
822
+ constraints->anyRestriction = false;
823
+ break;
824
+
825
+ case SYMBOL_TYPE:
826
+ constraints->symbolRestriction = false;
827
+ break;
828
+
829
+ case STRING_TYPE:
830
+ constraints->stringRestriction = false;
831
+ break;
832
+
833
+ case INTEGER_TYPE:
834
+ constraints->integerRestriction = false;
835
+ break;
836
+
837
+ case FLOAT_TYPE:
838
+ constraints->floatRestriction = false;
839
+ break;
840
+
841
+ case INTEGER_OR_FLOAT:
842
+ constraints->floatRestriction = false;
843
+ constraints->integerRestriction = false;
844
+ break;
845
+
846
+ case SYMBOL_OR_STRING:
847
+ constraints->symbolRestriction = false;
848
+ constraints->stringRestriction = false;
849
+ break;
850
+
851
+ case INSTANCE_NAME_TYPE:
852
+ constraints->instanceNameRestriction = false;
853
+ break;
854
+
855
+ case INSTANCE_OR_INSTANCE_NAME:
856
+ constraints->classRestriction = false;
857
+ break;
858
+ }
859
+ }
860
+
861
+ /*=====================================*/
862
+ /* Fix up pretty print representation. */
863
+ /*=====================================*/
864
+
865
+ PPBackup(theEnv);
866
+ PPBackup(theEnv);
867
+ SavePPBuffer(theEnv,")");
868
+
869
+ /*=======================================*/
870
+ /* Return true to indicate the attribute */
871
+ /* was successfully parsed. */
872
+ /*=======================================*/
873
+
874
+ return true;
875
+ }
876
+
877
+ /***********************************************************/
878
+ /* NoConjunctiveUseError: Generic error message indicating */
879
+ /* that two attributes can't be used in conjunction. */
880
+ /***********************************************************/
881
+ static void NoConjunctiveUseError(
882
+ Environment *theEnv,
883
+ const char *attribute1,
884
+ const char *attribute2)
885
+ {
886
+ PrintErrorID(theEnv,"CSTRNPSR",3,true);
887
+ WriteString(theEnv,STDERR,"The '");
888
+ WriteString(theEnv,STDERR,attribute1);
889
+ WriteString(theEnv,STDERR,"' attribute cannot be used ");
890
+ WriteString(theEnv,STDERR,"in conjunction with the '");
891
+ WriteString(theEnv,STDERR,attribute2);
892
+ WriteString(theEnv,STDERR,"' attribute.\n");
893
+ }
894
+
895
+ /**************************************************/
896
+ /* ParseTypeAttribute: Parses the type attribute. */
897
+ /**************************************************/
898
+ static bool ParseTypeAttribute(
899
+ Environment *theEnv,
900
+ const char *readSource,
901
+ CONSTRAINT_RECORD *constraints)
902
+ {
903
+ bool typeParsed = false;
904
+ bool variableParsed = false;
905
+ int theType;
906
+ struct token inputToken;
907
+
908
+ /*======================================*/
909
+ /* Continue parsing types until a right */
910
+ /* parenthesis is encountered. */
911
+ /*======================================*/
912
+
913
+ SavePPBuffer(theEnv," ");
914
+ for (GetToken(theEnv,readSource,&inputToken);
915
+ inputToken.tknType != RIGHT_PARENTHESIS_TOKEN;
916
+ GetToken(theEnv,readSource,&inputToken))
917
+ {
918
+ SavePPBuffer(theEnv," ");
919
+
920
+ /*==================================*/
921
+ /* If the token is a symbol then... */
922
+ /*==================================*/
923
+
924
+ if (inputToken.tknType == SYMBOL_TOKEN)
925
+ {
926
+ /*==============================================*/
927
+ /* ?VARIABLE can't be used with type constants. */
928
+ /*==============================================*/
929
+
930
+ if (variableParsed == true)
931
+ {
932
+ SyntaxErrorMessage(theEnv,"type attribute");
933
+ return false;
934
+ }
935
+
936
+ /*========================================*/
937
+ /* Check for an appropriate type constant */
938
+ /* (e.g. SYMBOL_TYPE, FLOAT_TYPE, INTEGER_TYPE, etc.). */
939
+ /*========================================*/
940
+
941
+ theType = GetConstraintTypeFromTypeName(inputToken.lexemeValue->contents);
942
+ if (theType < 0)
943
+ {
944
+ SyntaxErrorMessage(theEnv,"type attribute");
945
+ return false;
946
+ }
947
+
948
+ /*==================================================*/
949
+ /* Change the type restriction flags to reflect the */
950
+ /* type restriction. If the type restriction was */
951
+ /* already specified, then a error is generated. */
952
+ /*==================================================*/
953
+
954
+ if (SetConstraintType(theType,constraints))
955
+ {
956
+ SyntaxErrorMessage(theEnv,"type attribute");
957
+ return false;
958
+ }
959
+
960
+ constraints->anyAllowed = false;
961
+
962
+ /*===========================================*/
963
+ /* Remember that a type constant was parsed. */
964
+ /*===========================================*/
965
+
966
+ typeParsed = true;
967
+ }
968
+
969
+ /*==============================================*/
970
+ /* Otherwise if the token is a variable then... */
971
+ /*==============================================*/
972
+
973
+ else if (inputToken.tknType == SF_VARIABLE_TOKEN)
974
+ {
975
+ /*========================================*/
976
+ /* The only variable allowd is ?VARIABLE. */
977
+ /*========================================*/
978
+
979
+ if (strcmp(inputToken.printForm,"?VARIABLE") != 0)
980
+ {
981
+ SyntaxErrorMessage(theEnv,"type attribute");
982
+ return false;
983
+ }
984
+
985
+ /*===================================*/
986
+ /* ?VARIABLE can't be used more than */
987
+ /* once or with type constants. */
988
+ /*===================================*/
989
+
990
+ if (typeParsed || variableParsed)
991
+ {
992
+ SyntaxErrorMessage(theEnv,"type attribute");
993
+ return false;
994
+ }
995
+
996
+ /*======================================*/
997
+ /* Remember that a variable was parsed. */
998
+ /*======================================*/
999
+
1000
+ variableParsed = true;
1001
+ }
1002
+
1003
+ /*====================================*/
1004
+ /* Otherwise this is an invalid value */
1005
+ /* for the type attribute. */
1006
+ /*====================================*/
1007
+
1008
+ else
1009
+ {
1010
+ SyntaxErrorMessage(theEnv,"type attribute");
1011
+ return false;
1012
+ }
1013
+ }
1014
+
1015
+ /*=====================================*/
1016
+ /* Fix up pretty print representation. */
1017
+ /*=====================================*/
1018
+
1019
+ PPBackup(theEnv);
1020
+ PPBackup(theEnv);
1021
+ SavePPBuffer(theEnv,")");
1022
+
1023
+ /*=======================================*/
1024
+ /* The type attribute must have a value. */
1025
+ /*=======================================*/
1026
+
1027
+ if ((! typeParsed) && (! variableParsed))
1028
+ {
1029
+ SyntaxErrorMessage(theEnv,"type attribute");
1030
+ return false;
1031
+ }
1032
+
1033
+ /*===========================================*/
1034
+ /* Return true indicating the type attibuted */
1035
+ /* was successfully parsed. */
1036
+ /*===========================================*/
1037
+
1038
+ return true;
1039
+ }
1040
+
1041
+ /***************************************************************************/
1042
+ /* ParseRangeCardinalityAttribute: Parses the range/cardinality attribute. */
1043
+ /***************************************************************************/
1044
+ static bool ParseRangeCardinalityAttribute(
1045
+ Environment *theEnv,
1046
+ const char *readSource,
1047
+ CONSTRAINT_RECORD *constraints,
1048
+ CONSTRAINT_PARSE_RECORD *parsedConstraints,
1049
+ const char *constraintName,
1050
+ bool multipleValuesAllowed)
1051
+ {
1052
+ struct token inputToken;
1053
+ bool range;
1054
+ const char *tempPtr = NULL;
1055
+
1056
+ /*=================================*/
1057
+ /* Determine if we're parsing the */
1058
+ /* range or cardinality attribute. */
1059
+ /*=================================*/
1060
+
1061
+ if (strcmp(constraintName,"range") == 0)
1062
+ {
1063
+ parsedConstraints->range = true;
1064
+ range = true;
1065
+ }
1066
+ else
1067
+ {
1068
+ parsedConstraints->cardinality = true;
1069
+ range = false;
1070
+ }
1071
+
1072
+ /*===================================================================*/
1073
+ /* The cardinality attribute can only be used with multifield slots. */
1074
+ /*===================================================================*/
1075
+
1076
+ if ((range == false) &&
1077
+ (multipleValuesAllowed == false))
1078
+ {
1079
+ PrintErrorID(theEnv,"CSTRNPSR",5,true);
1080
+ WriteString(theEnv,STDERR,"The 'cardinality' attribute ");
1081
+ WriteString(theEnv,STDERR,"can only be used with multifield slots.\n");
1082
+ return false;
1083
+ }
1084
+
1085
+ /*====================================================*/
1086
+ /* The range attribute is not allowed with the */
1087
+ /* allowed-values/numbers/integers/floats attributes. */
1088
+ /*====================================================*/
1089
+
1090
+ if ((range == true) &&
1091
+ (parsedConstraints->allowedValues ||
1092
+ parsedConstraints->allowedNumbers ||
1093
+ parsedConstraints->allowedIntegers ||
1094
+ parsedConstraints->allowedFloats))
1095
+ {
1096
+ if (parsedConstraints->allowedValues) tempPtr = "allowed-values";
1097
+ else if (parsedConstraints->allowedIntegers) tempPtr = "allowed-integers";
1098
+ else if (parsedConstraints->allowedFloats) tempPtr = "allowed-floats";
1099
+ else if (parsedConstraints->allowedNumbers) tempPtr = "allowed-numbers";
1100
+ NoConjunctiveUseError(theEnv,"range",tempPtr);
1101
+ return false;
1102
+ }
1103
+
1104
+ /*==========================*/
1105
+ /* Parse the minimum value. */
1106
+ /*==========================*/
1107
+
1108
+ SavePPBuffer(theEnv," ");
1109
+ GetToken(theEnv,readSource,&inputToken);
1110
+ if ((inputToken.tknType == INTEGER_TOKEN) || ((inputToken.tknType == FLOAT_TOKEN) && range))
1111
+ {
1112
+ if (range)
1113
+ {
1114
+ ReturnExpression(theEnv,constraints->minValue);
1115
+ if (inputToken.tknType == INTEGER_TOKEN)
1116
+ { constraints->minValue = GenConstant(theEnv,INTEGER_TYPE,inputToken.value); }
1117
+ else
1118
+ { constraints->minValue = GenConstant(theEnv,FLOAT_TYPE,inputToken.value); }
1119
+ }
1120
+ else
1121
+ {
1122
+ if (inputToken.integerValue->contents < 0LL)
1123
+ {
1124
+ PrintErrorID(theEnv,"CSTRNPSR",6,true);
1125
+ WriteString(theEnv,STDERR,"Minimum 'cardinality' value must be greater than or equal to zero.\n");
1126
+ return false;
1127
+ }
1128
+
1129
+ ReturnExpression(theEnv,constraints->minFields);
1130
+ if (inputToken.tknType == INTEGER_TOKEN)
1131
+ { constraints->minFields = GenConstant(theEnv,INTEGER_TYPE,inputToken.value); }
1132
+ else
1133
+ { constraints->minFields = GenConstant(theEnv,FLOAT_TYPE,inputToken.value); }
1134
+ }
1135
+ }
1136
+ else if ((inputToken.tknType == SF_VARIABLE_TOKEN) && (strcmp(inputToken.printForm,"?VARIABLE") == 0))
1137
+ { /* Do nothing. */ }
1138
+ else
1139
+ {
1140
+ char tempBuffer[120];
1141
+ gensnprintf(tempBuffer,sizeof(tempBuffer),"%s attribute",constraintName);
1142
+ SyntaxErrorMessage(theEnv,tempBuffer);
1143
+ return false;
1144
+ }
1145
+
1146
+ /*==========================*/
1147
+ /* Parse the maximum value. */
1148
+ /*==========================*/
1149
+
1150
+ SavePPBuffer(theEnv," ");
1151
+ GetToken(theEnv,readSource,&inputToken);
1152
+ if ((inputToken.tknType == INTEGER_TOKEN) || ((inputToken.tknType == FLOAT_TOKEN) && range))
1153
+ {
1154
+ if (range)
1155
+ {
1156
+ ReturnExpression(theEnv,constraints->maxValue);
1157
+ if (inputToken.tknType == INTEGER_TOKEN)
1158
+ { constraints->maxValue = GenConstant(theEnv,INTEGER_TYPE,inputToken.value); }
1159
+ else
1160
+ { constraints->maxValue = GenConstant(theEnv,FLOAT_TYPE,inputToken.value); }
1161
+ }
1162
+ else
1163
+ {
1164
+ ReturnExpression(theEnv,constraints->maxFields);
1165
+ if (inputToken.tknType == INTEGER_TOKEN)
1166
+ { constraints->maxFields = GenConstant(theEnv,INTEGER_TYPE,inputToken.value); }
1167
+ else
1168
+ { constraints->maxFields = GenConstant(theEnv,FLOAT_TYPE,inputToken.value); }
1169
+ }
1170
+ }
1171
+ else if ((inputToken.tknType == SF_VARIABLE_TOKEN) && (strcmp(inputToken.printForm,"?VARIABLE") == 0))
1172
+ { /* Do nothing. */ }
1173
+ else
1174
+ {
1175
+ char tempBuffer[120];
1176
+ gensnprintf(tempBuffer,sizeof(tempBuffer),"%s attribute",constraintName);
1177
+ SyntaxErrorMessage(theEnv,tempBuffer);
1178
+ return false;
1179
+ }
1180
+
1181
+ /*================================*/
1182
+ /* Parse the closing parenthesis. */
1183
+ /*================================*/
1184
+
1185
+ GetToken(theEnv,readSource,&inputToken);
1186
+ if (inputToken.tknType != RIGHT_PARENTHESIS_TOKEN)
1187
+ {
1188
+ SyntaxErrorMessage(theEnv,"range attribute");
1189
+ return false;
1190
+ }
1191
+
1192
+ /*====================================================*/
1193
+ /* Minimum value must be less than the maximum value. */
1194
+ /*====================================================*/
1195
+
1196
+ if (range)
1197
+ {
1198
+ if (CompareNumbers(theEnv,constraints->minValue->type,
1199
+ constraints->minValue->value,
1200
+ constraints->maxValue->type,
1201
+ constraints->maxValue->value) == GREATER_THAN)
1202
+ {
1203
+ PrintErrorID(theEnv,"CSTRNPSR",2,true);
1204
+ WriteString(theEnv,STDERR,"Minimum 'range' value must be less than ");
1205
+ WriteString(theEnv,STDERR,"or equal to the maximum 'range' value.\n");
1206
+ return false;
1207
+ }
1208
+ }
1209
+ else
1210
+ {
1211
+ if (CompareNumbers(theEnv,constraints->minFields->type,
1212
+ constraints->minFields->value,
1213
+ constraints->maxFields->type,
1214
+ constraints->maxFields->value) == GREATER_THAN)
1215
+ {
1216
+ PrintErrorID(theEnv,"CSTRNPSR",2,true);
1217
+ WriteString(theEnv,STDERR,"Minimum 'cardinality' value must be less than ");
1218
+ WriteString(theEnv,STDERR,"or equal to the maximum 'cardinality' value.\n");
1219
+ return false;
1220
+ }
1221
+ }
1222
+
1223
+ /*====================================*/
1224
+ /* Return true to indicate that the */
1225
+ /* attribute was successfully parsed. */
1226
+ /*====================================*/
1227
+
1228
+ return true;
1229
+ }
1230
+
1231
+ /******************************************************************/
1232
+ /* GetConstraintTypeFromAllowedName: Returns the type restriction */
1233
+ /* associated with an allowed-... attribute. */
1234
+ /******************************************************************/
1235
+ static int GetConstraintTypeFromAllowedName(
1236
+ const char *constraintName)
1237
+ {
1238
+ if (strcmp(constraintName,"allowed-values") == 0) return(UNKNOWN_VALUE);
1239
+ else if (strcmp(constraintName,"allowed-symbols") == 0) return(SYMBOL_TYPE);
1240
+ else if (strcmp(constraintName,"allowed-strings") == 0) return(STRING_TYPE);
1241
+ else if (strcmp(constraintName,"allowed-lexemes") == 0) return(SYMBOL_OR_STRING);
1242
+ else if (strcmp(constraintName,"allowed-integers") == 0) return(INTEGER_TYPE);
1243
+ else if (strcmp(constraintName,"allowed-numbers") == 0) return(INTEGER_OR_FLOAT);
1244
+ else if (strcmp(constraintName,"allowed-instance-names") == 0) return(INSTANCE_NAME_TYPE);
1245
+ else if (strcmp(constraintName,"allowed-classes") == 0) return(INSTANCE_OR_INSTANCE_NAME);
1246
+ else if (strcmp(constraintName,"allowed-floats") == 0) return(FLOAT_TYPE);
1247
+
1248
+ return(-1);
1249
+ }
1250
+
1251
+ /*******************************************************/
1252
+ /* GetConstraintTypeFromTypeName: Converts a type name */
1253
+ /* to its equivalent integer type restriction. */
1254
+ /*******************************************************/
1255
+ static int GetConstraintTypeFromTypeName(
1256
+ const char *constraintName)
1257
+ {
1258
+ if (strcmp(constraintName,"SYMBOL") == 0) return(SYMBOL_TYPE);
1259
+ else if (strcmp(constraintName,"STRING") == 0) return(STRING_TYPE);
1260
+ else if (strcmp(constraintName,"LEXEME") == 0) return(SYMBOL_OR_STRING);
1261
+ else if (strcmp(constraintName,"INTEGER") == 0) return(INTEGER_TYPE);
1262
+ else if (strcmp(constraintName,"FLOAT") == 0) return(FLOAT_TYPE);
1263
+ else if (strcmp(constraintName,"NUMBER") == 0) return(INTEGER_OR_FLOAT);
1264
+ else if (strcmp(constraintName,"INSTANCE-NAME") == 0) return(INSTANCE_NAME_TYPE);
1265
+ else if (strcmp(constraintName,"INSTANCE-ADDRESS") == 0) return(INSTANCE_ADDRESS_TYPE);
1266
+ else if (strcmp(constraintName,"INSTANCE") == 0) return(INSTANCE_OR_INSTANCE_NAME);
1267
+ else if (strcmp(constraintName,"EXTERNAL-ADDRESS") == 0) return(EXTERNAL_ADDRESS_TYPE);
1268
+ else if (strcmp(constraintName,"FACT-ADDRESS") == 0) return(FACT_ADDRESS_TYPE);
1269
+
1270
+ return(-1);
1271
+ }
1272
+
1273
+ /**************************************************************/
1274
+ /* GetAttributeParseValue: Returns a boolean value indicating */
1275
+ /* whether a specific attribute has already been parsed. */
1276
+ /**************************************************************/
1277
+ static bool GetAttributeParseValue(
1278
+ const char *constraintName,
1279
+ CONSTRAINT_PARSE_RECORD *parsedConstraints)
1280
+ {
1281
+ if (strcmp(constraintName,"type") == 0)
1282
+ { return(parsedConstraints->type); }
1283
+ else if (strcmp(constraintName,"range") == 0)
1284
+ { return(parsedConstraints->range); }
1285
+ else if (strcmp(constraintName,"cardinality") == 0)
1286
+ { return(parsedConstraints->cardinality); }
1287
+ else if (strcmp(constraintName,"allowed-values") == 0)
1288
+ { return(parsedConstraints->allowedValues); }
1289
+ else if (strcmp(constraintName,"allowed-symbols") == 0)
1290
+ { return(parsedConstraints->allowedSymbols); }
1291
+ else if (strcmp(constraintName,"allowed-strings") == 0)
1292
+ { return(parsedConstraints->allowedStrings); }
1293
+ else if (strcmp(constraintName,"allowed-lexemes") == 0)
1294
+ { return(parsedConstraints->allowedLexemes); }
1295
+ else if (strcmp(constraintName,"allowed-instance-names") == 0)
1296
+ { return(parsedConstraints->allowedInstanceNames); }
1297
+ else if (strcmp(constraintName,"allowed-classes") == 0)
1298
+ { return(parsedConstraints->allowedClasses); }
1299
+ else if (strcmp(constraintName,"allowed-integers") == 0)
1300
+ { return(parsedConstraints->allowedIntegers); }
1301
+ else if (strcmp(constraintName,"allowed-floats") == 0)
1302
+ { return(parsedConstraints->allowedFloats); }
1303
+ else if (strcmp(constraintName,"allowed-numbers") == 0)
1304
+ { return(parsedConstraints->allowedNumbers); }
1305
+
1306
+ return true;
1307
+ }
1308
+
1309
+ /**********************************************************/
1310
+ /* SetRestrictionFlag: Sets the restriction flag of a */
1311
+ /* constraint record indicating whether a specific */
1312
+ /* type has an associated allowed-... restriction list. */
1313
+ /**********************************************************/
1314
+ static void SetRestrictionFlag(
1315
+ int restriction,
1316
+ CONSTRAINT_RECORD *constraints,
1317
+ bool value)
1318
+ {
1319
+ switch (restriction)
1320
+ {
1321
+ case UNKNOWN_VALUE:
1322
+ constraints->anyRestriction = value;
1323
+ break;
1324
+
1325
+ case SYMBOL_TYPE:
1326
+ constraints->symbolRestriction = value;
1327
+ break;
1328
+
1329
+ case STRING_TYPE:
1330
+ constraints->stringRestriction = value;
1331
+ break;
1332
+
1333
+ case INTEGER_TYPE:
1334
+ constraints->integerRestriction = value;
1335
+ break;
1336
+
1337
+ case FLOAT_TYPE:
1338
+ constraints->floatRestriction = value;
1339
+ break;
1340
+
1341
+ case INTEGER_OR_FLOAT:
1342
+ constraints->integerRestriction = value;
1343
+ constraints->floatRestriction = value;
1344
+ break;
1345
+
1346
+ case SYMBOL_OR_STRING:
1347
+ constraints->symbolRestriction = value;
1348
+ constraints->stringRestriction = value;
1349
+ break;
1350
+
1351
+ case INSTANCE_NAME_TYPE:
1352
+ constraints->instanceNameRestriction = value;
1353
+ break;
1354
+
1355
+ case INSTANCE_OR_INSTANCE_NAME:
1356
+ constraints->classRestriction = value;
1357
+ break;
1358
+ }
1359
+ }
1360
+
1361
+ /********************************************************************/
1362
+ /* SetParseFlag: Sets the flag in a parsed constraints data */
1363
+ /* structure indicating that a specific attribute has been parsed. */
1364
+ /********************************************************************/
1365
+ static void SetParseFlag(
1366
+ CONSTRAINT_PARSE_RECORD *parsedConstraints,
1367
+ const char *constraintName)
1368
+ {
1369
+ if (strcmp(constraintName,"range") == 0)
1370
+ { parsedConstraints->range = true; }
1371
+ else if (strcmp(constraintName,"type") == 0)
1372
+ { parsedConstraints->type = true; }
1373
+ else if (strcmp(constraintName,"cardinality") == 0)
1374
+ { parsedConstraints->cardinality = true; }
1375
+ else if (strcmp(constraintName,"allowed-symbols") == 0)
1376
+ { parsedConstraints->allowedSymbols = true; }
1377
+ else if (strcmp(constraintName,"allowed-strings") == 0)
1378
+ { parsedConstraints->allowedStrings = true; }
1379
+ else if (strcmp(constraintName,"allowed-lexemes") == 0)
1380
+ { parsedConstraints->allowedLexemes = true; }
1381
+ else if (strcmp(constraintName,"allowed-integers") == 0)
1382
+ { parsedConstraints->allowedIntegers = true; }
1383
+ else if (strcmp(constraintName,"allowed-floats") == 0)
1384
+ { parsedConstraints->allowedFloats = true; }
1385
+ else if (strcmp(constraintName,"allowed-numbers") == 0)
1386
+ { parsedConstraints->allowedNumbers = true; }
1387
+ else if (strcmp(constraintName,"allowed-values") == 0)
1388
+ { parsedConstraints->allowedValues = true; }
1389
+ else if (strcmp(constraintName,"allowed-classes") == 0)
1390
+ { parsedConstraints->allowedClasses = true; }
1391
+ }
1392
+
1393
+ #endif /* (! RUN_TIME) && (! BLOAD_ONLY) */
1394
+