README 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /* $XConsortium: README /main/4 1996/07/15 14:38:42 drk $ */
  2. This memo documents the Widget MetaLanguage (WML) facility which generates
  3. the Uil compiler language description.
  4. 1. Introduction
  5. The Uil compiler's language definition has the following components:
  6. - Invariant parts of the language grammar. This consists of the
  7. basic syntax and keywords, for example, the 'arguments' directive.
  8. - Dynamic parts of the language. This consists of the widget/gadget
  9. classes supported by the language, including all resources
  10. (arguments and reasons), and the definitions of legal relationships
  11. among these parts (which classes are legal controls (children)
  12. of any given class, default values, and so on).
  13. - The data types supported by the compiler. The code which supports
  14. the data types is invariant, but the data types must also be
  15. declared and made known in WML in order to provide a clean
  16. specification.
  17. The dynamic parts of the language definition in the compiler are represented
  18. as follows. The representation falls into two classes:
  19. - Definitions of the language used for validity checking and
  20. reporting:
  21. o A set of #define literals name all data types, classes,
  22. arguments, and reasons in the language.
  23. o A set of statically compiled tables defines the names and
  24. legal relationships among these entities.
  25. - All data types, classes, arguments, and reasons are treated as
  26. keywords in the Uil grammar. This is supported by:
  27. o A set of #define literals which names all the tokens in
  28. the language. Some of these tokens receive identical
  29. values to the literals mentioned above (this identity is
  30. crucial to the compiler's correct functioning).
  31. o A set of statically compiled tables used by lexical
  32. analysis to detect and classify the language keywords.
  33. o A yacc grammar including these token definitions which
  34. generates a compilable Uil language parser.
  35. These representations are all contained in .h files except for the parser,
  36. which is contained in a .y file and its resulting .c file.
  37. The WML system's task is to generate all these literals and tables based on
  38. a specification of the dynamic parts of the Uil language - the data types,
  39. widget/gadget classes, arguments, and reasons. The components of the system
  40. are:
  41. - A specification of the of set of widgets to be supported. This
  42. specification is an ASCII file containing a WML language
  43. specification as described below. The WML language is a simple
  44. declarative language whose syntax is similar to Uil itself.
  45. - A process named wml, which parses the WML specification and
  46. produces the following output:
  47. o The .h files which define the first class of language
  48. representations - the validity checking and reporting
  49. information.
  50. o A set of .dat files which are used by succeeding processes
  51. to produce the Uil grammar.
  52. o A report file which describes the toolkit being supported.
  53. o A .mm file to be incorporated in the Uil language
  54. documentation, which tabulates the built-in language
  55. tables for Uil user reference.
  56. - A process named wmluily which generates the Uil grammar.
  57. - A process named wmltokens which generates token data
  58. - A process named wmlkeyword which generates the token and lexical
  59. analysis tables.
  60. A shell script is provided which runs the system. The individual processes
  61. and inputs can usually be ignored.
  62. 2. Environment
  63. The generation and use of the WML system requires the following:
  64. - The C language compiler and runtime system (cc).
  65. - The lexical generator facility (lex)
  66. - the compiler compiler facility (yacc)
  67. The WML facility is found in directory /wmlsrc. It assumes the following
  68. directories also exist:
  69. /uilsrc - the directory to which the output files are to be moved
  70. /mrmsrc/Mrm - contains MrmCmpr.h and other .h files required to
  71. compile the uil compiler.
  72. The tables produced by WML must be consistent with the Mrm compression
  73. code tables emboded in /mrmsrc/Mrm/MrmCmpr.h and /mrmsrc/Mrm/MrmCmprTbl.h.
  74. If in doubt, refer to /mrmsrc/Mrm/urmc.README for details.
  75. 3. WML input
  76. Input to WML consists of:
  77. - A description of the widget set (toolkit) to be suppported in
  78. the WML specification language.
  79. - Data files supplied with WML facility, and which you will
  80. usually not need to modify. These are:
  81. o grammar.y - specifies the invariant part of the
  82. Uil grammar
  83. o charset.dat - specifies the character sets supported by
  84. the compiler when handling compound strings
  85. Any other .dat files found in /wmlsrc are the result of running
  86. the facility, and may be ignored.
  87. 3.A. WML specification language
  88. The WML specification is a simple declarative language whose syntax is
  89. similar to that of Uil itself. It models the widget set to be suppored in
  90. a way that is very similar to the Uil language. It differs in having class
  91. inheritance similar to Xt widget classes, which minimizes the amount of
  92. specification and reduces errors. The properties of the model are:
  93. - Class properties
  94. o Classes are differentiated into two types - metaclasses
  95. and classes. Metaclasses cannot instantiate widgets.
  96. Typically, a WML metaclass is generated for each metaclass
  97. in the widget set to be supported.
  98. o A regular class is defined for every low-level create
  99. routine in the widget set. There are typically more WML
  100. classes that widget set classes. For instance, there
  101. is one XmRowColumn class, with six WML classes (XmRowColumn
  102. XmMenuBar, XmOptionMenu, XmPopupMenu, XmPulldownMenu,
  103. XmRadioBox).
  104. o Gadgets are modelled as variants of a corresponding
  105. widget class.
  106. o A class may have zero or one superclasses. A class
  107. inherits all the resources and controls of its superclass
  108. (recursively). An inherited resource may have some of
  109. its properties overridden.
  110. o A class is given a name which becomes its Uil language
  111. keyword (for regular classes). Metaclass names do
  112. not appear in Uil.
  113. o A class is identified to Mrm by its creation
  114. convenience function (low-level create function). Examples
  115. are XmCreateLabel, XmCreatePushButtonGadget.
  116. - Resource properties
  117. o Resources are divided into two classes - arguments and
  118. and reasons. This models the Uil language distinction
  119. between callbacks and all other resources.
  120. o A resource is considered to have universal scope. Once
  121. defined, it may be used in any class. Its name and datatype
  122. are invariant, but its default value may be overridden.
  123. o A resource is included in a class by referencing it.
  124. Resources are inherited. Inherited resources may be
  125. excluded, which meancs they are not available in the
  126. class which provides this override (and its subclasses).
  127. This corresponds to the Motif toolkit N/A access value.
  128. o A resource is given a name which becomes its Uil language
  129. keyword.
  130. o A resource is identified to Mrm by the toolkit literal
  131. used to name it in arglists. Examples are
  132. XmNheight, XmNancestorSensitive, XmNhelpCallback. The
  133. resource literal defaults to the resource name, and need
  134. not be explicitly specified where they are identical.
  135. - Control properties
  136. o A control is a class which is permitted as the child
  137. of some other class.
  138. o Naming the controls of a class is a WML feature which
  139. supports validity checking. There is no coresponding
  140. explicit feature in any Xt widget set.
  141. 3.A.1 WML syntax and semantics
  142. The WML syntax can be quickly inferred from the standard input file
  143. provided with WML - motif-tables.wml. A quick BNF is provided in section 7.
  144. WML semantics are:
  145. - '!' introduces a comment. Comments run from '!' to EOL.
  146. - A string value may be quoted by enclosing in double quotes '"'.
  147. Names as well as values may be quoted. Keywords may not.
  148. - All names are case-sensitive. Forward and backward references
  149. are allowed. All references to be resolved are to items defined
  150. in WML. These are:
  151. o Type = <an item defined in a DataType statement>
  152. o SuperClass =
  153. WidgetClass = <an item defined in a Class statement>
  154. o Resources { <items defined in Resource statement> };
  155. o Controls { <items defined in Class or ControlList>
  156. statements> };
  157. - A convenience function name is required for all classes except
  158. Metaclasses.
  159. - Datatypes are required for all Arguments, Constraints, and
  160. SubResources.
  161. - Arguments and SubResources are functionally identical, and
  162. are distinguished only because they are different kinds of
  163. resources in Xt widget sets. Constraints apply only to the
  164. referencing class's children. The same name may not be
  165. used for both an Argument and a Constraint (once a Constraint,
  166. always a Constraint).
  167. - If a resource occurs in the widget set with more than one
  168. datatype, the Uil datatype 'any' must be used.
  169. - The ResourceLiteral attribute for resources is optional, and
  170. need only be specified when the name is not identical to the literal.
  171. - The DocName and Default attributes are only used for documentation.
  172. They are arbitrary strings.
  173. - The WidgetClass attribute identifies the Widget class
  174. associated with a Gadget class, and is required.
  175. - The DialogClass attribute is optional.
  176. - The ControlList statement is a simply macro for lists of
  177. controls. It avoids tedious repetition of identical lists.
  178. A Controls block in a Class statement allows Class and
  179. ControlList names to be freely mixed.
  180. 4. WML output
  181. - The .h files and parser required by the compiler. These
  182. are automatically moved to /uilsrc by the runwml script.
  183. - A report describing the supported widget set, always named
  184. wml.report. This report is intended to aid in validating
  185. the WML source. The report is organized in a way which makes
  186. if fairly easy to compare the Uil langauge against widget
  187. set documentation as exemplified by the Motif Programmer's
  188. Reference Manual. The reported is sorted as follows:
  189. - alphabetically by class name
  190. - Resources ordered by ancestor (top of tree first).
  191. Resources are listed alphabetically, with datatype
  192. and default always shown.
  193. - Reasons ordered by ancestor (top of tree first),
  194. then alphabetically.
  195. - Controls listed alphabetically.
  196. - A file which provides documentation for the language, intended
  197. to be an appendix to a Uil manual as exemplified by the
  198. Guide to the Motif User Interface Language Compiler. This file
  199. is named wml-uil.mm
  200. 5. Generating and running WML
  201. The script file /wmlsrc/genwml will build WML. The script file /wmlsrc/runwml
  202. will run WML with motif-tables.src as input.
  203. 6. Gotchas and problems in current WML implementation
  204. The script files genwml and runwml should be replaced by Makefiles.
  205. The documentation file ?.mm is relatively untested. The tables should
  206. probably be modified, as they are currently too big to print cleanly.
  207. The handling of the DocName attribute is incorrect.
  208. The specification of the Motif toolkit in motif-tables.wml has not been
  209. fully validated against the latest toolkit documentation. We believe there
  210. are no or very few errors in the actual resources and the classes which
  211. use them. There may be errors in the default values, which will appear
  212. in the documentation.
  213. 7. WML BNF
  214. WML-specification : statement_block_list
  215. statement_block_list:
  216. <empty>
  217. statement_block_list statement_block
  218. statement_block:
  219. class_statement_block
  220. | resource_statement_block
  221. | datatype_statement_block
  222. | control_list_statement_block
  223. class_statement_block:
  224. 'Class' class_statement_list
  225. resource_statement_block:
  226. 'Resource' resource_statement_list
  227. datatype_statement_block:
  228. 'Datatype' datatype_statement_list
  229. control_list_statement_block:
  230. 'ControlList' control_list_statement_list
  231. class_statement_list:
  232. class_statement ';'
  233. | class_statement_list class_statement ';'
  234. resource_statement_list:
  235. resource_statement ';'
  236. | resource_statement_list resource_statement ';'
  237. datatype_statement_list:
  238. datatype_statement ';'
  239. | datatype_statement_list datatype_statement ';'
  240. control_list_statement_list:
  241. control_list_statement ';'
  242. | control_list_statement_list control_list_statement ';'
  243. class_statement:
  244. <name> ':' class_type class_definition
  245. class_type:
  246. 'MetaClass' | 'Widget' | 'Gadget'
  247. class_definition:
  248. <empty>
  249. | '{' '}'
  250. | '{' class_attribute_list '}'
  251. class_attribute_list:
  252. class_attribute_name '=' <string> ';'
  253. | class_boolean_attribute_name '=' boolean_attribute_value ';'
  254. | class_resources ';'
  255. | class_controls ';'
  256. class_attribute_name:
  257. 'SuperClass' | 'Alias' | 'ConvenienceFunction' | 'WidgetClass' |
  258. 'DocName'
  259. class_boolean_attribute_name:
  260. 'DialogClass'
  261. boolean_attribute_value:
  262. 'True' | 'False'
  263. class_resources:
  264. 'Resources' class_resources_block
  265. class_resources_block:
  266. <empty>
  267. '{' '}'
  268. '{' class_resource_list '}'
  269. class_resource_list:
  270. class_resource_element
  271. | class_resource_list class_resource_element
  272. class_resource_element:
  273. <name> class_resource_attributes ';'
  274. class_resource_attributes:
  275. <empty>
  276. '{' '}' ';'
  277. '{' class_resource_attribute_list '}'
  278. class_resource_attribute_list:
  279. class_resource_attribute_element
  280. | class_resource_attribute_list class_resource_attribute_element
  281. class_attribute_element
  282. class_resource_attribute_name '=' <string> ';'
  283. | boolean_class_resource_attribute_name '=' boolean_attribute_value ';'
  284. class_resource_attribute_name:
  285. 'Default'
  286. boolean_class_resource_attribute_name:
  287. 'Exclude'
  288. class_controls:
  289. 'Controls' class_controls_block
  290. class_controls_block:
  291. <empty>
  292. | '{' '}' ';'
  293. | '{' class_controls_list '}'
  294. class_controls_list:
  295. class_controls_element
  296. class_controls_list class_controls_element
  297. class_controls_element:
  298. <name> ;
  299. resource_statement:
  300. <name> ':' resource_type resource_definition
  301. resource_type:
  302. 'Argument' | 'Reason' | 'Constraint' | 'SubResource'
  303. resource_definition:
  304. <empty>
  305. '{' '}'
  306. '{' resource_attribute_list '}'
  307. resource_attribute_list:
  308. resource_attribute
  309. resource_attribute_list resource_attribute
  310. resource_attribute:
  311. resource_attribute_name '=' <string> ';'
  312. resource_attribute_name:
  313. 'Type' | 'ResourceLiteral' | 'Alias' | 'Related' | 'Default' |
  314. 'DocName'
  315. datatype_statement:
  316. <name> datatype_definition
  317. datatype_definition:
  318. <empty>
  319. | '{' '}'
  320. | '{' datatype_attribute_list '}'
  321. datatype_attribute_list:
  322. datatype_attribuute
  323. datatype_attribute_list datatype_attribute
  324. datatype_attribute:
  325. datatype-attribute_name '=' <string> ';'
  326. datatype_attribute_name:
  327. 'Alias' | 'DocName'
  328. control_list_statement:
  329. <name> control_list_definition
  330. control_list_definition:
  331. <empty>
  332. '{' '}'
  333. '{' control_list_controls_list '}'
  334. control_list_controls_list:
  335. control_list_control
  336. control_list_controls_list control_list_control
  337. control_list_control:
  338. <name> ';'