wmlsynbld.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * @OSF_COPYRIGHT@
  25. * COPYRIGHT NOTICE
  26. * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
  27. * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
  28. * the full copyright text.
  29. */
  30. /*
  31. * HISTORY
  32. */
  33. #ifdef REV_INFO
  34. #ifndef lint
  35. static char rcsid[] = "$XConsortium: wmlsynbld.c /main/9 1995/08/29 11:11:12 drk $"
  36. #endif
  37. #endif
  38. /*
  39. * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  40. /*
  41. * This module contains the programs which construct the syntactic
  42. * representation of the WML input. All the routines are called as
  43. * actions of the grammar productions.
  44. *
  45. * Since WML is so simple, no stack frame technology is used. Instead,
  46. * context is maintained by global pointers and vectors which contain
  47. * the intermediate results of parsing a statement. At most, these
  48. * contain an object being constructed (for instance a class descriptor)
  49. * and a subobject (for instance a resource reference in a class).
  50. *
  51. * Results are communicated back using the global error count
  52. * wml_err_count, and the ordered handle list wml_synobj_ptr.
  53. */
  54. #include "wml.h"
  55. #include "wmlparse.h"
  56. #if defined(__STDC__)
  57. #include <stdlib.h>
  58. #endif
  59. #include <stdio.h>
  60. /*
  61. * Globals used during WML parsing.
  62. */
  63. /*
  64. * Character arrays and other variables to hold lexemes
  65. * are defined in wmllex.l
  66. */
  67. /*
  68. * Current principal object being constructed
  69. * Current subobject
  70. */
  71. ObjectPtr wml_cur_obj;
  72. ObjectPtr wml_cur_subobj;
  73. /*
  74. * Routine to create a class descriptor. The result is placed in both
  75. * wml_cur_obj and wml_synobj.
  76. *
  77. * name the class name
  78. * ctype class type, one of METACLASS | WIDGET | GADGET
  79. */
  80. void wmlCreateClass (name, ctype)
  81. char *name;
  82. int ctype;
  83. {
  84. WmlSynClassDefPtr cdesc; /* new class descriptor */
  85. /*
  86. * Initialize the new class descriptor. Enter it in the object list.
  87. * Set the current object global to the descriptor.
  88. */
  89. cdesc = (WmlSynClassDefPtr) malloc (sizeof(WmlSynClassDef));
  90. cdesc->validation = WmlClassDefValid;
  91. cdesc->rslvdef = NULL;
  92. switch ( ctype )
  93. {
  94. case METACLASS:
  95. cdesc->type = WmlClassTypeMetaclass;
  96. break;
  97. case WIDGET:
  98. cdesc->type = WmlClassTypeWidget;
  99. break;
  100. case GADGET:
  101. cdesc->type = WmlClassTypeGadget;
  102. break;
  103. default:
  104. printf ("\nwmlCreateClass: unknown class type %d", ctype);
  105. return;
  106. break;
  107. }
  108. cdesc->dialog = FALSE;
  109. cdesc->name = wmlAllocateString (name);
  110. cdesc->superclass = NULL;
  111. cdesc->parentclass = NULL;
  112. cdesc->widgetclass = NULL;
  113. cdesc->int_lit = NULL;
  114. cdesc->convfunc = NULL;
  115. cdesc->docname = NULL;
  116. cdesc->ctrlmapto = NULL;
  117. cdesc->controls = NULL;
  118. cdesc->resources = NULL;
  119. cdesc->children = NULL;
  120. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  121. {
  122. printf ("\nDuplicate name %s found", name);
  123. return;
  124. }
  125. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)cdesc);
  126. wml_cur_obj = (ObjectPtr) cdesc;
  127. wml_cur_subobj = NULL;
  128. return;
  129. }
  130. /*
  131. * Routine to create a resource descriptor. The result is placed in both
  132. * wml_cur_obj and wml_synobj.
  133. *
  134. * name the resource name
  135. * rtype resource type, one of
  136. * ARGUMENT | REASON | CONSTRAINT | SUBRESOURCE
  137. */
  138. void wmlCreateResource (name, rtype)
  139. char *name;
  140. int rtype;
  141. {
  142. WmlSynResourceDefPtr rdesc; /* new resource descriptor */
  143. /*
  144. * Initialize the new resource descriptor. Enter it in the object list.
  145. * Set the current object global to the descriptor.
  146. */
  147. rdesc = (WmlSynResourceDefPtr) malloc (sizeof(WmlSynResourceDef));
  148. rdesc->validation = WmlResourceDefValid;
  149. rdesc->rslvdef = NULL;
  150. switch ( rtype )
  151. {
  152. case ARGUMENT:
  153. rdesc->type = WmlResourceTypeArgument;
  154. rdesc->xrm_support = WmlAttributeTrue;
  155. break;
  156. case REASON:
  157. rdesc->type = WmlResourceTypeReason;
  158. rdesc->xrm_support = WmlAttributeFalse;
  159. break;
  160. case CONSTRAINT:
  161. rdesc->type = WmlResourceTypeConstraint;
  162. rdesc->xrm_support = WmlAttributeTrue;
  163. break;
  164. case SUBRESOURCE:
  165. rdesc->type = WmlResourceTypeSubResource;
  166. rdesc->xrm_support = WmlAttributeTrue;
  167. break;
  168. default:
  169. printf ("\nwmlCreateResource: unknown resource type %d", rtype);
  170. return;
  171. break;
  172. }
  173. rdesc->name = wmlAllocateString (name);
  174. rdesc->datatype = NULL;
  175. rdesc->int_lit = NULL;
  176. rdesc->resliteral = wmlAllocateString (name); /* default to name */
  177. rdesc->enumset = NULL;
  178. rdesc->docname = NULL;
  179. rdesc->related = NULL;
  180. rdesc->dflt = NULL;
  181. rdesc->alias_cnt = 0;
  182. rdesc->alias_list = NULL;
  183. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  184. {
  185. printf ("\nDuplicate name %s found", name);
  186. return;
  187. }
  188. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)rdesc);
  189. wml_cur_obj = (ObjectPtr) rdesc;
  190. wml_cur_subobj = NULL;
  191. return;
  192. }
  193. /*
  194. * Routine to create a datatype descriptor. The result is placed in both
  195. * wml_cur_obj and wml_synobj.
  196. *
  197. * name the datatype name
  198. */
  199. void wmlCreateDatatype (name)
  200. char *name;
  201. {
  202. WmlSynDataTypeDefPtr ddesc; /* new datatype descriptor */
  203. /*
  204. * Initialize the new datatype descriptor. Enter it in the object list.
  205. * Set the current object global to the descriptor.
  206. */
  207. ddesc = (WmlSynDataTypeDefPtr) malloc (sizeof(WmlSynDataTypeDef));
  208. ddesc->validation = WmlDataTypeDefValid;
  209. ddesc->rslvdef = NULL;
  210. ddesc->name = wmlAllocateString (name);
  211. ddesc->int_lit = NULL;
  212. ddesc->docname = NULL;
  213. ddesc->xrm_support = WmlAttributeTrue;
  214. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  215. {
  216. printf ("\nDuplicate name %s found", name);
  217. return;
  218. }
  219. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)ddesc);
  220. wml_cur_obj = (ObjectPtr) ddesc;
  221. wml_cur_subobj = NULL;
  222. return;
  223. }
  224. /*
  225. * Routine to create a child descriptor. The result is placed in both
  226. * wml_cur_obj and wml_synobj.
  227. *
  228. * name the child name
  229. * class the class name
  230. */
  231. void wmlCreateChild (name, class)
  232. char *name;
  233. char *class;
  234. {
  235. WmlSynChildDefPtr chdesc; /* new child descriptor */
  236. /*
  237. * Initialize the new child descriptor. Enter it in the object list.
  238. * Set the current object global to the descriptor.
  239. */
  240. chdesc = (WmlSynChildDefPtr) malloc (sizeof(WmlSynChildDef));
  241. chdesc->validation = WmlChildDefValid;
  242. chdesc->rslvdef = NULL;
  243. chdesc->name = wmlAllocateString (name);
  244. chdesc->class = wmlAllocateString (class);
  245. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  246. {
  247. printf ("\nDuplicate name %s found", name);
  248. return;
  249. }
  250. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)chdesc);
  251. wml_cur_obj = (ObjectPtr) chdesc;
  252. wml_cur_subobj = NULL;
  253. return;
  254. }
  255. /*
  256. * Routine to create a controls list descriptor. The result is placed in both
  257. * wml_cur_obj and wml_synobj.
  258. *
  259. * name the controls list name
  260. */
  261. void wmlCreateOrAppendCtrlList (name)
  262. char *name;
  263. {
  264. int idx;
  265. WmlSynCtrlListDefPtr cdesc; /* new CtrlList descriptor */
  266. idx = wmlFindInHList(wml_synobj_ptr,name);
  267. if (idx < 0 ) {
  268. /* Didn't find list */
  269. /*
  270. * Initialize the new CtrlList descriptor. Enter it in the object list.
  271. * Set the current object global to the descriptor.
  272. */
  273. cdesc = (WmlSynCtrlListDefPtr) malloc (sizeof(WmlSynCtrlListDef));
  274. cdesc->validation = WmlCtrlListDefValid;
  275. cdesc->rslvdef = NULL;
  276. cdesc->name = wmlAllocateString (name);
  277. cdesc->controls = NULL;
  278. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)cdesc);
  279. } else {
  280. cdesc = (WmlSynCtrlListDefPtr) wml_synobj_ptr -> hvec[idx].objptr;
  281. printf ("\nAppending to list name %s", name);
  282. }
  283. wml_cur_obj = (ObjectPtr) cdesc;
  284. wml_cur_subobj = NULL;
  285. return;
  286. }
  287. /*
  288. * Routine to create an enumeration set descriptor. The result is placed in both
  289. * wml_cur_obj and wml_synobj.
  290. *
  291. * name the enumeration set name
  292. * type data type, must match a data type name
  293. */
  294. void wmlCreateEnumSet (name, dtype)
  295. char *name;
  296. char *dtype;
  297. {
  298. WmlSynEnumSetDefPtr esdesc; /* new enumeration set descriptor */
  299. /*
  300. * Initialize the new resource descriptor. Enter it in the object list.
  301. * Set the current object global to the descriptor.
  302. */
  303. esdesc = (WmlSynEnumSetDefPtr) malloc (sizeof(WmlSynEnumSetDef));
  304. esdesc->validation = WmlEnumSetDefValid;
  305. esdesc->rslvdef = NULL;
  306. esdesc->name = wmlAllocateString (name);
  307. esdesc->datatype = wmlAllocateString (dtype);
  308. esdesc->values = NULL;
  309. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  310. {
  311. printf ("\nDuplicate name %s found", name);
  312. return;
  313. }
  314. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)esdesc);
  315. wml_cur_obj = (ObjectPtr) esdesc;
  316. wml_cur_subobj = NULL;
  317. return;
  318. }
  319. /*
  320. * Routine to create an enumeration value descriptor. The result is placed in both
  321. * wml_cur_obj and wml_synobj.
  322. *
  323. * name the enumeration value name
  324. */
  325. void wmlCreateEnumValue (name)
  326. char *name;
  327. {
  328. WmlSynEnumValueDefPtr evdesc; /* new enumeration value descriptor */
  329. /*
  330. * Initialize the new resource descriptor. Enter it in the object list.
  331. * Set the current object global to the descriptor.
  332. */
  333. evdesc = (WmlSynEnumValueDefPtr) malloc (sizeof(WmlSynEnumValueDef));
  334. evdesc->validation = WmlEnumValueDefValid;
  335. evdesc->rslvdef = NULL;
  336. evdesc->name = wmlAllocateString (name);
  337. evdesc->enumlit = wmlAllocateString (name); /* defaults to name */
  338. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  339. {
  340. printf ("\nDuplicate name %s found", name);
  341. return;
  342. }
  343. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)evdesc);
  344. wml_cur_obj = (ObjectPtr) evdesc;
  345. wml_cur_subobj = NULL;
  346. return;
  347. }
  348. /*
  349. * Routine to create a charset descriptor. The result is placed in both
  350. * wml_cur_obj and wml_synobj.
  351. *
  352. * name the charset name
  353. */
  354. void wmlCreateCharset (name)
  355. char *name;
  356. {
  357. WmlSynCharSetDefPtr ddesc; /* new charset descriptor */
  358. /*
  359. * Initialize the new charset descriptor. Enter it in the object list.
  360. * Set the current object global to the descriptor.
  361. */
  362. ddesc = (WmlSynCharSetDefPtr) malloc (sizeof(WmlSynCharSetDef));
  363. ddesc->validation = WmlCharSetDefValid;
  364. ddesc->rslvdef = NULL;
  365. ddesc->name = wmlAllocateString (name);
  366. ddesc->int_lit = NULL;
  367. ddesc->xms_name = NULL;
  368. ddesc->direction = WmlCharSetDirectionLtoR;
  369. ddesc->parsedirection = WmlAttributeUnspecified;
  370. ddesc->charsize = WmlCharSizeOneByte;
  371. ddesc->alias_cnt = 0;
  372. ddesc->alias_list = NULL;
  373. if ( wmlFindInHList(wml_synobj_ptr,name) >= 0 )
  374. {
  375. printf ("\nDuplicate name %s found", name);
  376. return;
  377. }
  378. wmlInsertInHList (wml_synobj_ptr, name, (ObjectPtr)ddesc);
  379. wml_cur_obj = (ObjectPtr) ddesc;
  380. wml_cur_subobj = NULL;
  381. return;
  382. }
  383. /*
  384. * Routine to set an attribute in a class descriptor.
  385. *
  386. * This routine sets the given attribute in the current object, which
  387. * must be a class descriptor. The current object and subobject do not
  388. * change.
  389. *
  390. * attrid oneof SUPERCLASS | INTERNALLITERAL | DOCNAME |
  391. * CONVFUNC | WIDGETCLASS | DIALOGCLASS |
  392. * CTRLMAPSRESOURCE
  393. * val value of the attribute, usually a string
  394. */
  395. void wmlAddClassAttribute (attrid, val)
  396. int attrid;
  397. char *val;
  398. {
  399. WmlSynClassDefPtr cdesc; /* the class descriptor */
  400. /*
  401. * Acquire the current class descriptor
  402. */
  403. if ( wml_cur_obj == NULL )
  404. {
  405. printf ("\nwmlAddClassAttribute: NULL current object");
  406. return;
  407. }
  408. cdesc = (WmlSynClassDefPtr) wml_cur_obj;
  409. if ( cdesc->validation != WmlClassDefValid )
  410. {
  411. printf ("\nwmlAddClassAttribute: %d not a class descriptor",
  412. cdesc->validation);
  413. return;
  414. }
  415. /*
  416. * Set the appropriate resource
  417. */
  418. switch ( attrid )
  419. {
  420. case SUPERCLASS:
  421. cdesc->superclass = wmlAllocateString (val);
  422. break;
  423. case PARENTCLASS:
  424. cdesc->parentclass = wmlAllocateString (val);
  425. break;
  426. case INTERNALLITERAL:
  427. cdesc->int_lit = wmlAllocateString (val);
  428. break;
  429. case CONVFUNC:
  430. cdesc->convfunc = wmlAllocateString (val);
  431. break;
  432. case DOCNAME:
  433. cdesc->docname = wmlAllocateString (val);
  434. break;
  435. case WIDGETCLASS:
  436. cdesc->widgetclass = wmlAllocateString (val);
  437. break;
  438. case DIALOGCLASS:
  439. switch ( (long)val )
  440. {
  441. case ATTRTRUE:
  442. cdesc->dialog = TRUE;
  443. break;
  444. }
  445. break;
  446. case CTRLMAPSRESOURCE:
  447. cdesc->ctrlmapto = wmlAllocateString (val);
  448. break;
  449. }
  450. return;
  451. }
  452. /*
  453. * Routine to add a control specification to the current class.
  454. * The current object must be a class descriptor. The entry name
  455. * is added to the controls list. The control specification becomes the
  456. * current subobject.
  457. *
  458. * name the name of the controlled class
  459. */
  460. void wmlAddClassControl (name)
  461. char *name;
  462. {
  463. WmlSynClassDefPtr cdesc; /* the class descriptor */
  464. WmlSynClassCtrlDefPtr ctrlelm; /* controls element */
  465. /*
  466. * Acquire the current class descriptor
  467. */
  468. if ( wml_cur_obj == NULL )
  469. {
  470. printf ("\nwmlAddClassControl: NULL current object");
  471. return;
  472. }
  473. cdesc = (WmlSynClassDefPtr) wml_cur_obj;
  474. if ( cdesc->validation != WmlClassDefValid )
  475. {
  476. printf ("\nwmlAddClassControl: %d not a class descriptor",
  477. cdesc->validation);
  478. return;
  479. }
  480. /*
  481. * Add the control to the control list
  482. */
  483. ctrlelm = (WmlSynClassCtrlDefPtr) malloc (sizeof(WmlSynClassCtrlDef));
  484. ctrlelm->validation = WmlClassCtrlDefValid;
  485. ctrlelm->next = cdesc->controls;
  486. cdesc->controls = ctrlelm;
  487. ctrlelm->name = wmlAllocateString (name);
  488. /*
  489. * This becomes the current subobject
  490. */
  491. wml_cur_subobj = (ObjectPtr) ctrlelm;
  492. return;
  493. }
  494. /*
  495. * Add a resource descriptor to a class.
  496. * The current object must be a class descriptor. Create and add a
  497. * resource descriptor, which becomes the current subobject. It is not
  498. * entered in the named object list.
  499. *
  500. * name the resource name
  501. */
  502. void wmlAddClassResource (name)
  503. char *name;
  504. {
  505. WmlSynClassDefPtr cdesc; /* the class descriptor */
  506. WmlSynClassResDefPtr rdesc; /* the resource reference descriptor */
  507. /*
  508. * Acquire the current class descriptor
  509. */
  510. if ( wml_cur_obj == NULL )
  511. {
  512. printf ("\nwmlAddClassResource: NULL current object");
  513. return;
  514. }
  515. cdesc = (WmlSynClassDefPtr) wml_cur_obj;
  516. if ( cdesc->validation != WmlClassDefValid )
  517. {
  518. printf ("\nwmlAddClassResource: %d not a class descriptor",
  519. cdesc->validation);
  520. return;
  521. }
  522. /*
  523. * Add the resource to the resource list
  524. */
  525. rdesc = (WmlSynClassResDefPtr) malloc (sizeof(WmlSynClassResDef));
  526. rdesc->validation = WmlClassResDefValid;
  527. rdesc->name = wmlAllocateString (name);
  528. rdesc->type = NULL;
  529. rdesc->dflt = NULL;
  530. rdesc->exclude = WmlAttributeUnspecified;
  531. rdesc->next = cdesc->resources;
  532. cdesc->resources = rdesc;
  533. /*
  534. * This becomes the current subobject
  535. */
  536. wml_cur_subobj = (ObjectPtr) rdesc;
  537. return;
  538. }
  539. /*
  540. * Add a child descriptor to a class.
  541. * The current object must be a class descriptor. Create and add a
  542. * child descriptor, which becomes the current subobject. It is not
  543. * entered in the named object list.
  544. *
  545. * name the resource name
  546. */
  547. void wmlAddClassChild (name)
  548. char *name;
  549. {
  550. WmlSynClassDefPtr cdesc; /* the class descriptor */
  551. WmlSynClassChildDefPtr chdesc; /* the child reference descriptor */
  552. /*
  553. * Acquire the current class descriptor
  554. */
  555. if ( wml_cur_obj == NULL )
  556. {
  557. printf ("\nwmlAddClassResource: NULL current object");
  558. return;
  559. }
  560. cdesc = (WmlSynClassDefPtr) wml_cur_obj;
  561. if ( cdesc->validation != WmlClassDefValid )
  562. {
  563. printf ("\nwmlAddClassResource: %d not a class descriptor",
  564. cdesc->validation);
  565. return;
  566. }
  567. /*
  568. * Add the child to the child list
  569. */
  570. chdesc = (WmlSynClassChildDefPtr) malloc (sizeof(WmlSynClassChildDef));
  571. chdesc->validation = WmlClassChildDefValid;
  572. chdesc->name = wmlAllocateString (name);
  573. chdesc->next = cdesc->children;
  574. cdesc->children = chdesc;
  575. /*
  576. * This becomes the current subobject
  577. */
  578. wml_cur_subobj = (ObjectPtr) chdesc;
  579. return;
  580. }
  581. /*
  582. * This routine sets an attribute in the current class resource descriptor.
  583. * The current subobject must be a class resource descriptor. The
  584. * named attribute is set.
  585. *
  586. * attrid one of TYPE | DEFAULT | EXCLUDE
  587. * val attribute value, usually a string. Must be
  588. * ATTRTRUE | ATTRFALSE for EXCLUDE.
  589. */
  590. void wmlAddClassResourceAttribute (attrid, val)
  591. int attrid;
  592. char *val;
  593. {
  594. WmlSynClassResDefPtr rdesc; /* current class resource descriptor */
  595. long excval; /* EXCLUDE value */
  596. /*
  597. * Acquire the descriptor from the current subobject.
  598. */
  599. if ( wml_cur_subobj == NULL )
  600. {
  601. printf ("\nwmlAddClassResourceAttribute: NULL current subobject");
  602. return;
  603. }
  604. rdesc = (WmlSynClassResDefPtr) wml_cur_subobj;
  605. if ( rdesc->validation != WmlClassResDefValid )
  606. {
  607. printf
  608. ("\nwmlAddClassResourceAttribute: %d not a class resource descriptor",
  609. rdesc->validation);
  610. return;
  611. }
  612. switch ( attrid )
  613. {
  614. case TYPE:
  615. rdesc->type = wmlAllocateString (val);
  616. break;
  617. case DEFAULT:
  618. rdesc->dflt = wmlAllocateString (val);
  619. break;
  620. case EXCLUDE:
  621. excval = (long) val;
  622. switch ( excval )
  623. {
  624. case ATTRTRUE:
  625. rdesc->exclude = WmlAttributeTrue;
  626. break;
  627. case ATTRFALSE:
  628. rdesc->exclude = WmlAttributeFalse;
  629. break;
  630. default:
  631. printf ("\nwmlAddClassResourceAttribute: bad EXCLUDE value %d",
  632. excval);
  633. return;
  634. break;
  635. }
  636. break;
  637. default:
  638. printf ("\nwmlAddClassResourceAttribute: unknown attrid %d", attrid);
  639. return;
  640. break;
  641. }
  642. return;
  643. }
  644. /*
  645. * Routine to set an attribute in a resource descriptor.
  646. *
  647. * This routine sets the given attribute in the current object, which
  648. * must be a resource descriptor. The current object and subobject do not
  649. * change.
  650. *
  651. * attrid oneof TYPE | RESOURCELITERAL | INTERNALLITERAL |
  652. * RELATED | DOCNAME | DEFAULT | XRMRESOURCE | ALIAS |
  653. * ENUMERATIONSET
  654. * val value of the attribute, usually a string
  655. */
  656. void wmlAddResourceAttribute (attrid, val)
  657. int attrid;
  658. char *val;
  659. {
  660. WmlSynResourceDefPtr rdesc; /* the resource descriptor */
  661. long xrmval; /* XRMRESOURCE value */
  662. char **synlist; /* ALIAS pointer list */
  663. /*
  664. * Acquire the current resource descriptor
  665. */
  666. if ( wml_cur_obj == NULL )
  667. {
  668. printf ("\nwmlAddResourceAttribute: NULL current object");
  669. return;
  670. }
  671. rdesc = (WmlSynResourceDefPtr) wml_cur_obj;
  672. if ( rdesc->validation != WmlResourceDefValid )
  673. {
  674. printf ("\nwmlAddResourceAttribute: %d not a resource descriptor",
  675. rdesc->validation);
  676. return;
  677. }
  678. /*
  679. * Set the appropriate resource
  680. */
  681. switch ( attrid )
  682. {
  683. case TYPE:
  684. rdesc->datatype = wmlAllocateString (val);
  685. break;
  686. case INTERNALLITERAL:
  687. rdesc->int_lit = wmlAllocateString (val);
  688. break;
  689. case RESOURCELITERAL:
  690. rdesc->resliteral = wmlAllocateString (val);
  691. break;
  692. case ENUMERATIONSET:
  693. rdesc->enumset = wmlAllocateString (val);
  694. break;
  695. case DOCNAME:
  696. rdesc->docname = wmlAllocateString (val);
  697. break;
  698. case RELATED:
  699. rdesc->related = wmlAllocateString (val);
  700. break;
  701. case DEFAULT:
  702. rdesc->dflt = wmlAllocateString (val);
  703. break;
  704. case XRMRESOURCE:
  705. xrmval = (long) val;
  706. switch ( xrmval )
  707. {
  708. case ATTRTRUE:
  709. rdesc->xrm_support = WmlAttributeTrue;
  710. break;
  711. case ATTRFALSE:
  712. rdesc->xrm_support = WmlAttributeFalse;
  713. break;
  714. default:
  715. printf
  716. ("\nwmlAddResourceAttribute: bad XRMRESOURCE value %d",
  717. xrmval);
  718. return;
  719. break;
  720. }
  721. break;
  722. case ALIAS:
  723. if ( rdesc->alias_cnt == 0 )
  724. synlist = (char **) malloc (sizeof(char *));
  725. else
  726. synlist = (char **)
  727. realloc (rdesc->alias_list,
  728. (rdesc->alias_cnt+1)*sizeof(char **));
  729. synlist[rdesc->alias_cnt] = wmlAllocateString (val);
  730. rdesc->alias_cnt += 1;
  731. rdesc->alias_list = synlist;
  732. break;
  733. default:
  734. printf ("\nwmlAddResourceAttribute: unknown attrid %d", attrid);
  735. return;
  736. break;
  737. }
  738. return;
  739. }
  740. /*
  741. * Routine to set an attribute in a datatype descriptor.
  742. *
  743. * This routine sets the given attribute in the current object, which
  744. * must be a datatype descriptor. The current object and subobject do not
  745. * change.
  746. *
  747. * attrid oneof INTERNALLITERAL | DOCNAME | XRMRESOURCE
  748. * val value of the attribute, usually a string
  749. */
  750. void wmlAddDatatypeAttribute (attrid, val)
  751. int attrid;
  752. char *val;
  753. {
  754. WmlSynDataTypeDefPtr ddesc; /* the datatype descriptor */
  755. long xrmval; /* XRMRESOURCE value */
  756. /*
  757. * Acquire the current datatype descriptor
  758. */
  759. if ( wml_cur_obj == NULL )
  760. {
  761. printf ("\nwmlAddDatatypeAttribute: NULL current object");
  762. return;
  763. }
  764. ddesc = (WmlSynDataTypeDefPtr) wml_cur_obj;
  765. if ( ddesc->validation != WmlDataTypeDefValid )
  766. {
  767. printf ("\nwmlAddDatatypeAttribute: %d not a datatype descriptor",
  768. ddesc->validation);
  769. return;
  770. }
  771. /*
  772. * Set the appropriate slot
  773. */
  774. switch ( attrid )
  775. {
  776. case INTERNALLITERAL:
  777. ddesc->int_lit = wmlAllocateString (val);
  778. break;
  779. case DOCNAME:
  780. ddesc->docname = wmlAllocateString (val);
  781. break;
  782. case XRMRESOURCE:
  783. xrmval = (long) val;
  784. switch ( xrmval )
  785. {
  786. case ATTRTRUE:
  787. ddesc->xrm_support = WmlAttributeTrue;
  788. break;
  789. case ATTRFALSE:
  790. ddesc->xrm_support = WmlAttributeFalse;
  791. break;
  792. default:
  793. printf
  794. ("\nwmlAddDatatypeAttribute: bad XRMRESOURCE value %d",
  795. xrmval);
  796. return;
  797. break;
  798. }
  799. break;
  800. default:
  801. printf ("\nwmlAddDatatypeAttribute: unknown attrid %d", attrid);
  802. return;
  803. break;
  804. }
  805. return;
  806. }
  807. /*
  808. * Routine to add a control specification to the current controls list.
  809. * The current object must be a controls list descriptor. The entry name
  810. * is added to the controls list. The new element becomes the current
  811. * subobject.
  812. *
  813. * name the name of the controlled class
  814. */
  815. void wmlAddCtrlListControl (name)
  816. char *name;
  817. {
  818. WmlSynCtrlListDefPtr cdesc; /* the controls list descriptor */
  819. WmlSynClassCtrlDefPtr ctrlelm; /* controls element */
  820. /*
  821. * Acquire the current controls list descriptor
  822. */
  823. if ( wml_cur_obj == NULL )
  824. {
  825. printf ("\nwmlAddCtrlListControl: NULL current object");
  826. return;
  827. }
  828. cdesc = (WmlSynCtrlListDefPtr) wml_cur_obj;
  829. if ( cdesc->validation != WmlCtrlListDefValid )
  830. {
  831. printf ("\nwmlAddCtrlListControl: %d not a controls list descriptor",
  832. cdesc->validation);
  833. return;
  834. }
  835. /*
  836. * Add the control to the control list
  837. */
  838. ctrlelm = (WmlSynClassCtrlDefPtr) malloc (sizeof(WmlSynClassCtrlDef));
  839. ctrlelm->validation = WmlClassCtrlDefValid;
  840. ctrlelm->next = cdesc->controls;
  841. cdesc->controls = ctrlelm;
  842. ctrlelm->name = wmlAllocateString (name);
  843. /*
  844. * This becomes the current subobject
  845. */
  846. wml_cur_subobj = (ObjectPtr) ctrlelm;
  847. return;
  848. }
  849. /*
  850. * Routine to add an enumeration value to the current enumeration set
  851. * The current object must be an enumeration set descriptor. The entry name
  852. * is added to the the enumeration value list.
  853. *
  854. * name the name of the enumeration value
  855. */
  856. void wmlAddEnumSetValue (name)
  857. char *name;
  858. {
  859. WmlSynEnumSetDefPtr esdesc; /* the enumeration set descriptor */
  860. WmlSynEnumSetValDefPtr evelm; /* EnumSet EnumValue element */
  861. /*
  862. * Acquire the current enumeration set descriptor
  863. */
  864. if ( wml_cur_obj == NULL )
  865. {
  866. printf ("\nwmlAddEnumSetValue: NULL current object");
  867. return;
  868. }
  869. esdesc = (WmlSynEnumSetDefPtr) wml_cur_obj;
  870. if ( esdesc->validation != WmlEnumSetDefValid )
  871. {
  872. printf ("\nwmlAddEnumSetValue: %d not an enumeration set descriptor",
  873. esdesc->validation);
  874. return;
  875. }
  876. /*
  877. * Add the value to the set
  878. */
  879. evelm = (WmlSynEnumSetValDefPtr) malloc (sizeof(WmlSynEnumSetValDef));
  880. evelm->validation = WmlEnumValueDefValid;
  881. evelm->next = esdesc->values;
  882. esdesc->values = evelm;
  883. evelm->name = wmlAllocateString (name);
  884. /*
  885. * Becomes current subobject
  886. */
  887. wml_cur_subobj = (ObjectPtr) evelm;
  888. }
  889. /*
  890. * Routine to set an attribute in an enumeration value
  891. *
  892. * This routine sets the given attribute in the current object, which must
  893. * be an enumeration value descriptor. The current object does not change.
  894. *
  895. * attrid oneof ENUMLITERAL
  896. * val value of the attribute, usually a string
  897. */
  898. void wmlAddEnumValueAttribute (attrid, val)
  899. int attrid;
  900. char *val;
  901. {
  902. WmlSynEnumValueDefPtr evdesc; /* the enumeration value descriptor */
  903. /*
  904. * Acquire the current enumeration value descriptor
  905. */
  906. if ( wml_cur_obj == NULL )
  907. {
  908. printf ("\nwmlAddEnumValueAttribute: NULL current object");
  909. return;
  910. }
  911. evdesc = (WmlSynEnumValueDefPtr) wml_cur_obj;
  912. if ( evdesc->validation != WmlEnumValueDefValid )
  913. {
  914. printf ("\nwmlAddEnumValueAttribute: %d not an enumeration value descriptor",
  915. evdesc->validation);
  916. return;
  917. }
  918. /*
  919. * Set the appropriate slot
  920. */
  921. switch ( attrid )
  922. {
  923. case ENUMLITERAL:
  924. evdesc->enumlit = wmlAllocateString (val);
  925. break;
  926. default:
  927. printf ("\nwmlAddEnumValueAttribute: unknown attrid %d", attrid);
  928. return;
  929. break;
  930. }
  931. return;
  932. }
  933. /*
  934. * Routine to set an attribute in a charset descriptor.
  935. *
  936. * This routine sets the given attribute in the current object, which
  937. * must be a charset descriptor. The current object and subobject do not
  938. * change.
  939. *
  940. * attrid oneof INTERNALLITERAL | ALIAS | XMSTRINGCHARSETNAME |
  941. * DIRECTION | PARSEDIRECTION | CHARACTERSIZE
  942. * val value of the attribute, usually a string
  943. */
  944. void wmlAddCharsetAttribute (attrid, val)
  945. int attrid;
  946. char *val;
  947. {
  948. WmlSynCharSetDefPtr ddesc; /* the charset descriptor */
  949. char **synlist; /* ALIAS pointer list */
  950. long atrval; /* attribute value */
  951. /*
  952. * Acquire the current charset descriptor
  953. */
  954. if ( wml_cur_obj == NULL )
  955. {
  956. printf ("\nwmlAddCharSetAttribute: NULL current object");
  957. return;
  958. }
  959. ddesc = (WmlSynCharSetDefPtr) wml_cur_obj;
  960. if ( ddesc->validation != WmlCharSetDefValid )
  961. {
  962. printf ("\nwmlAddCharsetAttribute: %d not a CharSet descriptor",
  963. ddesc->validation);
  964. return;
  965. }
  966. /*
  967. * Set the appropriate slot
  968. */
  969. switch ( attrid )
  970. {
  971. case INTERNALLITERAL:
  972. ddesc->int_lit = wmlAllocateString (val);
  973. break;
  974. case ALIAS:
  975. if ( ddesc->alias_cnt == 0 )
  976. synlist = (char **) malloc (sizeof(char *));
  977. else
  978. synlist = (char **)
  979. realloc (ddesc->alias_list,
  980. (ddesc->alias_cnt+1)*sizeof(char **));
  981. synlist[ddesc->alias_cnt] = wmlAllocateString (val);
  982. ddesc->alias_cnt += 1;
  983. ddesc->alias_list = synlist;
  984. break;
  985. case XMSTRINGCHARSETNAME:
  986. ddesc->xms_name = wmlAllocateString (val);
  987. break;
  988. case DIRECTION:
  989. atrval = (long) val;
  990. switch ( atrval )
  991. {
  992. case LEFTTORIGHT:
  993. ddesc->direction = WmlCharSetDirectionLtoR;
  994. break;
  995. case RIGHTTOLEFT:
  996. ddesc->direction = WmlCharSetDirectionRtoL;
  997. break;
  998. default:
  999. printf
  1000. ("\nwmlAddCharsetAttribute: bad DIRECTION value %d",
  1001. atrval);
  1002. return;
  1003. break;
  1004. }
  1005. break;
  1006. case PARSEDIRECTION:
  1007. atrval = (long) val;
  1008. switch ( atrval )
  1009. {
  1010. case LEFTTORIGHT:
  1011. ddesc->parsedirection = WmlCharSetDirectionLtoR;
  1012. break;
  1013. case RIGHTTOLEFT:
  1014. ddesc->parsedirection = WmlCharSetDirectionRtoL;
  1015. break;
  1016. default:
  1017. printf
  1018. ("\nwmlAddCharsetAttribute: bad PARSEDIRECTION value %d",
  1019. atrval);
  1020. return;
  1021. break;
  1022. }
  1023. break;
  1024. case CHARACTERSIZE:
  1025. atrval = (long) val;
  1026. switch ( atrval )
  1027. {
  1028. case ONEBYTE:
  1029. ddesc->charsize = WmlCharSizeOneByte;
  1030. break;
  1031. case TWOBYTE:
  1032. ddesc->charsize = WmlCharSizeTwoByte;
  1033. break;
  1034. case MIXED1_2BYTE:
  1035. ddesc->charsize = WmlCharSizeMixed1_2Byte;
  1036. break;
  1037. default:
  1038. printf
  1039. ("\nwmlAddCharsetAttribute: bad CHARACTERSIZE value %d",
  1040. atrval);
  1041. return;
  1042. break;
  1043. }
  1044. break;
  1045. default:
  1046. printf ("\nwmlAddCharsetAttribute: unknown attrid %d", attrid);
  1047. return;
  1048. break;
  1049. }
  1050. return;
  1051. }
  1052. /*
  1053. * The error reporting routine.
  1054. *
  1055. * For now, issue a very simple error message
  1056. */
  1057. void LexIssueError (tkn)
  1058. int tkn;
  1059. {
  1060. switch ( tkn )
  1061. {
  1062. case SEMICOLON:
  1063. printf ("\n Syntax error: expected a semicolon");
  1064. break;
  1065. case RBRACE:
  1066. printf ("\n Syntax error: expected a right brace");
  1067. break;
  1068. case 0:
  1069. printf ("\nSyntax error: Couldn't recognize a section name, probably fatal");
  1070. break;
  1071. }
  1072. printf ("\n\tnear name='%s', value='%s', line %d",
  1073. yynameval, yystringval, wml_line_count);
  1074. wml_err_count += 1;
  1075. return;
  1076. }