Blame tools/wml/README

Packit b099d7
/* $XConsortium: README /main/4 1996/07/15 14:38:42 drk $ */
Packit b099d7
This memo documents the Widget MetaLanguage (WML) facility which generates
Packit b099d7
the Uil compiler language description.
Packit b099d7
Packit b099d7
1. Introduction
Packit b099d7
Packit b099d7
The Uil compiler's language definition has the following components:
Packit b099d7
	- Invariant parts of the language grammar. This consists of the
Packit b099d7
	  basic syntax and keywords, for example, the 'arguments' directive.
Packit b099d7
	- Dynamic parts of the language. This consists of the widget/gadget
Packit b099d7
	  classes supported by the language, including all resources
Packit b099d7
	  (arguments and reasons), and the definitions of legal relationships
Packit b099d7
	  among these parts (which classes are legal controls (children)
Packit b099d7
	  of any given class, default values, and so on).
Packit b099d7
	- The data types supported by the compiler. The code which supports
Packit b099d7
	  the data types is invariant, but the data types must also be
Packit b099d7
	  declared and made known in WML in order to provide a clean
Packit b099d7
	  specification.
Packit b099d7
Packit b099d7
The dynamic parts of the language definition in the compiler are represented
Packit b099d7
as follows. The representation falls into two classes:
Packit b099d7
	- Definitions of the language used for validity checking and
Packit b099d7
	  reporting:
Packit b099d7
		o A set of #define literals name all data types, classes,
Packit b099d7
		  arguments, and reasons in the language.
Packit b099d7
		o A set of statically compiled tables defines the names and
Packit b099d7
		  legal relationships among these entities.
Packit b099d7
	- All data types, classes, arguments, and reasons are treated as
Packit b099d7
	  keywords in the Uil grammar. This is supported by:
Packit b099d7
		o A set of #define literals which names all the tokens in
Packit b099d7
		  the language. Some of these tokens receive identical
