2
* @OPENGROUP_COPYRIGHT@
4
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
5
* Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
6
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
7
* the full copyright text.
9
* This software is subject to an open license. It may only be
10
* used on, with or for operating systems which are themselves open
11
* source systems. You must contact The Open Group for a license
12
* allowing distribution and sublicensing of this software on, with,
13
* or for operating systems which are not Open Source programs.
15
* See http://www.opengroup.org/openmotif/license for full
16
* details of the license agreement. Any use, reproduction, or
17
* distribution of the program constitutes recipient's acceptance of
20
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
21
* PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
* KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
23
* WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
24
* OR FITNESS FOR A PARTICULAR PURPOSE
26
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
27
* NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
28
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
30
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
33
* EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGES.
41
static char rcsid[] = "$TOG: wml.c /main/8 1999/04/16 09:41:47 mgreess $"
51
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
54
* This is the main program for WML. It declares all global data structures
55
* used during a compilation, and during output.
59
* WML is a semi-standard Unix application. It reads its input from
60
* stdin, which is expected to be a stream containing a WML description
61
* of a UIL language. If this stream is successfully parsed and semantically
62
* validated, then WML writes a series of standard .h and .dat files into
63
* the user directory. The .h files will be used directly to construct
64
* the UIL compiler. The .dat files are used by other phases of UIL
67
* The files created by WML are:
99
* Globals used during WML parsing.
101
* WML uses globals exclusively to communicate data during parsing. The
102
* current object being constructed is held by these globals, and all
103
* routines called from the parse assume correct setting of these globals.
104
* This simplisitic approach is possible since the WML description language
105
* has no recursive constructs requiring a frame stack.
109
* Error and other counts
111
int wml_err_count = 0; /* total errors */
112
int wml_line_count = 0; /* lines read from input */
115
* Dynamic ordered vector of all objects encountered during parse. This
116
* is used to detect name collisions, and is the primary order vector
117
* used for all other vectors constructed curing the semantic resolution
118
* phase of processing.
120
DynamicHandleListDef wml_synobj;
121
DynamicHandleListDefPtr wml_synobj_ptr = &wml_synobj;
125
* Dynamic vectors of vectors partitioned and ordered
126
* as required by the semantic processing and output routines. All
127
* point to resolved objects rather than syntactic objects.
129
DynamicHandleListDef wml_obj_datatype; /* datatype objects */
130
DynamicHandleListDefPtr wml_obj_datatype_ptr = &wml_obj_datatype;
132
DynamicHandleListDef wml_obj_enumval; /* enumeration value objects */
133
DynamicHandleListDefPtr wml_obj_enumval_ptr = &wml_obj_enumval;
135
DynamicHandleListDef wml_obj_enumset; /* enumeration set objects */
136
DynamicHandleListDefPtr wml_obj_enumset_ptr = &wml_obj_enumset;
138
DynamicHandleListDef wml_obj_reason; /* reason resource objects */
139
DynamicHandleListDefPtr wml_obj_reason_ptr = &wml_obj_reason;
141
DynamicHandleListDef wml_obj_arg; /* argument resource objects */
142
DynamicHandleListDefPtr wml_obj_arg_ptr = &wml_obj_arg;
144
DynamicHandleListDef wml_obj_child; /* argument resource objects */
145
DynamicHandleListDefPtr wml_obj_child_ptr = &wml_obj_child;
147
DynamicHandleListDef wml_obj_allclass; /* metaclass, widget, gadget */
148
DynamicHandleListDefPtr wml_obj_allclass_ptr = &wml_obj_allclass;
150
DynamicHandleListDef wml_obj_class; /* widget & gadget objects */
151
DynamicHandleListDefPtr wml_obj_class_ptr = &wml_obj_class;
153
DynamicHandleListDef wml_obj_ctrlist; /* controls list objects */
154
DynamicHandleListDefPtr wml_obj_ctrlist_ptr = &wml_obj_ctrlist;
156
DynamicHandleListDef wml_obj_charset; /* charset objects */
157
DynamicHandleListDefPtr wml_obj_charset_ptr = &wml_obj_charset;
159
DynamicHandleListDef wml_tok_sens; /* case-sensitive tokens */
160
DynamicHandleListDefPtr wml_tok_sens_ptr = &wml_tok_sens;
162
DynamicHandleListDef wml_tok_insens; /* case-insensitive tokens */
163
DynamicHandleListDefPtr wml_tok_insens_ptr = &wml_tok_insens;
167
* Routines only accessible in this module
180
* The WML main routine:
182
* 1. Initialize global storage
183
* 2. Open the input file if there is one
184
* 3. Parse the WML description in stdin. Exit on errors
185
* 4. Perform semantic validation and resolution. Exit on errors.
189
int main (argc, argv)
196
int fd; /* input file descriptor */
204
* Assume that anything in argv must be an input file. Open it, and
209
if ( (fd=open(argv[1],O_RDONLY)) == -1 )
210
printf ("\nCouldn't open file %s", argv[1]);
223
* Parse the input stream
225
yyleng = 0; /* initialization safety */
227
if ( wml_err_count > 0 ) break;
228
printf ("\nParse of WML input complete");
231
* Perform semantic validation, and construct resolved data structures
233
wmlResolveDescriptors ();
234
if ( wml_err_count > 0 ) break;
235
printf ("\nSemantic validation and resolution complete");
241
if ( wml_err_count > 0 ) break;
242
printf ("\nWML Uil*.h and wml-uil.mm file creation complete\n");
248
* Report inaction on errors
250
if ( wml_err_count > 0 )
252
printf ("\nWML found %d errors, no or incomplete output produced\n",
254
/* Begin fixing the bug CR 4748 */
256
/* End fixing the bug CR 4748 */
265
* Routine to initialize WML.
267
* The main job is to dynamically allocate any dynamic lists to a reasonable
275
* Initialize the list of all syntactic objects
277
wmlInitHList (wml_synobj_ptr, 1000, TRUE);