Packit b099d7
		  values to the literals mentioned above (this identity is
Packit b099d7
		  crucial to the compiler's correct functioning).
Packit b099d7
		o A set of statically compiled tables used by lexical
Packit b099d7
		  analysis to detect and classify the language keywords.
Packit b099d7
		o A yacc grammar including these token definitions which
Packit b099d7
		  generates a compilable Uil language parser.
Packit b099d7
Packit b099d7
These representations are all contained in .h files except for the parser,
Packit b099d7
which is contained in a .y file and its resulting .c file.
Packit b099d7
Packit b099d7
The WML system's task is to generate all these literals and tables based on
Packit b099d7
a specification of the dynamic parts of the Uil language - the data types,
Packit b099d7
widget/gadget classes, arguments, and reasons. The components of the system
Packit b099d7
are:
Packit b099d7
	- A specification of the of set of widgets to be supported. This
Packit b099d7
	  specification is an ASCII file containing a WML language
Packit b099d7
	  specification as described below. The WML language is a simple
Packit b099d7
	  declarative language whose syntax is similar to Uil itself.
Packit b099d7
	- A process named wml, which parses the WML specification and
Packit b099d7
	  produces the following output:
Packit b099d7
		o The .h files which define the first class of language
Packit b099d7
		  representations - the validity checking and reporting
Packit b099d7
		  information.
Packit b099d7
		o A set of .dat files which are used by succeeding processes
Packit b099d7
		  to produce the Uil grammar.
Packit b099d7
		o A report file which describes the toolkit being supported.
Packit b099d7
		o A .mm file to be incorporated in the Uil language
Packit b099d7
		  documentation, which tabulates the built-in language
Packit b099d7
		  tables for Uil user reference.
Packit b099d7
	- A process named wmluily which generates the Uil grammar.
Packit b099d7
	- A process named wmltokens which generates token data
Packit b099d7
	- A process named wmlkeyword which generates the token and lexical
Packit b099d7
	  analysis tables.
Packit b099d7
Packit b099d7
A shell script is provided which runs the system. The individual processes
Packit b099d7
and inputs can usually be ignored.
Packit b099d7
Packit b099d7
Packit b099d7
2. Environment
Packit b099d7
Packit b099d7
The generation and use of the WML system requires the following:
Packit b099d7
	- The C language compiler and runtime system (cc).
Packit b099d7
	- The lexical generator facility (lex)
Packit b099d7
	- the compiler compiler facility (yacc)
Packit b099d7
Packit b099d7
The WML facility is found in directory /wmlsrc. It assumes the following
Packit b099d7
directories also exist:
Packit b099d7
	/uilsrc - the directory to which the output files are to be moved
Packit b099d7
	/mrmsrc/Mrm - contains MrmCmpr.h and other .h files required to
Packit b099d7
		compile the uil compiler.
Packit b099d7
Packit b099d7
The tables produced by WML must be consistent with the Mrm compression
Packit b099d7
code tables emboded in /mrmsrc/Mrm/MrmCmpr.h and /mrmsrc/Mrm/MrmCmprTbl.h.
Packit b099d7
If in doubt, refer to /mrmsrc/Mrm/urmc.README for details.
Packit b099d7
Packit b099d7
Packit b099d7
3. WML input
Packit b099d7
Packit b099d7
Input to WML consists of:
Packit b099d7
	- A description of the widget set (toolkit) to be suppported in
Packit b099d7
	  the WML specification language.
Packit b099d7
	- Data files supplied with WML facility, and which you will
Packit b099d7
	  usually not need to modify. These are:
Packit b099d7
		o grammar.y	- specifies the invariant part of the
Packit b099d7
				  Uil grammar
Packit b099d7
		o charset.dat	- specifies the character sets supported by
Packit b099d7
				  the compiler when handling compound strings
Packit b099d7
	  Any other .dat files found in /wmlsrc are the result of running
Packit b099d7
	  the facility, and may be ignored.
Packit b099d7
Packit b099d7
3.A. WML specification language
Packit b099d7
Packit b099d7
The WML specification is a simple declarative language whose syntax is
Packit b099d7
similar to that of Uil itself. It models the widget set to be suppored in
Packit b099d7
a way that is very similar to the Uil language. It differs in having class
Packit b099d7
inheritance similar to Xt widget classes, which minimizes the amount of
Packit b099d7
specification and reduces errors. The properties of the model are:
Packit b099d7
	- Class properties
Packit b099d7
		o Classes are differentiated into two types - metaclasses
Packit b099d7
		  and classes. Metaclasses cannot instantiate widgets.
Packit b099d7
		  Typically, a WML metaclass is generated for each metaclass
Packit b099d7
		  in the widget set to be supported.
Packit b099d7
		o A regular class is defined for every low-level create
Packit b099d7
		  routine in the widget set. There are typically more WML
Packit b099d7
		  classes that widget set classes. For instance, there
Packit b099d7
		  is one XmRowColumn class, with six WML classes (XmRowColumn
Packit b099d7
		  XmMenuBar, XmOptionMenu, XmPopupMenu, XmPulldownMenu,
Packit b099d7
		  XmRadioBox).
Packit b099d7
		o Gadgets are modelled as variants of a corresponding
Packit b099d7
		  widget class.
Packit b099d7
		o A class may have zero or one superclasses. A class
Packit b099d7
		  inherits all the resources and controls of its superclass
Packit b099d7
		  (recursively). An inherited resource may have some of
Packit b099d7
		  its properties overridden.
Packit b099d7
		o A class is given a name which becomes its Uil language
Packit b099d7
		  keyword (for regular classes). Metaclass names do
Packit b099d7
		  not appear in Uil.
Packit b099d7
		o A class is identified to Mrm by its creation
Packit b099d7
		  convenience function (low-level create function). Examples
Packit b099d7
		  are XmCreateLabel, XmCreatePushButtonGadget.
Packit b099d7
	- Resource properties
Packit b099d7
		o Resources are divided into two classes - arguments and
Packit b099d7
		  and reasons. This models the Uil language distinction
Packit b099d7
		  between callbacks and all other resources.
Packit b099d7
		o A resource is considered to have universal scope. Once
Packit b099d7
		  defined, it may be used in any class. Its name and datatype
Packit b099d7
		  are invariant, but its default value may be overridden.
Packit b099d7
		o A resource is included in a class by referencing it.
Packit b099d7
		  Resources are inherited. Inherited resources may be
Packit b099d7
		  excluded, which meancs they are not available in the
Packit b099d7
		  class which provides this override (and its subclasses).
Packit b099d7
		  This corresponds to the Motif toolkit N/A access value.
Packit b099d7
		o A resource is given a name which becomes its Uil language
Packit b099d7
		  keyword.
Packit b099d7
		o A resource is identified to Mrm by the toolkit literal
Packit b099d7
		  used to name it in arglists. Examples are
Packit b099d7
		  XmNheight, XmNancestorSensitive, XmNhelpCallback. The
Packit b099d7
		  resource literal defaults to the resource name, and need
Packit b099d7
		  not be explicitly specified where they are identical.
Packit b099d7
	- Control properties
Packit b099d7
		o A control is a class which is permitted as the child
Packit b099d7
		  of some other class.
Packit b099d7
		o Naming the controls of a class is a WML feature which
Packit b099d7
		  supports validity checking. There is no coresponding
Packit b099d7
		  explicit feature in any Xt widget set.
Packit b099d7
Packit b099d7
3.A.1 WML syntax and semantics
Packit b099d7
Packit b099d7
The WML syntax can be quickly inferred from the standard input file
Packit b099d7
provided with WML - motif-tables.wml. A quick BNF is provided in section 7.
Packit b099d7
Packit b099d7
Packit b099d7
WML semantics are:
Packit b099d7
	- '!' introduces a comment. Comments run from '!' to EOL.
Packit b099d7
	- A string value may be quoted by enclosing in double quotes '"'.
Packit b099d7
	  Names as well as values may be quoted. Keywords may not.
Packit b099d7
	- All names are case-sensitive. Forward and backward references
Packit b099d7
	  are allowed. All references to be resolved are to items defined
Packit b099d7
	  in WML. These are:
Packit b099d7
		o Type = <an item defined in a DataType statement>
Packit b099d7
		o SuperClass =
Packit b099d7
		  WidgetClass = <an item defined in a Class statement>
Packit b099d7
		o Resources { <items defined in Resource statement> };
Packit b099d7
		o Controls { <items defined in Class or ControlList>
Packit b099d7
				statements> };
Packit b099d7
	- A convenience function name is required for all classes except
Packit b099d7
	  Metaclasses.
Packit b099d7
	- Datatypes are required for all Arguments, Constraints, and
Packit b099d7
	  SubResources.
Packit b099d7
	- Arguments and SubResources are functionally identical, and
Packit b099d7
	  are distinguished only because they are different kinds of
Packit b099d7
	  resources in Xt widget sets. Constraints apply only to the
Packit b099d7
	  referencing class's children. The same name may not be
Packit b099d7
	  used for both an Argument and a Constraint (once a Constraint,
Packit b099d7
	  always a Constraint).
Packit b099d7
	- If a resource occurs in the widget set with more than one
Packit b099d7
	  datatype, the Uil datatype 'any' must be used.
Packit b099d7
	- The ResourceLiteral attribute for resources is optional, and
Packit b099d7
	  need only be specified when the name is not identical to the literal.
Packit b099d7
	- The DocName and Default attributes are only used for documentation.
Packit b099d7
	  They are arbitrary strings.
Packit b099d7
	- The WidgetClass attribute identifies the Widget class
Packit b099d7
	  associated with a Gadget class, and is required.
Packit b099d7
	- The DialogClass attribute is optional.
Packit b099d7
	- The ControlList statement is a simply macro for lists of
Packit b099d7
	  controls. It avoids tedious repetition of identical lists.
Packit b099d7
	  A Controls block in a Class statement allows Class and
Packit b099d7
	  ControlList names to be freely mixed.
Packit b099d7
Packit b099d7
Packit b099d7
4. WML output
Packit b099d7
	- The .h files and parser required by the compiler. These
Packit b099d7
	  are automatically moved to /uilsrc by the runwml script.
Packit b099d7
	- A report describing the supported widget set, always named
Packit b099d7
	  wml.report. This report is intended to aid in validating
Packit b099d7
	  the WML source. The report is organized in a way which makes
Packit b099d7
	  if fairly easy to compare the Uil langauge against widget
Packit b099d7
	  set documentation as exemplified by the Motif Programmer's
Packit b099d7
	  Reference Manual. The reported is sorted as follows:
Packit b099d7
		- alphabetically by class name
Packit b099d7
		- Resources ordered by ancestor (top of tree first).
Packit b099d7
		  Resources are listed alphabetically, with datatype
Packit b099d7
		  and default always shown.
Packit b099d7
		- Reasons ordered by ancestor (top of tree first),
Packit b099d7
		  then alphabetically.
Packit b099d7
		- Controls listed alphabetically.
Packit b099d7
	- A file which provides documentation for the language, intended
Packit b099d7
	  to be an appendix to a Uil manual as exemplified by the
Packit b099d7
	  Guide to the Motif User Interface Language Compiler. This file
Packit b099d7
	  is named wml-uil.mm
Packit b099d7
Packit b099d7
Packit b099d7
5. Generating and running WML
Packit b099d7
Packit b099d7
The script file /wmlsrc/genwml will build WML. The script file /wmlsrc/runwml
Packit b099d7
will run WML with motif-tables.src as input.
Packit b099d7
Packit b099d7
Packit b099d7
6. Gotchas and problems in current WML implementation
Packit b099d7
Packit b099d7
The script files genwml and runwml should be replaced by Makefiles.
Packit b099d7
Packit b099d7
The documentation file ?.mm is relatively untested. The tables should
Packit b099d7
probably be modified, as they are currently too big to print cleanly.
Packit b099d7
The handling of the DocName attribute is incorrect.
Packit b099d7
Packit b099d7
The specification of the Motif toolkit in motif-tables.wml has not been
Packit b099d7
fully validated against the latest toolkit documentation. We believe there
Packit b099d7
are no or very few errors in the actual resources and the classes which
Packit b099d7
use them. There may be errors in the default values, which will appear
Packit b099d7
in the documentation.
Packit b099d7
Packit b099d7
Packit b099d7
7. WML BNF
Packit b099d7
Packit b099d7
WML-specification : statement_block_list
Packit b099d7
Packit b099d7
statement_block_list:
Packit b099d7
	<empty>
Packit b099d7
	statement_block_list statement_block
Packit b099d7
Packit b099d7
statement_block:
Packit b099d7
	class_statement_block
Packit b099d7
	| resource_statement_block
Packit b099d7
	| datatype_statement_block
Packit b099d7
	| control_list_statement_block
Packit b099d7
Packit b099d7
class_statement_block:
Packit b099d7
	'Class' class_statement_list
Packit b099d7
Packit b099d7
resource_statement_block:
Packit b099d7
	'Resource' resource_statement_list
Packit b099d7
Packit b099d7
datatype_statement_block:
Packit b099d7
	'Datatype' datatype_statement_list
Packit b099d7
Packit b099d7
control_list_statement_block:
Packit b099d7
	'ControlList' control_list_statement_list
Packit b099d7
Packit b099d7
class_statement_list:
Packit b099d7
	class_statement ';'
Packit b099d7
	| class_statement_list class_statement ';'
Packit b099d7
Packit b099d7
resource_statement_list:
Packit b099d7
	resource_statement ';'
Packit b099d7
	| resource_statement_list resource_statement ';'
Packit b099d7
Packit b099d7
datatype_statement_list:
Packit b099d7
	datatype_statement ';'
Packit b099d7
	| datatype_statement_list datatype_statement ';'
Packit b099d7
Packit b099d7
control_list_statement_list:
Packit b099d7
	control_list_statement ';'
Packit b099d7
	| control_list_statement_list control_list_statement ';'
Packit b099d7
Packit b099d7
class_statement:
Packit b099d7
	<name> ':' class_type class_definition
Packit b099d7
Packit b099d7
class_type:
Packit b099d7
	'MetaClass' | 'Widget' | 'Gadget'
Packit b099d7
Packit b099d7
class_definition:
Packit b099d7
	<empty>
Packit b099d7
	| '{' '}'
Packit b099d7
	| '{' class_attribute_list '}'
Packit b099d7
Packit b099d7
class_attribute_list:
Packit b099d7
	class_attribute_name '=' <string> ';'
Packit b099d7
	| class_boolean_attribute_name '=' boolean_attribute_value ';'
Packit b099d7
	| class_resources ';'
Packit b099d7
	| class_controls ';'
Packit b099d7
Packit b099d7
class_attribute_name:
Packit b099d7
	'SuperClass' | 'Alias' | 'ConvenienceFunction' | 'WidgetClass' |
Packit b099d7
	'DocName'
Packit b099d7
Packit b099d7
class_boolean_attribute_name:
Packit b099d7
	'DialogClass'
Packit b099d7
Packit b099d7
boolean_attribute_value:
Packit b099d7
	'True' | 'False'
Packit b099d7
Packit b099d7
class_resources:
Packit b099d7
	'Resources' class_resources_block
Packit b099d7
Packit b099d7
class_resources_block:
Packit b099d7
	<empty>
Packit b099d7
	'{' '}'
Packit b099d7
	'{' class_resource_list '}'
Packit b099d7
Packit b099d7
class_resource_list:
Packit b099d7
	class_resource_element
Packit b099d7
	| class_resource_list class_resource_element
Packit b099d7
Packit b099d7
class_resource_element:
Packit b099d7
	<name> class_resource_attributes ';'
Packit b099d7
Packit b099d7
class_resource_attributes:
Packit b099d7
	<empty>
Packit b099d7
	'{' '}' ';'
Packit b099d7
	'{' class_resource_attribute_list '}'
Packit b099d7
Packit b099d7
class_resource_attribute_list:
Packit b099d7
	class_resource_attribute_element
Packit b099d7
	| class_resource_attribute_list class_resource_attribute_element
Packit b099d7
Packit b099d7
class_attribute_element
Packit b099d7
	class_resource_attribute_name '=' <string> ';'
Packit b099d7
	| boolean_class_resource_attribute_name '=' boolean_attribute_value ';'
Packit b099d7
Packit b099d7
class_resource_attribute_name:
Packit b099d7
	'Default'
Packit b099d7
Packit b099d7
boolean_class_resource_attribute_name:
Packit b099d7
	'Exclude'
Packit b099d7
Packit b099d7
class_controls:
Packit b099d7
	'Controls' class_controls_block
Packit b099d7
Packit b099d7
class_controls_block:
Packit b099d7
	<empty>
Packit b099d7
	| '{' '}' ';'
Packit b099d7
	| '{' class_controls_list '}'
Packit b099d7
Packit b099d7
class_controls_list:
Packit b099d7
	class_controls_element
Packit b099d7
	class_controls_list class_controls_element
Packit b099d7
Packit b099d7
class_controls_element:
Packit b099d7
	<name> ;
Packit b099d7
Packit b099d7
resource_statement:
Packit b099d7
	<name> ':' resource_type resource_definition
Packit b099d7
Packit b099d7
resource_type:
Packit b099d7
	'Argument' | 'Reason' | 'Constraint' | 'SubResource'
Packit b099d7
Packit b099d7
resource_definition:
Packit b099d7
	<empty>
Packit b099d7
	'{' '}'
Packit b099d7
	'{' resource_attribute_list '}'
Packit b099d7
Packit b099d7
resource_attribute_list:
Packit b099d7
	resource_attribute
Packit b099d7
	resource_attribute_list resource_attribute
Packit b099d7
Packit b099d7
resource_attribute:
Packit b099d7
	resource_attribute_name '=' <string> ';'
Packit b099d7
Packit b099d7
resource_attribute_name:
Packit b099d7
	'Type' | 'ResourceLiteral' | 'Alias' | 'Related' | 'Default' |
Packit b099d7
	'DocName'
Packit b099d7
Packit b099d7
datatype_statement:
Packit b099d7
	<name> datatype_definition
Packit b099d7
Packit b099d7
datatype_definition:
Packit b099d7
	<empty>
Packit b099d7
	| '{' '}'
Packit b099d7
	| '{' datatype_attribute_list '}'
Packit b099d7
Packit b099d7
datatype_attribute_list:
Packit b099d7
	datatype_attribuute
Packit b099d7
	datatype_attribute_list datatype_attribute
Packit b099d7
Packit b099d7
datatype_attribute:
Packit b099d7
	datatype-attribute_name '=' <string> ';'
Packit b099d7
Packit b099d7
datatype_attribute_name:
Packit b099d7
	'Alias' | 'DocName'
Packit b099d7
Packit b099d7
control_list_statement:
Packit b099d7
	<name> control_list_definition
Packit b099d7
Packit b099d7
control_list_definition:
Packit b099d7
	<empty>
Packit b099d7
	'{' '}'
Packit b099d7
	'{' control_list_controls_list '}'
Packit b099d7
Packit b099d7
control_list_controls_list:
Packit b099d7
	control_list_control
Packit b099d7
	control_list_controls_list control_list_control
Packit b099d7
Packit b099d7
control_list_control:
Packit b099d7
	<name> ';'