Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
103
cde/osf/wml/Imakefile
Normal file
103
cde/osf/wml/Imakefile
Normal file
@@ -0,0 +1,103 @@
|
||||
XCOMM $TOG: Imakefile /main/16 1998/03/11 20:19:03 mgreess $
|
||||
XCOMM
|
||||
XCOMM @OSF_COPYRIGHT@
|
||||
XCOMM COPYRIGHT NOTICE
|
||||
XCOMM Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
XCOMM ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
XCOMM the full copyright text.
|
||||
|
||||
INCLUDES = -I. -I$(INCLUDESRC) -I$(MINCLUDESRC) -I$(MLIBSRC) -I$(MTOP)/include
|
||||
DEPLIBS = $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)
|
||||
LOCAL_LIBRARIES = $(XMLIB) $(XTOOLLIB) $(XPLIB) $(XLIB)
|
||||
|
||||
|
||||
SRCS1 = wml.c wmlouth.c wmloutmm.c \
|
||||
wmloutp1.c wmlresolve.c wmlsynbld.c wmlutils.c \
|
||||
wmldbcreate.c
|
||||
|
||||
OBJS1 = wml.o wmloutkey.o wmlouth.o wmloutmm.o \
|
||||
wmloutp1.o wmlresolve.o wmlsynbld.o wmlutils.o
|
||||
|
||||
SRCS2 = wmluiltok.l
|
||||
|
||||
OBJS2 = wmlparse.o
|
||||
|
||||
SRCS = $(SRCS1) $(SRCS2)
|
||||
|
||||
YACCTARGETS = UilLexPars.c UilLexPars.h
|
||||
|
||||
WMLTARGETS = UilConst.h UilKeyTab.h \
|
||||
UilSymArTa.h UilSymArTy.h UilSymCSet.h UilSymCtl.h \
|
||||
UilSymEnum.h UilSymGen.h UilSymNam.h UilSymRArg.h \
|
||||
UilSymReas.h UilTokName.h UilUrmClas.h UilSymChCl.h \
|
||||
UilSymChTa.h
|
||||
|
||||
TARGETS = $(YACCTARGETS) $(WMLTARGETS)
|
||||
|
||||
TABLE = motif.wml
|
||||
WMDTABLE = motif.wmd
|
||||
WMLTOOLS = wml wmluiltok
|
||||
REPORT = wml.report
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
|
||||
all:: DONE
|
||||
|
||||
DONE: $(WMDTABLE) $(TARGETS)
|
||||
(cd $(UILSRC); $(RM) $(TARGETS) UilDBDef.h)
|
||||
cp $(TARGETS) UilDBDef.h $(UILSRC)
|
||||
touch DONE
|
||||
|
||||
NormalLibraryTarget(wml,$(OBJS2) $(OBJS1))
|
||||
|
||||
install:: all
|
||||
|
||||
wml:: libwml.a
|
||||
$(CC) $(CFLAGS) libwml.a -o wml
|
||||
|
||||
NormalProgramTarget(wmldbcreate,wmldbcreate.o,$(DEPLIBS),$(LOCAL_LIBRARIES),$(SYSLIBS))
|
||||
|
||||
wmlparse.c: wmlparse.y wmllex.l
|
||||
$(LEX) wmllex.l
|
||||
$(MV) lex.yy.c wmllex.c
|
||||
$(YACC) -d $(YACCFLAGS) wmlparse.y
|
||||
$(RM) wmlparse.c wmlparse.h
|
||||
$(MV) y.tab.c wmlparse.c
|
||||
$(MV) y.tab.h wmlparse.h
|
||||
|
||||
wmlparse.h:: wmlparse.y wmllex.l
|
||||
$(LEX) wmllex.l
|
||||
$(MV) lex.yy.c wmllex.c
|
||||
$(YACC) -d $(YACCFLAGS) wmlparse.y
|
||||
$(MV) y.tab.c wmlparse.c
|
||||
$(MV) y.tab.h wmlparse.h
|
||||
|
||||
wmluiltok:: wmluiltok.l
|
||||
$(LEX) wmluiltok.l
|
||||
$(CC) $(CFLAGS) lex.yy.c $(LEXLIB) -o wmluiltok
|
||||
|
||||
$(TARGETS): $(WMLTOOLS) $(TABLE)
|
||||
$(RM) $(TARGETS) $(REPORT) wml-uil.mm
|
||||
$(YACC) -d $(YACCFLAGS) Uil.y
|
||||
$(MV) y.tab.c UilLexPars.c
|
||||
$(MV) y.tab.h UilLexPars.h
|
||||
$(CLIENTENVSETUP) ./wmluiltok < Uil.y > tokens.dat
|
||||
$(RM) wml-uil.mm
|
||||
$(CLIENTENVSETUP) ./wml $(TABLE)
|
||||
$(RM) tokens.dat
|
||||
|
||||
$(WMDTABLE): wmldbcreate
|
||||
$(CLIENTENVSETUP) ./wmldbcreate -o $@
|
||||
|
||||
clean::
|
||||
$(RM) $(TARGETS) $(WMDTABLE) $(REPORT) lex.yy.c libwml.a wml \
|
||||
*.mm *.sdml *.txt wmlparse.c wmlparse.h wmluiltok wmllex.c \
|
||||
tokens.dat DONE
|
||||
|
||||
depend:: wmlparse.h
|
||||
|
||||
DependTarget()
|
||||
|
||||
includes:: $(TARGETS)
|
||||
(cd $(UILSRC); $(RM) $(TARGETS) UilDBDef.h)
|
||||
cp $(TARGETS) UilDBDef.h $(UILSRC)
|
||||
416
cde/osf/wml/README
Normal file
416
cde/osf/wml/README
Normal file
@@ -0,0 +1,416 @@
|
||||
/* $XConsortium: README /main/4 1996/07/15 14:38:42 drk $ */
|
||||
This memo documents the Widget MetaLanguage (WML) facility which generates
|
||||
the Uil compiler language description.
|
||||
|
||||
1. Introduction
|
||||
|
||||
The Uil compiler's language definition has the following components:
|
||||
- Invariant parts of the language grammar. This consists of the
|
||||
basic syntax and keywords, for example, the 'arguments' directive.
|
||||
- Dynamic parts of the language. This consists of the widget/gadget
|
||||
classes supported by the language, including all resources
|
||||
(arguments and reasons), and the definitions of legal relationships
|
||||
among these parts (which classes are legal controls (children)
|
||||
of any given class, default values, and so on).
|
||||
- The data types supported by the compiler. The code which supports
|
||||
the data types is invariant, but the data types must also be
|
||||
declared and made known in WML in order to provide a clean
|
||||
specification.
|
||||
|
||||
The dynamic parts of the language definition in the compiler are represented
|
||||
as follows. The representation falls into two classes:
|
||||
- Definitions of the language used for validity checking and
|
||||
reporting:
|
||||
o A set of #define literals name all data types, classes,
|
||||
arguments, and reasons in the language.
|
||||
o A set of statically compiled tables defines the names and
|
||||
legal relationships among these entities.
|
||||
- All data types, classes, arguments, and reasons are treated as
|
||||
keywords in the Uil grammar. This is supported by:
|
||||
o A set of #define literals which names all the tokens in
|
||||
the language. Some of these tokens receive identical
|
||||
values to the literals mentioned above (this identity is
|
||||
crucial to the compiler's correct functioning).
|
||||
o A set of statically compiled tables used by lexical
|
||||
analysis to detect and classify the language keywords.
|
||||
o A yacc grammar including these token definitions which
|
||||
generates a compilable Uil language parser.
|
||||
|
||||
These representations are all contained in .h files except for the parser,
|
||||
which is contained in a .y file and its resulting .c file.
|
||||
|
||||
The WML system's task is to generate all these literals and tables based on
|
||||
a specification of the dynamic parts of the Uil language - the data types,
|
||||
widget/gadget classes, arguments, and reasons. The components of the system
|
||||
are:
|
||||
- A specification of the of set of widgets to be supported. This
|
||||
specification is an ASCII file containing a WML language
|
||||
specification as described below. The WML language is a simple
|
||||
declarative language whose syntax is similar to Uil itself.
|
||||
- A process named wml, which parses the WML specification and
|
||||
produces the following output:
|
||||
o The .h files which define the first class of language
|
||||
representations - the validity checking and reporting
|
||||
information.
|
||||
o A set of .dat files which are used by succeeding processes
|
||||
to produce the Uil grammar.
|
||||
o A report file which describes the toolkit being supported.
|
||||
o A .mm file to be incorporated in the Uil language
|
||||
documentation, which tabulates the built-in language
|
||||
tables for Uil user reference.
|
||||
- A process named wmluily which generates the Uil grammar.
|
||||
- A process named wmltokens which generates token data
|
||||
- A process named wmlkeyword which generates the token and lexical
|
||||
analysis tables.
|
||||
|
||||
A shell script is provided which runs the system. The individual processes
|
||||
and inputs can usually be ignored.
|
||||
|
||||
|
||||
2. Environment
|
||||
|
||||
The generation and use of the WML system requires the following:
|
||||
- The C language compiler and runtime system (cc).
|
||||
- The lexical generator facility (lex)
|
||||
- the compiler compiler facility (yacc)
|
||||
|
||||
The WML facility is found in directory /wmlsrc. It assumes the following
|
||||
directories also exist:
|
||||
/uilsrc - the directory to which the output files are to be moved
|
||||
/mrmsrc/Mrm - contains MrmCmpr.h and other .h files required to
|
||||
compile the uil compiler.
|
||||
|
||||
The tables produced by WML must be consistent with the Mrm compression
|
||||
code tables emboded in /mrmsrc/Mrm/MrmCmpr.h and /mrmsrc/Mrm/MrmCmprTbl.h.
|
||||
If in doubt, refer to /mrmsrc/Mrm/urmc.README for details.
|
||||
|
||||
|
||||
3. WML input
|
||||
|
||||
Input to WML consists of:
|
||||
- A description of the widget set (toolkit) to be suppported in
|
||||
the WML specification language.
|
||||
- Data files supplied with WML facility, and which you will
|
||||
usually not need to modify. These are:
|
||||
o grammar.y - specifies the invariant part of the
|
||||
Uil grammar
|
||||
o charset.dat - specifies the character sets supported by
|
||||
the compiler when handling compound strings
|
||||
Any other .dat files found in /wmlsrc are the result of running
|
||||
the facility, and may be ignored.
|
||||
|
||||
3.A. WML specification language
|
||||
|
||||
The WML specification is a simple declarative language whose syntax is
|
||||
similar to that of Uil itself. It models the widget set to be suppored in
|
||||
a way that is very similar to the Uil language. It differs in having class
|
||||
inheritance similar to Xt widget classes, which minimizes the amount of
|
||||
specification and reduces errors. The properties of the model are:
|
||||
- Class properties
|
||||
o Classes are differentiated into two types - metaclasses
|
||||
and classes. Metaclasses cannot instantiate widgets.
|
||||
Typically, a WML metaclass is generated for each metaclass
|
||||
in the widget set to be supported.
|
||||
o A regular class is defined for every low-level create
|
||||
routine in the widget set. There are typically more WML
|
||||
classes that widget set classes. For instance, there
|
||||
is one XmRowColumn class, with six WML classes (XmRowColumn
|
||||
XmMenuBar, XmOptionMenu, XmPopupMenu, XmPulldownMenu,
|
||||
XmRadioBox).
|
||||
o Gadgets are modelled as variants of a corresponding
|
||||
widget class.
|
||||
o A class may have zero or one superclasses. A class
|
||||
inherits all the resources and controls of its superclass
|
||||
(recursively). An inherited resource may have some of
|
||||
its properties overridden.
|
||||
o A class is given a name which becomes its Uil language
|
||||
keyword (for regular classes). Metaclass names do
|
||||
not appear in Uil.
|
||||
o A class is identified to Mrm by its creation
|
||||
convenience function (low-level create function). Examples
|
||||
are XmCreateLabel, XmCreatePushButtonGadget.
|
||||
- Resource properties
|
||||
o Resources are divided into two classes - arguments and
|
||||
and reasons. This models the Uil language distinction
|
||||
between callbacks and all other resources.
|
||||
o A resource is considered to have universal scope. Once
|
||||
defined, it may be used in any class. Its name and datatype
|
||||
are invariant, but its default value may be overridden.
|
||||
o A resource is included in a class by referencing it.
|
||||
Resources are inherited. Inherited resources may be
|
||||
excluded, which meancs they are not available in the
|
||||
class which provides this override (and its subclasses).
|
||||
This corresponds to the Motif toolkit N/A access value.
|
||||
o A resource is given a name which becomes its Uil language
|
||||
keyword.
|
||||
o A resource is identified to Mrm by the toolkit literal
|
||||
used to name it in arglists. Examples are
|
||||
XmNheight, XmNancestorSensitive, XmNhelpCallback. The
|
||||
resource literal defaults to the resource name, and need
|
||||
not be explicitly specified where they are identical.
|
||||
- Control properties
|
||||
o A control is a class which is permitted as the child
|
||||
of some other class.
|
||||
o Naming the controls of a class is a WML feature which
|
||||
supports validity checking. There is no coresponding
|
||||
explicit feature in any Xt widget set.
|
||||
|
||||
3.A.1 WML syntax and semantics
|
||||
|
||||
The WML syntax can be quickly inferred from the standard input file
|
||||
provided with WML - motif-tables.wml. A quick BNF is provided in section 7.
|
||||
|
||||
|
||||
WML semantics are:
|
||||
- '!' introduces a comment. Comments run from '!' to EOL.
|
||||
- A string value may be quoted by enclosing in double quotes '"'.
|
||||
Names as well as values may be quoted. Keywords may not.
|
||||
- All names are case-sensitive. Forward and backward references
|
||||
are allowed. All references to be resolved are to items defined
|
||||
in WML. These are:
|
||||
o Type = <an item defined in a DataType statement>
|
||||
o SuperClass =
|
||||
WidgetClass = <an item defined in a Class statement>
|
||||
o Resources { <items defined in Resource statement> };
|
||||
o Controls { <items defined in Class or ControlList>
|
||||
statements> };
|
||||
- A convenience function name is required for all classes except
|
||||
Metaclasses.
|
||||
- Datatypes are required for all Arguments, Constraints, and
|
||||
SubResources.
|
||||
- Arguments and SubResources are functionally identical, and
|
||||
are distinguished only because they are different kinds of
|
||||
resources in Xt widget sets. Constraints apply only to the
|
||||
referencing class's children. The same name may not be
|
||||
used for both an Argument and a Constraint (once a Constraint,
|
||||
always a Constraint).
|
||||
- If a resource occurs in the widget set with more than one
|
||||
datatype, the Uil datatype 'any' must be used.
|
||||
- The ResourceLiteral attribute for resources is optional, and
|
||||
need only be specified when the name is not identical to the literal.
|
||||
- The DocName and Default attributes are only used for documentation.
|
||||
They are arbitrary strings.
|
||||
- The WidgetClass attribute identifies the Widget class
|
||||
associated with a Gadget class, and is required.
|
||||
- The DialogClass attribute is optional.
|
||||
- The ControlList statement is a simply macro for lists of
|
||||
controls. It avoids tedious repetition of identical lists.
|
||||
A Controls block in a Class statement allows Class and
|
||||
ControlList names to be freely mixed.
|
||||
|
||||
|
||||
4. WML output
|
||||
- The .h files and parser required by the compiler. These
|
||||
are automatically moved to /uilsrc by the runwml script.
|
||||
- A report describing the supported widget set, always named
|
||||
wml.report. This report is intended to aid in validating
|
||||
the WML source. The report is organized in a way which makes
|
||||
if fairly easy to compare the Uil langauge against widget
|
||||
set documentation as exemplified by the Motif Programmer's
|
||||
Reference Manual. The reported is sorted as follows:
|
||||
- alphabetically by class name
|
||||
- Resources ordered by ancestor (top of tree first).
|
||||
Resources are listed alphabetically, with datatype
|
||||
and default always shown.
|
||||
- Reasons ordered by ancestor (top of tree first),
|
||||
then alphabetically.
|
||||
- Controls listed alphabetically.
|
||||
- A file which provides documentation for the language, intended
|
||||
to be an appendix to a Uil manual as exemplified by the
|
||||
Guide to the Motif User Interface Language Compiler. This file
|
||||
is named wml-uil.mm
|
||||
|
||||
|
||||
5. Generating and running WML
|
||||
|
||||
The script file /wmlsrc/genwml will build WML. The script file /wmlsrc/runwml
|
||||
will run WML with motif-tables.src as input.
|
||||
|
||||
|
||||
6. Gotchas and problems in current WML implementation
|
||||
|
||||
The script files genwml and runwml should be replaced by Makefiles.
|
||||
|
||||
The documentation file ?.mm is relatively untested. The tables should
|
||||
probably be modified, as they are currently too big to print cleanly.
|
||||
The handling of the DocName attribute is incorrect.
|
||||
|
||||
The specification of the Motif toolkit in motif-tables.wml has not been
|
||||
fully validated against the latest toolkit documentation. We believe there
|
||||
are no or very few errors in the actual resources and the classes which
|
||||
use them. There may be errors in the default values, which will appear
|
||||
in the documentation.
|
||||
|
||||
|
||||
7. WML BNF
|
||||
|
||||
WML-specification : statement_block_list
|
||||
|
||||
statement_block_list:
|
||||
<empty>
|
||||
statement_block_list statement_block
|
||||
|
||||
statement_block:
|
||||
class_statement_block
|
||||
| resource_statement_block
|
||||
| datatype_statement_block
|
||||
| control_list_statement_block
|
||||
|
||||
class_statement_block:
|
||||
'Class' class_statement_list
|
||||
|
||||
resource_statement_block:
|
||||
'Resource' resource_statement_list
|
||||
|
||||
datatype_statement_block:
|
||||
'Datatype' datatype_statement_list
|
||||
|
||||
control_list_statement_block:
|
||||
'ControlList' control_list_statement_list
|
||||
|
||||
class_statement_list:
|
||||
class_statement ';'
|
||||
| class_statement_list class_statement ';'
|
||||
|
||||
resource_statement_list:
|
||||
resource_statement ';'
|
||||
| resource_statement_list resource_statement ';'
|
||||
|
||||
datatype_statement_list:
|
||||
datatype_statement ';'
|
||||
| datatype_statement_list datatype_statement ';'
|
||||
|
||||
control_list_statement_list:
|
||||
control_list_statement ';'
|
||||
| control_list_statement_list control_list_statement ';'
|
||||
|
||||
class_statement:
|
||||
<name> ':' class_type class_definition
|
||||
|
||||
class_type:
|
||||
'MetaClass' | 'Widget' | 'Gadget'
|
||||
|
||||
class_definition:
|
||||
<empty>
|
||||
| '{' '}'
|
||||
| '{' class_attribute_list '}'
|
||||
|
||||
class_attribute_list:
|
||||
class_attribute_name '=' <string> ';'
|
||||
| class_boolean_attribute_name '=' boolean_attribute_value ';'
|
||||
| class_resources ';'
|
||||
| class_controls ';'
|
||||
|
||||
class_attribute_name:
|
||||
'SuperClass' | 'Alias' | 'ConvenienceFunction' | 'WidgetClass' |
|
||||
'DocName'
|
||||
|
||||
class_boolean_attribute_name:
|
||||
'DialogClass'
|
||||
|
||||
boolean_attribute_value:
|
||||
'True' | 'False'
|
||||
|
||||
class_resources:
|
||||
'Resources' class_resources_block
|
||||
|
||||
class_resources_block:
|
||||
<empty>
|
||||
'{' '}'
|
||||
'{' class_resource_list '}'
|
||||
|
||||
class_resource_list:
|
||||
class_resource_element
|
||||
| class_resource_list class_resource_element
|
||||
|
||||
class_resource_element:
|
||||
<name> class_resource_attributes ';'
|
||||
|
||||
class_resource_attributes:
|
||||
<empty>
|
||||
'{' '}' ';'
|
||||
'{' class_resource_attribute_list '}'
|
||||
|
||||
class_resource_attribute_list:
|
||||
class_resource_attribute_element
|
||||
| class_resource_attribute_list class_resource_attribute_element
|
||||
|
||||
class_attribute_element
|
||||
class_resource_attribute_name '=' <string> ';'
|
||||
| boolean_class_resource_attribute_name '=' boolean_attribute_value ';'
|
||||
|
||||
class_resource_attribute_name:
|
||||
'Default'
|
||||
|
||||
boolean_class_resource_attribute_name:
|
||||
'Exclude'
|
||||
|
||||
class_controls:
|
||||
'Controls' class_controls_block
|
||||
|
||||
class_controls_block:
|
||||
<empty>
|
||||
| '{' '}' ';'
|
||||
| '{' class_controls_list '}'
|
||||
|
||||
class_controls_list:
|
||||
class_controls_element
|
||||
class_controls_list class_controls_element
|
||||
|
||||
class_controls_element:
|
||||
<name> ;
|
||||
|
||||
resource_statement:
|
||||
<name> ':' resource_type resource_definition
|
||||
|
||||
resource_type:
|
||||
'Argument' | 'Reason' | 'Constraint' | 'SubResource'
|
||||
|
||||
resource_definition:
|
||||
<empty>
|
||||
'{' '}'
|
||||
'{' resource_attribute_list '}'
|
||||
|
||||
resource_attribute_list:
|
||||
resource_attribute
|
||||
resource_attribute_list resource_attribute
|
||||
|
||||
resource_attribute:
|
||||
resource_attribute_name '=' <string> ';'
|
||||
|
||||
resource_attribute_name:
|
||||
'Type' | 'ResourceLiteral' | 'Alias' | 'Related' | 'Default' |
|
||||
'DocName'
|
||||
|
||||
datatype_statement:
|
||||
<name> datatype_definition
|
||||
|
||||
datatype_definition:
|
||||
<empty>
|
||||
| '{' '}'
|
||||
| '{' datatype_attribute_list '}'
|
||||
|
||||
datatype_attribute_list:
|
||||
datatype_attribuute
|
||||
datatype_attribute_list datatype_attribute
|
||||
|
||||
datatype_attribute:
|
||||
datatype-attribute_name '=' <string> ';'
|
||||
|
||||
datatype_attribute_name:
|
||||
'Alias' | 'DocName'
|
||||
|
||||
control_list_statement:
|
||||
<name> control_list_definition
|
||||
|
||||
control_list_definition:
|
||||
<empty>
|
||||
'{' '}'
|
||||
'{' control_list_controls_list '}'
|
||||
|
||||
control_list_controls_list:
|
||||
control_list_control
|
||||
control_list_controls_list control_list_control
|
||||
|
||||
control_list_control:
|
||||
<name> ';'
|
||||
1404
cde/osf/wml/Uil.y
Normal file
1404
cde/osf/wml/Uil.y
Normal file
File diff suppressed because it is too large
Load Diff
425
cde/osf/wml/UilDBDef.h
Normal file
425
cde/osf/wml/UilDBDef.h
Normal file
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
/* $XConsortium: UilDBDef.h /main/8 1995/07/13 21:03:16 drk $ */
|
||||
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
**++
|
||||
** FACILITY:
|
||||
**
|
||||
** User Interface Language Compiler (UIL)
|
||||
**
|
||||
** ABSTRACT:
|
||||
**
|
||||
** This include file defines the interfaces necessry to the binary
|
||||
** data base in the WML & UIL compilers.
|
||||
**
|
||||
**--
|
||||
**/
|
||||
|
||||
#ifndef UilDBDef_h
|
||||
#define UilDBDef_h
|
||||
|
||||
/***********************************************************************
|
||||
****************** From UilDef.h ***************************************/
|
||||
#define _BIT_INDEX(_type) \
|
||||
(((unsigned int) (_type)) >> 3)
|
||||
|
||||
#define _BIT_MASK(_type) \
|
||||
(1 << (((unsigned int) (_type)) & 0x7))
|
||||
|
||||
#define _BIT_SET(table_entry_addr, _type) \
|
||||
( _BIT_MASK (_type) & \
|
||||
( ((unsigned char *) (table_entry_addr)) \
|
||||
[ _BIT_INDEX (_type) ] ) )
|
||||
|
||||
/*******************************************************************
|
||||
**************** From UilSymDef.h *********************************/
|
||||
/*
|
||||
** Hash table size
|
||||
*/
|
||||
|
||||
#define sym_k_hash_table_limit 127
|
||||
|
||||
/*
|
||||
** Symbol tags. These values are used in the tag field of every object header
|
||||
** to identify the type of the entry.
|
||||
*/
|
||||
|
||||
#define sym_k_error_entry (127)
|
||||
/* An error entry is used when compilation errors are detected in the */
|
||||
/* source program. Its use reduces cascading errors caused by missing */
|
||||
/* information and allows the compilation to continue and thus */
|
||||
/* additional errors may be detected */
|
||||
#define sym_k_value_entry 1
|
||||
/* A value entry contains information about a UIL literal value */
|
||||
/* (integer, string, compound string, xbitmapfile, argument, color, */
|
||||
/* icon, etc.). The b_type field is used to determine the datatype of */
|
||||
/* this value. */
|
||||
#define sym_k_name_entry 2
|
||||
/* A name entry corresponds to a name (identifier) used in the UIL */
|
||||
/* source. */
|
||||
#define sym_k_widget_entry 3
|
||||
/* A widget entry represents a widget declaration. It points off to */
|
||||
/* the arguments, callbacks, and controls lists for the widget. */
|
||||
#define sym_k_control_entry 4
|
||||
/* A control entry hangs off a list entry and identifes an object */
|
||||
/* (widget or gadget) that is controlled. It also contains the */
|
||||
/* managed/unmanaged information. */
|
||||
#define sym_k_forward_ref_entry 5
|
||||
/* forward reference entries are a linked listed of objects */
|
||||
/* (widgets/gadgets) that were not defined at the time of the */
|
||||
/* reference. After all objects have been seen, then this list is */
|
||||
/* traversed and all objects in it should now be defined and the */
|
||||
/* specified pointers can be filled-in. */
|
||||
#define sym_k_external_def_entry 6
|
||||
/* An external definition entry identifies a name that has been */
|
||||
/* imported and thus in not declared within this source module. */
|
||||
#define sym_k_argument_entry 7
|
||||
/* An argument entry hangs off a list entry and identifies an object */
|
||||
/* argument. It contains informtation about the argument name and */
|
||||
/* argument value. */
|
||||
#define sym_k_callback_entry 8
|
||||
/* An calllback entry hangs off a list entry and identifies an object */
|
||||
/* callback. It contains informtation about the callback name, */
|
||||
/* callback procedure, and callback tag. */
|
||||
#define sym_k_module_entry 9
|
||||
/* A module entry contains information specified on the module */
|
||||
/* statement. */
|
||||
#define sym_k_proc_def_entry 10
|
||||
/* A procedure definition entry is created for each procedure listed */
|
||||
/* in a procedure section. I contains informaion on the number and */
|
||||
/* types of the arguments. */
|
||||
|
||||
#define sym_k_proc_ref_entry 11
|
||||
/* A procedure reference entry contains information about a the use of */
|
||||
/* a procedure (e.g. as a callback). It also stores the tag to be */
|
||||
/* passed to the procedure. */
|
||||
#define sym_k_list_entry 12
|
||||
/* A list entry is a typed list of other symbol table entries. It */
|
||||
/* contains a count and a pointer to the next entry on the list via */
|
||||
/* the obj_header.az_next field. */
|
||||
#define sym_k_child_entry 13
|
||||
/* A child entry represents a declaration for an */
|
||||
/* automatically created child. It points off to */
|
||||
/* the arguments, callbacks, and controls lists for the child. Since */
|
||||
/* the structures for widget and child are the same, the */
|
||||
/* datastructure for children is really a sym_k_widget_entry_type. */
|
||||
#define sym_k_identifier_entry 14
|
||||
/* identifier entry tag is used for diagnostic messages only */
|
||||
#define sym_k_color_item_entry 15
|
||||
/* entry describing a color. */
|
||||
#define sym_k_gadget_entry 16
|
||||
/* A gadget entry represents a gadget declaration. It points off to */
|
||||
/* the arguments, callbacks, and controls lists for the gadget. Since */
|
||||
/* the structures for widget and gadgets are the same, the */
|
||||
/* datastructure for gadgets is really a sym_k_widget_entry_type. */
|
||||
#define sym_k_root_entry 17
|
||||
/* An entry used to group all the other entries together. It is */
|
||||
/* returned in the parse_tree_root field of the compilation descriptor */
|
||||
/* when using the callable interface. */
|
||||
#define sym_k_parent_list_entry 18
|
||||
/* This is a list of parents of a widget. It is used to check for */
|
||||
/* constraints provided by the parent that may be used on this widget. */
|
||||
#define sym_k_nested_list_entry 19
|
||||
/* This entry occurs as a list entry for a nested list. It occupies */
|
||||
/* the correct position in the list for the reference to a list, and */
|
||||
/* points to the actual list entry. */
|
||||
#define sym_k_include_file_entry 20
|
||||
/* An include file entry is used to describe the contents of an */
|
||||
/* include file. It is needed only maintain information about the */
|
||||
/* source file from which this parse tree was generated. It is not */
|
||||
/* used by UIL directly. */
|
||||
#define sym_k_section_entry 21
|
||||
/* A section entry is used to describe the contents of an source file. */
|
||||
/* It is needed only maintain information about the structure of */
|
||||
/* source file from which this parse tree was generated. It is not */
|
||||
/* used by UIL directly. */
|
||||
/* */
|
||||
#define sym_k_def_obj_entry 22
|
||||
/* This entry corresponds to the default object clause on the module */
|
||||
/* declaration it is used to store source information about the file */
|
||||
/* from which this parse tree was generated. It is not used by UIL */
|
||||
/* directly. */
|
||||
#define sym_k_UNUSED23_entry 23
|
||||
#define sym_k_val_forward_ref_entry 24
|
||||
/* val forward reference entries are a linked listed of values */
|
||||
/* that were not defined at the time of the */
|
||||
/* reference. After all values have been seen, then this list is */
|
||||
/* traversed and all values in it should now be defined and the */
|
||||
/* specified pointers can be filled-in. */
|
||||
#define sym_k_max_entry 24
|
||||
/* this is the largest possible value for an entry constant. */
|
||||
|
||||
|
||||
/*
|
||||
** Common attribute masks -- These values are used in the b_flags field of
|
||||
** the object_header.
|
||||
*/
|
||||
|
||||
#define sym_m_private (1 << 0)
|
||||
/* This item is private to this source module and thus need not be */
|
||||
/* output into the UID file. */
|
||||
#define sym_m_exported (1 << 1)
|
||||
/* This is an exported definition and must be put in the UID file. */
|
||||
#define sym_m_imported (1 << 2)
|
||||
/* This item is a reference external to this source module and thus */
|
||||
/* will be resolved at runtime by searching the resourec hierarchy. */
|
||||
#define sym_m_reference (1 << 3)
|
||||
#define sym_m_builtin (1 << 4)
|
||||
/* This item is builtin as oppose to a userdefined item. */
|
||||
#define sym_m_obj_is_gadget (1 << 5)
|
||||
/* This object is a gadget as oppose to a widget. */
|
||||
|
||||
|
||||
/*
|
||||
** Output states - order is important
|
||||
*/
|
||||
|
||||
#define sym_k_not_processed 0
|
||||
#define sym_k_queued 1
|
||||
#define sym_k_emitted 2
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Constants to define compiler-recognized data types. It is
|
||||
** important that the names used in .wml language descriptions
|
||||
** match these names. These values were once automatically generated
|
||||
** by WML. They are now maintained by hand to reduce compiler
|
||||
** dependence on WML artifacts.
|
||||
**
|
||||
** We have also separated the values loosely into two classes:
|
||||
** values which can be used to verify operator legality and values
|
||||
** which cannot (see UilSemVal.c -- the legal_operand_type table).
|
||||
** There is a comment below denoting where the separation is. Any
|
||||
** values above the comment may be used for validation of an operator
|
||||
** while any values below may not.
|
||||
**
|
||||
** The order of the values below is unimportant except that the
|
||||
** entries in the uil_datatype_names table in UilData.c must be
|
||||
** ordered the same way.
|
||||
*/
|
||||
#define sym_k_any_value 1
|
||||
#define sym_k_bool_value 2
|
||||
#define sym_k_char_8_value 3
|
||||
#define sym_k_compound_string_value 4
|
||||
#define sym_k_float_value 5
|
||||
#define sym_k_integer_value 6
|
||||
#define sym_k_single_float_value 7
|
||||
#define sym_k_localized_string_value 8
|
||||
#define sym_k_wchar_string_value 9
|
||||
#define sym_k_horizontal_integer_value 10
|
||||
#define sym_k_vertical_integer_value 11
|
||||
#define sym_k_horizontal_float_value 12
|
||||
#define sym_k_vertical_float_value 13
|
||||
/* Values after here may not be used for operator argument validation */
|
||||
#define sym_k_argument_value 14
|
||||
#define sym_k_asciz_table_value 15
|
||||
#define sym_k_class_rec_name_value 16
|
||||
#define sym_k_color_value 17
|
||||
#define sym_k_color_table_value 18
|
||||
#define sym_k_font_value 19
|
||||
#define sym_k_font_table_value 20
|
||||
#define sym_k_icon_value 21
|
||||
#define sym_k_identifier_value 22
|
||||
#define sym_k_integer_table_value 23
|
||||
#define sym_k_keysym_value 24
|
||||
#define sym_k_pixmap_value 25
|
||||
#define sym_k_reason_value 26
|
||||
#define sym_k_rgb_value 27
|
||||
#define sym_k_string_table_value 28
|
||||
#define sym_k_trans_table_value 29
|
||||
#define sym_k_widget_ref_value 30
|
||||
#define sym_k_xbitmapfile_value 31
|
||||
#define sym_k_fontset_value 32
|
||||
#define sym_k_child_value 33
|
||||
#define sym_k_max_value 33
|
||||
#define sym_k_no_value (sym_k_max_value+1)
|
||||
|
||||
/*
|
||||
* Error values for all kind of sym_k_... literal set
|
||||
*/
|
||||
#define sym_k_error_value 0
|
||||
#define sym_k_error_object 0
|
||||
#define sym_k_error_charset 0
|
||||
|
||||
|
||||
/*
|
||||
* Literals associated with character sets
|
||||
*
|
||||
* Character set character sizes
|
||||
*/
|
||||
#define sym_k_onebyte_charsize 1
|
||||
#define sym_k_twobyte_charsize 2
|
||||
#define sym_k_mixed1_2byte_charsize 3
|
||||
|
||||
/*
|
||||
* User-defined character set
|
||||
*/
|
||||
#define sym_k_userdefined_charset 1
|
||||
|
||||
/*
|
||||
* XmFONTLIST_DEFAULT_TAG
|
||||
*/
|
||||
#define sym_k_fontlist_default_tag 0
|
||||
|
||||
/*
|
||||
** value sets defining expression operators
|
||||
*/
|
||||
#define sym_k_unspecified_op 0
|
||||
#define sym_k_not_op 1
|
||||
#define sym_k_unary_plus_op 2
|
||||
#define sym_k_unary_minus_op 3
|
||||
#define sym_k_comp_str_op 4
|
||||
#define sym_k_wchar_str_op 5
|
||||
#define sym_k_last_unary_op 5
|
||||
|
||||
#define sym_k_multiply_op 6
|
||||
#define sym_k_divide_op 7
|
||||
#define sym_k_add_op 8
|
||||
#define sym_k_subtract_op 9
|
||||
#define sym_k_left_shift_op 10
|
||||
#define sym_k_right_shift_op 11
|
||||
#define sym_k_and_op 12
|
||||
#define sym_k_xor_op 13
|
||||
#define sym_k_or_op 14
|
||||
#define sym_k_cat_op 15
|
||||
#define sym_k_last_binary_op 15
|
||||
#define sym_k_valref_op 16 /* az_exp_op1 points to the value node
|
||||
whose value is referenced by this
|
||||
value node. */
|
||||
#define sym_k_coerce_op 17 /* az_exp_op1 points to the value node
|
||||
whose value is to be coerced to the
|
||||
data type of this node. */
|
||||
#define sym_k_last_special_op 17
|
||||
|
||||
/*
|
||||
* Structure of an enumeration set entry
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
short int values_cnt;
|
||||
/* number of values in the enuemration set descriptor */
|
||||
unsigned short int *values;
|
||||
/* vector of values */
|
||||
} UilEnumSetDescDef, *UilEnumSetDescDefPtr;
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
**************** From UilKeyDef.h ************************************/
|
||||
/*
|
||||
* Token class literals
|
||||
*/
|
||||
#define tkn_k_class_argument 1
|
||||
#define tkn_k_class_charset 2
|
||||
#define tkn_k_class_color 3
|
||||
#define tkn_k_class_enumval 4
|
||||
#define tkn_k_class_font 5
|
||||
#define tkn_k_class_identifier 6
|
||||
#define tkn_k_class_keyword 7
|
||||
#define tkn_k_class_literal 8
|
||||
#define tkn_k_class_reason 9
|
||||
#define tkn_k_class_reserved 10
|
||||
#define tkn_k_class_special 11
|
||||
#define tkn_k_class_unused 12
|
||||
#define tkn_k_class_class 13
|
||||
#define tkn_k_class_child 14
|
||||
|
||||
/*
|
||||
* Keyword table entry structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char b_class;
|
||||
unsigned short int b_subclass;
|
||||
unsigned char b_length;
|
||||
unsigned char b_token;
|
||||
char *at_name;
|
||||
} key_keytable_entry_type;
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
************************ New Stuff **************************************/
|
||||
|
||||
/* For COMPOUND_STRING_COMPONENT */
|
||||
#define XmStringComponent "XmStringComponent"
|
||||
|
||||
/*
|
||||
* Names of the tables put in the binary database
|
||||
*/
|
||||
|
||||
#define Constraint_Tab 1
|
||||
#define Key_Table 2
|
||||
#define Key_Table_Case_Ins 3
|
||||
#define Allowed_Argument_Table 4
|
||||
#define Argument_Type_Table_Value 5
|
||||
#define Charset_Xmstring_Names_Table 6
|
||||
#define Charset_Wrdirection_Table 7
|
||||
#define Charset_Parsdirection_Table 8
|
||||
#define Charset_Charsize_Table 9
|
||||
#define Charset_Lang_Names_Table 10
|
||||
#define Charset_Lang_Codes_Table 11
|
||||
#define Allowed_Control_Table 12
|
||||
#define Enum_Set_Table 13
|
||||
#define Argument_Enum_Set_Table 14
|
||||
#define Enumval_Values_Table 15
|
||||
#define Uil_Widget_Names 16
|
||||
#define Uil_Argument_Names 17
|
||||
#define Uil_Reason_Names 18
|
||||
#define Uil_Enumval_names 19
|
||||
#define Uil_Charset_Names 20
|
||||
#define Related_Argument_Table 21
|
||||
#define Allowed_Reason_Table 22
|
||||
#define Uil_Widget_Funcs 23
|
||||
#define Uil_Gadget_Funcs 24
|
||||
#define Uil_Urm_Nondialog_Class 25
|
||||
#define Uil_Urm_Subtree_Resource 26
|
||||
#define Uil_Argument_Toolkit_Names 27
|
||||
#define Uil_Reason_Toolkit_Names 28
|
||||
#define Child_Class_Table 29
|
||||
#define Allowed_Child_Table 30
|
||||
#define Uil_Children_Names 31
|
||||
|
||||
/*
|
||||
* Binary Data Base Work
|
||||
*/
|
||||
#define DB_Compiled_Version 2
|
||||
|
||||
typedef struct _db_globals_struct
|
||||
{
|
||||
int version;
|
||||
int uil_max_arg;
|
||||
int uil_max_charset;
|
||||
int charset_lang_table_max;
|
||||
int uil_max_object;
|
||||
int uil_max_reason;
|
||||
int uil_max_enumval;
|
||||
int uil_max_enumset;
|
||||
int key_k_keyword_count;
|
||||
int key_k_keyword_max_length;
|
||||
int uil_max_child;
|
||||
} _db_globals;
|
||||
|
||||
typedef struct _db_header_struct
|
||||
{
|
||||
int table_id;
|
||||
int num_items;
|
||||
int table_size;
|
||||
} _db_header, *_db_header_ptr;
|
||||
|
||||
|
||||
#endif /* UilDBDef_h */
|
||||
/* DON'T ADD STUFF AFTER THIS #endif */
|
||||
5233
cde/osf/wml/motif.wml
Normal file
5233
cde/osf/wml/motif.wml
Normal file
File diff suppressed because it is too large
Load Diff
249
cde/osf/wml/wml.c
Normal file
249
cde/osf/wml/wml.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#ifdef REV_INFO
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$TOG: wml.c /main/8 1999/04/16 09:41:47 mgreess $"
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This is the main program for WML. It declares all global data structures
|
||||
* used during a compilation, and during output.
|
||||
*/
|
||||
|
||||
/*
|
||||
* WML is a semi-standard Unix application. It reads its input from
|
||||
* stdin, which is expected to be a stream containing a WML description
|
||||
* of a UIL language. If this stream is successfully parsed and semantically
|
||||
* validated, then WML writes a series of standard .h and .dat files into
|
||||
* the user directory. The .h files will be used directly to construct
|
||||
* the UIL compiler. The .dat files are used by other phases of UIL
|
||||
* table generation.
|
||||
*
|
||||
* The files created by WML are:
|
||||
*
|
||||
* .h files:
|
||||
* UilSymGen.h
|
||||
* UilSymArTy.h
|
||||
* UilSymRArg.h
|
||||
* UilDrmClas.h
|
||||
* UilConst.h
|
||||
* UilSymReas.h
|
||||
* UilSymArTa.h
|
||||
* UilSymCtl.h
|
||||
* UilSymNam.h
|
||||
* .dat files
|
||||
* argument.dat
|
||||
* reason.dat
|
||||
* grammar.dat
|
||||
* .mm files
|
||||
* wml-uil.mm
|
||||
*/
|
||||
|
||||
#include "wml.h"
|
||||
|
||||
#if defined(SYSV) || defined(SVR4)
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Globals used during WML parsing.
|
||||
*
|
||||
* WML uses globals exclusively to communicate data during parsing. The
|
||||
* current object being constructed is held by these globals, and all
|
||||
* routines called from the parse assume correct setting of these globals.
|
||||
* This simplisitic approach is possible since the WML description language
|
||||
* has no recursive constructs requiring a frame stack.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Error and other counts
|
||||
*/
|
||||
int wml_err_count = 0; /* total errors */
|
||||
int wml_line_count = 0; /* lines read from input */
|
||||
|
||||
/*
|
||||
* Dynamic ordered vector of all objects encountered during parse. This
|
||||
* is used to detect name collisions, and is the primary order vector
|
||||
* used for all other vectors constructed curing the semantic resolution
|
||||
* phase of processing.
|
||||
*/
|
||||
DynamicHandleListDef wml_synobj;
|
||||
DynamicHandleListDefPtr wml_synobj_ptr = &wml_synobj;
|
||||
|
||||
|
||||
/*
|
||||
* Dynamic vectors of vectors partitioned and ordered
|
||||
* as required by the semantic processing and output routines. All
|
||||
* point to resolved objects rather than syntactic objects.
|
||||
*/
|
||||
DynamicHandleListDef wml_obj_datatype; /* datatype objects */
|
||||
DynamicHandleListDefPtr wml_obj_datatype_ptr = &wml_obj_datatype;
|
||||
|
||||
DynamicHandleListDef wml_obj_enumval; /* enumeration value objects */
|
||||
DynamicHandleListDefPtr wml_obj_enumval_ptr = &wml_obj_enumval;
|
||||
|
||||
DynamicHandleListDef wml_obj_enumset; /* enumeration set objects */
|
||||
DynamicHandleListDefPtr wml_obj_enumset_ptr = &wml_obj_enumset;
|
||||
|
||||
DynamicHandleListDef wml_obj_reason; /* reason resource objects */
|
||||
DynamicHandleListDefPtr wml_obj_reason_ptr = &wml_obj_reason;
|
||||
|
||||
DynamicHandleListDef wml_obj_arg; /* argument resource objects */
|
||||
DynamicHandleListDefPtr wml_obj_arg_ptr = &wml_obj_arg;
|
||||
|
||||
DynamicHandleListDef wml_obj_child; /* argument resource objects */
|
||||
DynamicHandleListDefPtr wml_obj_child_ptr = &wml_obj_child;
|
||||
|
||||
DynamicHandleListDef wml_obj_allclass; /* metaclass, widget, gadget */
|
||||
DynamicHandleListDefPtr wml_obj_allclass_ptr = &wml_obj_allclass;
|
||||
|
||||
DynamicHandleListDef wml_obj_class; /* widget & gadget objects */
|
||||
DynamicHandleListDefPtr wml_obj_class_ptr = &wml_obj_class;
|
||||
|
||||
DynamicHandleListDef wml_obj_ctrlist; /* controls list objects */
|
||||
DynamicHandleListDefPtr wml_obj_ctrlist_ptr = &wml_obj_ctrlist;
|
||||
|
||||
DynamicHandleListDef wml_obj_charset; /* charset objects */
|
||||
DynamicHandleListDefPtr wml_obj_charset_ptr = &wml_obj_charset;
|
||||
|
||||
DynamicHandleListDef wml_tok_sens; /* case-sensitive tokens */
|
||||
DynamicHandleListDefPtr wml_tok_sens_ptr = &wml_tok_sens;
|
||||
|
||||
DynamicHandleListDef wml_tok_insens; /* case-insensitive tokens */
|
||||
DynamicHandleListDefPtr wml_tok_insens_ptr = &wml_tok_insens;
|
||||
|
||||
|
||||
/*
|
||||
* Routines only accessible in this module
|
||||
*/
|
||||
void wmlInit ();
|
||||
|
||||
/*
|
||||
* External variables
|
||||
*/
|
||||
extern int yyleng;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The WML main routine:
|
||||
*
|
||||
* 1. Initialize global storage
|
||||
* 2. Open the input file if there is one
|
||||
* 3. Parse the WML description in stdin. Exit on errors
|
||||
* 4. Perform semantic validation and resolution. Exit on errors.
|
||||
* 5. Output files
|
||||
*/
|
||||
|
||||
int main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
|
||||
int done;
|
||||
int fd; /* input file descriptor */
|
||||
|
||||
/*
|
||||
* Initialize storage
|
||||
*/
|
||||
wmlInit ();
|
||||
|
||||
/*
|
||||
* Assume that anything in argv must be an input file. Open it, and
|
||||
* dup it to stdin
|
||||
*/
|
||||
if ( argc > 1 )
|
||||
{
|
||||
if ( (fd=open(argv[1],O_RDONLY)) == -1 )
|
||||
printf ("\nCouldn't open file %s", argv[1]);
|
||||
else
|
||||
dup2 (fd, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process the input
|
||||
*/
|
||||
done = 0;
|
||||
while (!done)
|
||||
{
|
||||
|
||||
/*
|
||||
* Parse the input stream
|
||||
*/
|
||||
yyleng = 0; /* initialization safety */
|
||||
yyparse ();
|
||||
if ( wml_err_count > 0 ) break;
|
||||
printf ("\nParse of WML input complete");
|
||||
|
||||
/*
|
||||
* Perform semantic validation, and construct resolved data structures
|
||||
*/
|
||||
wmlResolveDescriptors ();
|
||||
if ( wml_err_count > 0 ) break;
|
||||
printf ("\nSemantic validation and resolution complete");
|
||||
|
||||
/*
|
||||
* Output
|
||||
*/
|
||||
wmlOutput ();
|
||||
if ( wml_err_count > 0 ) break;
|
||||
printf ("\nWML Uil*.h and wml-uil.mm file creation complete\n");
|
||||
|
||||
done = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Report inaction on errors
|
||||
*/
|
||||
if ( wml_err_count > 0 )
|
||||
{
|
||||
printf ("\nWML found %d errors, no or incomplete output produced\n",
|
||||
wml_err_count);
|
||||
/* Begin fixing the bug CR 4748 */
|
||||
exit(1);
|
||||
/* End fixing the bug CR 4748 */
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Routine to initialize WML.
|
||||
*
|
||||
* The main job is to dynamically allocate any dynamic lists to a reasonable
|
||||
* initial state.
|
||||
*/
|
||||
void wmlInit ()
|
||||
|
||||
{
|
||||
|
||||
/*
|
||||
* Initialize the list of all syntactic objects
|
||||
*/
|
||||
wmlInitHList (wml_synobj_ptr, 1000, TRUE);
|
||||
|
||||
}
|
||||
|
||||
yywrap()
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
686
cde/osf/wml/wml.h
Normal file
686
cde/osf/wml/wml.h
Normal file
@@ -0,0 +1,686 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
/* $XConsortium: wml.h /main/9 1995/08/29 11:10:33 drk $ */
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This file contains the structure and literal definitions required
|
||||
* by the WML processor
|
||||
*/
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define SUCCESS 1
|
||||
#define FAILURE 0
|
||||
|
||||
/*
|
||||
* Generic object pointer
|
||||
*/
|
||||
typedef char *ObjectPtr;
|
||||
|
||||
|
||||
/*
|
||||
* True and False for attributes, so setting is explicit
|
||||
*/
|
||||
#define WmlAttributeUnspecified 0
|
||||
#define WmlAttributeTrue 1
|
||||
#define WmlAttributeFalse 2
|
||||
|
||||
/*
|
||||
* Values of character set direction
|
||||
*/
|
||||
#define WmlCharSetDirectionLtoR 1
|
||||
#define WmlCharSetDirectionRtoL 2
|
||||
|
||||
/*
|
||||
* Values of character set character size
|
||||
*/
|
||||
#define WmlCharSizeOneByte 1
|
||||
#define WmlCharSizeTwoByte 2
|
||||
#define WmlCharSizeMixed1_2Byte 3
|
||||
|
||||
|
||||
/*
|
||||
* Upper case and lower case converters
|
||||
*/
|
||||
#define _upper(c) ((c) >= 'a' && (c) <= 'z' ? (c) & 0x5F:(c))
|
||||
#define _lower(c) ((c) >= 'A' && (c) <= 'Z' ? (c) | 0x20:(c))
|
||||
|
||||
|
||||
/*
|
||||
* The Uil token classes which are dealt with WML. Matched to definitions
|
||||
* in UilKeyDef.h, although this isn't required.
|
||||
*/
|
||||
#define WmlTokenClassArgument 1
|
||||
#define WmlTokenClassCharset 2
|
||||
#define WmlTokenClassColor 3
|
||||
#define WmlTokenClassEnumval 4
|
||||
#define WmlTokenClassFont 5
|
||||
#define WmlTokenClassIdentifier 6
|
||||
#define WmlTokenClassKeyword 7
|
||||
#define WmlTokenClassLiteral 8
|
||||
#define WmlTokenClassReason 9
|
||||
#define WmlTokenClassReserved 10
|
||||
#define WmlTokenClassSpecial 11
|
||||
#define WmlTokenClassUnused 12
|
||||
#define WmlTokenClassClass 13
|
||||
#define WmlTokenClassChild 14
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Structures for WML objects. Two kinds are created for each object
|
||||
* recognized and built as a WML description is read:
|
||||
* - A syntactic descriptor, which captures the information parse
|
||||
* from the input in pretty much its raw form
|
||||
* - A semantically resolved descriptor, in which pointers to
|
||||
* other descriptors have been resolved, ordering is done,
|
||||
* superclass inheritance is complete, etc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Syntactic structures. These are constructred during input parse.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* A dummy holding only a header. Allows access to the validation field.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int validation; /* a unique validation code */
|
||||
ObjectPtr rslvdef; /* the resolved object pointer */
|
||||
} WmlSynDef, *WmlSynDefPtr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* A class resource descriptor. This a subset of a full resource descriptor,
|
||||
* which captures those elements which can be overridden in a class declaration
|
||||
*/
|
||||
#define WmlClassResDefValid 871253
|
||||
|
||||
typedef struct WmlSynClassResDefStruct
|
||||
{
|
||||
int validation; /* WmlClassResDefValid */
|
||||
struct WmlSynClassResDefStruct
|
||||
*next; /* next descriptor in chain */
|
||||
char *name; /* resource name */
|
||||
char *type; /* override type name */
|
||||
char *dflt; /* override default value */
|
||||
short int exclude; /* WmlAttributeTrue if to be excluded */
|
||||
} WmlSynClassResDef, *WmlSynClassResDefPtr;
|
||||
|
||||
/*
|
||||
* A class child descriptor.
|
||||
*/
|
||||
#define WmlClassChildDefValid 780344
|
||||
|
||||
typedef struct WmlSynClassChildDefStruct
|
||||
{
|
||||
int validation; /* WmlClassChildDefValid */
|
||||
struct WmlSynClassChildDefStruct
|
||||
*next; /* next descriptor in chain */
|
||||
char *name; /* child name */
|
||||
} WmlSynClassChildDef, *WmlSynClassChildDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A class controls descriptor. It contains elements which can be added
|
||||
* to a controls reference.
|
||||
*/
|
||||
|
||||
#define WmlClassCtrlDefValid 7132320
|
||||
|
||||
typedef struct WmlSynClassCtrlDefStruct
|
||||
{
|
||||
int validation; /* WmlClassCtrlDefValid */
|
||||
struct WmlSynClassCtrlDefStruct
|
||||
*next; /* next descriptor in chain */
|
||||
char *name; /* controlled class name */
|
||||
} WmlSynClassCtrlDef, *WmlSynClassCtrlDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A class structure. One exists for each Class statement in a WML
|
||||
* description.
|
||||
*/
|
||||
#define WmlClassDefValid 93741
|
||||
|
||||
#define WmlClassTypeMetaclass 1
|
||||
#define WmlClassTypeWidget 2
|
||||
#define WmlClassTypeGadget 3
|
||||
|
||||
typedef struct WmlSynClassDefStruct
|
||||
{
|
||||
int validation; /* WmlClassDefValid */
|
||||
struct WmlClassDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
short int type; /* from WmlClassType... */
|
||||
short int dialog; /* TRUE if a dialog class (has
|
||||
window manager decoration, etc) */
|
||||
char *name; /* class name */
|
||||
char *superclass; /* superclass name */
|
||||
char *parentclass; /* parentclass name */
|
||||
char *widgetclass; /* widget class name */
|
||||
char *int_lit; /* internal literal name */
|
||||
char *convfunc; /* convenience function name */
|
||||
char *docname; /* name for docs */
|
||||
char *ctrlmapto; /* resource controls map to */
|
||||
WmlSynClassCtrlDefPtr
|
||||
controls; /* list of controlled classes */
|
||||
WmlSynClassResDefPtr
|
||||
resources; /* list of resources from input */
|
||||
WmlSynClassChildDefPtr
|
||||
children; /* list of automatic children */
|
||||
} WmlSynClassDef, *WmlSynClassDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A controls list structure. One is created for each ControlsList statement
|
||||
* in a WML description.
|
||||
*/
|
||||
#define WmlCtrlListDefValid 621298
|
||||
|
||||
typedef struct WmlSynCtrlListDefStruct
|
||||
{
|
||||
int validation; /* WmlCtrlListDefValid */
|
||||
struct WmlCtrlListDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
char *name; /* controls list name */
|
||||
WmlSynClassCtrlDefPtr
|
||||
controls; /* list of controlled classes */
|
||||
} WmlSynCtrlListDef, *WmlSynCtrlListDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A resource descriptor. One is created for each Resource statement
|
||||
* in a WML description
|
||||
*/
|
||||
#define WmlResourceDefValid 310538
|
||||
|
||||
#define WmlResourceTypeArgument 1
|
||||
#define WmlResourceTypeReason 2
|
||||
#define WmlResourceTypeConstraint 3
|
||||
#define WmlResourceTypeSubResource 4
|
||||
|
||||
typedef struct WmlSynResourceDefStruct
|
||||
{
|
||||
int validation; /* WmlResourceDefValid */
|
||||
struct WmlResourceDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
short int type; /* from WmlResourceType... */
|
||||
char *name; /* resource name */
|
||||
char *datatype; /* resource data type */
|
||||
char *int_lit; /* internal literal name */
|
||||
char *resliteral; /* resource name literal */
|
||||
char *enumset; /* enumeration set name */
|
||||
char *docname; /* name for docs */
|
||||
char *related; /* names related resource */
|
||||
char *dflt; /* default value */
|
||||
short int xrm_support; /* WmlAttributeTrue if can be
|
||||
Xrm resource */
|
||||
short int alias_cnt; /* alias count */
|
||||
char **alias_list; /* vector of aliass */
|
||||
} WmlSynResourceDef, *WmlSynResourceDefPtr;
|
||||
|
||||
/*
|
||||
* A child descriptor. One is created for each Child statement
|
||||
* in a WML description
|
||||
*/
|
||||
#define WmlChildDefValid 229629
|
||||
|
||||
typedef struct WmlSynChildDefStruct
|
||||
{
|
||||
int validation; /* WmlResourceDefValid */
|
||||
struct WmlChildDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
char *name; /* child name */
|
||||
char *class; /* child class */
|
||||
} WmlSynChildDef, *WmlSynChildDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A datatype descriptor
|
||||
*/
|
||||
#define WmlDataTypeDefValid 714210
|
||||
|
||||
typedef struct WmlSynDataTypeDefStruct
|
||||
{
|
||||
int validation; /* WmlDataTypeDefValid */
|
||||
struct WmlDataTypeDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
char *name; /* data type name */
|
||||
char *int_lit; /* internal literal name */
|
||||
char *docname; /* name for docs */
|
||||
short int xrm_support; /* WmlAttributeTrue if can be
|
||||
Xrm resource */
|
||||
} WmlSynDataTypeDef, *WmlSynDataTypeDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* An enumeration set values descriptor, as it occurs in the list for
|
||||
* an enumeration set descriptor.
|
||||
*/
|
||||
typedef struct WmlSynEnumSetValDefStruct
|
||||
{
|
||||
int validation; /* WmlEnumValueDefValid */
|
||||
struct WmlSynEnumSetValDefStruct
|
||||
*next; /* next descriptor in chain */
|
||||
char *name; /* enumeration value name */
|
||||
} WmlSynEnumSetValDef, *WmlSynEnumSetValDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* An enumeration set descriptor
|
||||
*/
|
||||
#define WmlEnumSetDefValid 931184
|
||||
|
||||
typedef struct WmlSynEnumSetDefStruct
|
||||
{
|
||||
int validation; /* WmlEnumSetDefValid */
|
||||
struct WmlEnumSetDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
char *name; /* enumeration set name */
|
||||
char *datatype; /* enumeration set data type */
|
||||
WmlSynEnumSetValDefPtr
|
||||
values; /* list of values in set */
|
||||
} WmlSynEnumSetDef, *WmlSynEnumSetDefPtr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* An enumeration value descriptor
|
||||
*/
|
||||
#define WmlEnumValueDefValid 172938
|
||||
|
||||
typedef struct WmlSynEnumValueDefStruct
|
||||
{
|
||||
int validation; /* WmlEnumValueDefValid */
|
||||
struct WmlEnumValueDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
char *name; /* enumeration value name */
|
||||
char *enumlit; /* name of defining literal */
|
||||
} WmlSynEnumValueDef, *WmlSynEnumValueDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A charset descriptor
|
||||
*/
|
||||
#define WmlCharSetDefValid 110983
|
||||
|
||||
typedef struct WmlSynCharSetDefStruct
|
||||
{
|
||||
int validation; /* WmlCharSetDefValid */
|
||||
struct WmlCharSetDefStruct
|
||||
*rslvdef; /* resolved definition */
|
||||
char *name; /* data type name */
|
||||
char *int_lit; /* internal literal name */
|
||||
char *xms_name; /* identifying XmString name */
|
||||
short int direction; /* WmlCharSetDirection... */
|
||||
short int parsedirection; /* WmlCharSetDirection... */
|
||||
short int charsize; /* WmlCharSize... */
|
||||
short int alias_cnt; /* alias count */
|
||||
char **alias_list; /* vector of aliases */
|
||||
} WmlSynCharSetDef, *WmlSynCharSetDefPtr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Data structures constructed during semantic validation. Each points
|
||||
* as required to syntactic data structures. These are typically accessed
|
||||
* from ordered pointer vectors.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* A datatype descriptor. It extends the syntactic element by assigning
|
||||
* a code to the descriptor.
|
||||
*/
|
||||
typedef struct WmlDataTypeDefStruct
|
||||
{
|
||||
struct WmlSynDataTypeDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
char *tkname; /* name for generating literals */
|
||||
} WmlDataTypeDef, *WmlDataTypeDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A charset descriptor. It extends the syntactic element by assigning
|
||||
* a code to the descriptor.
|
||||
*/
|
||||
typedef struct WmlCharSetDefStruct
|
||||
{
|
||||
struct WmlSynCharSetDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
char *tkname; /* name for generating literals */
|
||||
short int sym_code; /* code value for literals */
|
||||
} WmlCharSetDef, *WmlCharSetDefPtr;
|
||||
|
||||
/*
|
||||
* A child descriptor. It extends the syntactic element by assigning
|
||||
* a code and a pointer to the class to the descriptor.
|
||||
*/
|
||||
typedef struct WmlChildDefStruct
|
||||
{
|
||||
struct WmlSynChildDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
char *tkname; /* name for generating literals */
|
||||
short int sym_code; /* code value for literals */
|
||||
struct WmlClassDefStruct
|
||||
*class; /* class structure */
|
||||
struct WmlClassChildDefStruct
|
||||
*ref_ptr; /* used dynamically for search */
|
||||
} WmlChildDef, *WmlChildDefPtr;
|
||||
|
||||
/*
|
||||
* An element in the values list of an enumeration set. These elements have
|
||||
* separate lists in order to deal with the possibility of an enumeration
|
||||
* value which is a member of more than one list.
|
||||
*/
|
||||
typedef struct WmlEnumSetValDefStruct
|
||||
{
|
||||
struct WmlEnumSetValDefStruct
|
||||
*next; /* next value in list */
|
||||
struct WmlEnumValueDefStruct
|
||||
*value; /* value descriptor for element */
|
||||
} WmlEnumSetValDef, *WmlEnumSetValDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A resolved enumeration set descriptor
|
||||
*/
|
||||
typedef struct WmlEnumSetDefStruct
|
||||
{
|
||||
struct WmlSynEnumSetDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
char *tkname; /* name for generating literals */
|
||||
short int sym_code; /* code value for literals */
|
||||
WmlDataTypeDefPtr dtype_def; /* data type */
|
||||
short int values_cnt; /* count of # of values in set */
|
||||
WmlEnumSetValDefPtr
|
||||
values; /* list of values in set */
|
||||
} WmlEnumSetDef, *WmlEnumSetDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A resolved enumeration value descriptor
|
||||
*/
|
||||
typedef struct WmlEnumValueDefStruct
|
||||
{
|
||||
struct WmlSynEnumValueDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
short int sym_code; /* code value for literals */
|
||||
} WmlEnumValueDef, *WmlEnumValueDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A resource descriptor
|
||||
*/
|
||||
typedef struct WmlResourceDefStruct
|
||||
{
|
||||
struct WmlSynResourceDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
char *tkname; /* name for generating literals */
|
||||
short int sym_code; /* code value for literals */
|
||||
WmlDataTypeDefPtr dtype_def; /* data type for base definition */
|
||||
WmlEnumSetDefPtr enumset_def; /* enumeration set if specified */
|
||||
short int related_code; /* if non-0, the sym_code for the
|
||||
related (count) argument */
|
||||
short int xrm_support; /* if AttributeTrue, then the resource
|
||||
can be set in Xrm. Resolved
|
||||
from either explicit setting or
|
||||
data type setting */
|
||||
struct WmlClassDefStruct
|
||||
*ref_class; /* used for membership sort */
|
||||
struct WmlClassResDefStruct
|
||||
*ref_ptr; /* used dynamically for search */
|
||||
} WmlResourceDef, *WmlResourceDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A resource descriptor with overrides which is a member of the resource
|
||||
* list of a class descriptor.
|
||||
*/
|
||||
typedef struct WmlClassResDefStruct
|
||||
{
|
||||
struct WmlClassResDefStruct
|
||||
*next; /* next resource in list */
|
||||
WmlResourceDefPtr act_resource; /* actual resource descriptor */
|
||||
WmlDataTypeDefPtr over_dtype; /* overriding data type */
|
||||
char *dflt; /* overriding default */
|
||||
int exclude; /* WmlAttributeTrue if to be excluded */
|
||||
} WmlClassResDef, *WmlClassResDefPtr;
|
||||
|
||||
/*
|
||||
* A child descriptor which is a member of the children
|
||||
* list of a class descriptor.
|
||||
*/
|
||||
typedef struct WmlClassChildDefStruct
|
||||
{
|
||||
struct WmlClassChildDefStruct
|
||||
*next; /* next child in list */
|
||||
WmlChildDefPtr act_child; /* actual child descriptor */
|
||||
} WmlClassChildDef, *WmlClassChildDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* An element for the controls list of a resolved class descriptor
|
||||
*/
|
||||
typedef struct WmlClassCtrlDefStruct
|
||||
{
|
||||
struct WmlClassCtrlDefStruct
|
||||
*next; /* next control in list */
|
||||
struct WmlClassDefStruct
|
||||
*ctrl; /* class being controlled */
|
||||
} WmlClassCtrlDef, *WmlClassCtrlDefPtr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* A resolved class descriptor. It has a pointer to its superclass, and
|
||||
* a resource list consisting of its inherited resources followed by
|
||||
* its own resources.
|
||||
*/
|
||||
typedef struct WmlClassDefStruct
|
||||
{
|
||||
struct WmlSynClassDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
struct WmlClassDefStruct
|
||||
*superclass; /* superclass structure */
|
||||
struct WmlClassDefStruct
|
||||
*parentclass; /* parentclass structure */
|
||||
char *tkname; /* name to be used in literals.
|
||||
int_lit or name if no int_lit */
|
||||
short int sym_code; /* code value for literals */
|
||||
short int inherit_done; /* TRUE when inheritance complete */
|
||||
WmlClassResDefPtr arguments; /* linked argument list */
|
||||
WmlClassResDefPtr reasons; /* lined reason list */
|
||||
WmlClassCtrlDefPtr controls; /* list of controlled classes.
|
||||
Controls list references will
|
||||
be expanded into this list. */
|
||||
WmlClassChildDefPtr children; /* list of automatic children */
|
||||
struct WmlClassDefStruct
|
||||
*variant; /* the gadget class for a widget */
|
||||
struct WmlClassDefStruct
|
||||
*nondialog; /* the non-dialog ancestor of a
|
||||
dialog widget */
|
||||
WmlResourceDefPtr ctrlmapto; /* the resource controls map to */
|
||||
struct WmlClassCtrlDefStruct
|
||||
*ref_ptr; /* used dynamically for search */
|
||||
} WmlClassDef, *WmlClassDefPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A resolved controls list descriptor.
|
||||
*/
|
||||
typedef struct WmlCtrlListDefStruct
|
||||
{
|
||||
struct WmlSynCtrlListDefStruct
|
||||
*syndef; /* syntactic definition */
|
||||
WmlClassCtrlDefPtr controls; /* list of controlled classes */
|
||||
} WmlCtrlListDef, *WmlCtrlListDefPtr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Data structures used to locate and order objects in various ways.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Token structure used to create ordered token lists for generation of
|
||||
* UilKeyTab.h. The token string is in the order vector.
|
||||
*/
|
||||
typedef struct WmlKeyWTokenStruct
|
||||
{
|
||||
int class; /* token class, WmlTokenClass... */
|
||||
ObjectPtr objdef; /* object definition (resolved) */
|
||||
} WmlKeyWToken, *WmlKeyWTokenPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A grammar token as obtained from the UIL grammar file (Uil.y)
|
||||
*/
|
||||
typedef struct WmlGrammarTokenStruct
|
||||
{
|
||||
int class; /* token class, WmlTokenClass... */
|
||||
char *token; /* token name (literal) */
|
||||
int val; /* token id as value */
|
||||
} WmlGrammarToken, *WmlGrammarTokenPtr;
|
||||
|
||||
|
||||
/*
|
||||
* A list element which allows association of a name with an object.
|
||||
* Typically used to construct ordered lists.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *objname; /* object name */
|
||||
ObjectPtr objptr; /* the object */
|
||||
} ObjectHandleDef, *ObjectHandleDefPtr;
|
||||
|
||||
/*
|
||||
* A dynamic handle element list, extensible by malloc'ing more space.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int cnt; /* # entries in use */
|
||||
int max; /* max # entries available */
|
||||
int ordered; /* TRUE if list is lexicographically
|
||||
ordered by object name */
|
||||
ObjectHandleDefPtr hvec; /* vector of handle entries */
|
||||
} DynamicHandleListDef, *DynamicHandleListDefPtr;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Global declarations
|
||||
*/
|
||||
|
||||
/*
|
||||
* Defined in wml.c
|
||||
*/
|
||||
extern int wml_err_count; /* total errors */
|
||||
extern int wml_line_count; /* lines read from input */
|
||||
extern DynamicHandleListDefPtr
|
||||
wml_synobj_ptr; /* syntactic object list */
|
||||
|
||||
extern DynamicHandleListDefPtr wml_obj_datatype_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_enumval_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_enumset_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_reason_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_arg_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_child_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_allclass_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_class_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_ctrlist_ptr;
|
||||
extern DynamicHandleListDefPtr wml_obj_charset_ptr;
|
||||
|
||||
extern DynamicHandleListDefPtr wml_tok_sens_ptr;
|
||||
extern DynamicHandleListDefPtr wml_tok_insens_ptr;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Defined in wmlutils.c
|
||||
*/
|
||||
extern char *wmlAllocateString (); /* dynamic string copy */
|
||||
extern void wmlUpperCaseString (); /* convert to upper case */
|
||||
extern void wmlInitHList (); /* init dynamic list */
|
||||
extern void wmlResizeHList (); /* resize a list */
|
||||
extern void wmlClearHList (); /* clear a list for reuse */
|
||||
extern int wmlFindInHList (); /* find name in list */
|
||||
extern void wmlInsertInHList (); /* generic list insert */
|
||||
extern void wmlInsertInKeyList (); /* specialized list insert */
|
||||
extern WmlClassResDefPtr wmlResolveResIsMember ();
|
||||
/* is resource in class? */
|
||||
extern WmlClassChildDefPtr wmlResolveChildIsMember ();
|
||||
/* is child in class? */
|
||||
|
||||
/*
|
||||
* Defined in wmlsynbld.c
|
||||
*/
|
||||
extern char yystringval[]; /* any string value */
|
||||
extern char yynameval[]; /* any name (identifier) */
|
||||
extern int yytknval1; /* terminal token value 1 */
|
||||
extern int yytknval2; /* terminal token value 2 */
|
||||
extern ObjectPtr wml_cur_obj; /* object being constructed */
|
||||
extern ObjectPtr wml_cur_subobj; /* current subobject */
|
||||
extern void wmlCreateClass ();
|
||||
extern void wmlAddClassAttribute ();
|
||||
extern void wmlAddClassResource ();
|
||||
extern void wmlAddClassResourceAttribute ();
|
||||
extern void wmlAddClassControl ();
|
||||
extern void wmlAddCtrList ();
|
||||
extern void wmlCreateResource ();
|
||||
extern void wmlCreateDatatype ();
|
||||
extern void wmlAddResourceAttribute ();
|
||||
extern void wmlAddDatatypeAttribute ();
|
||||
extern void wmlAddCtrListControl ();
|
||||
extern void wmlCreateEnumSet ();
|
||||
extern void wmlAddEnumSetValue ();
|
||||
extern void wmlCreateEnumValue ();
|
||||
extern void wmlAddEnumValueAttribute ();
|
||||
extern void wmlCreateCharset ();
|
||||
extern void wmlAddCharsetAttribute ();
|
||||
extern void LexIssueError ();
|
||||
|
||||
|
||||
/*
|
||||
* Defined in wmlresolve.c
|
||||
*/
|
||||
extern void wmlResolveDescriptors ();
|
||||
extern void wmlMarkReferencePointers ();
|
||||
|
||||
|
||||
/*
|
||||
* Defined in wmlouth.c
|
||||
*/
|
||||
extern void wmlOutputHFiles ();
|
||||
|
||||
|
||||
/*
|
||||
* Defined in wmloutdat.c
|
||||
*/
|
||||
extern void wmlOutputDatFiles ();
|
||||
|
||||
/*
|
||||
* Define in wmloutp1 or wmloutp2
|
||||
*/
|
||||
extern void wmlOutput ();
|
||||
664
cde/osf/wml/wmldbcreate.c
Normal file
664
cde/osf/wml/wmldbcreate.c
Normal file
@@ -0,0 +1,664 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#ifdef REV_INFO
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$TOG: wmldbcreate.c /main/8 1997/04/14 12:55:30 dbl $"
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This is the program creates binary databases from WML output.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef X_NOT_STDC_ENV
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <Mrm/MrmWidget.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
|
||||
#include <Dt/Editor.h>
|
||||
#include <Dt/Help.h>
|
||||
#include <Dt/HelpDialog.h>
|
||||
#include <Dt/HelpQuickD.h>
|
||||
#include <Dt/MenuButton.h>
|
||||
#include <Dt/Print.h>
|
||||
#include <Dt/TermPrim.h>
|
||||
#include <Dt/Term.h>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* User supplied widget public.h and/or private.h files are to be added here
|
||||
* #ifdef for automatic use in uilwmdcreate script file
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* End of User supplied widget files
|
||||
*/
|
||||
|
||||
|
||||
#include "UilDBDef.h"
|
||||
#include "UilLexPars.h"
|
||||
|
||||
#include "UilSymGen.h" /* from WML */
|
||||
#include "UilSymArTy.h" /* from WML */
|
||||
#include "UilSymRArg.h" /* from WML */
|
||||
#include "UilSymArTa.h" /* from WML */
|
||||
#include "UilSymReas.h" /* from WML */
|
||||
#include "UilSymCtl.h" /* from WML */
|
||||
#include "UilConst.h" /* from WML */
|
||||
#include "UilSymNam.h" /* from WML */
|
||||
#include "UilSymEnum.h" /* from WML */
|
||||
#include "UilSymCSet.h" /* from WML */
|
||||
#include "UilUrmClas.h" /* from WML */
|
||||
#include "UilKeyTab.h" /* from WML */
|
||||
#include "UilSymChCl.h" /* from WML */
|
||||
#include "UilSymChTa.h" /* from WML */
|
||||
|
||||
void emit_globals();
|
||||
void emit_header(_db_header_ptr header);
|
||||
void emit_chars(int table_id);
|
||||
void emit_ints_and_string( int table_id);
|
||||
void emit_char_table( int table_id);
|
||||
void emit_length_and_string( int table_id);
|
||||
void emit_shorts( int table_id);
|
||||
void emit_int_and_table_shorts( int table_id);
|
||||
void emit_ints( int table_id);
|
||||
|
||||
FILE *bfile, *afile;
|
||||
int DEBUG=FALSE;
|
||||
char outfilename[80];
|
||||
char debugfilename[80];
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
_db_header header;
|
||||
|
||||
strcpy(outfilename, "motif.wmd");
|
||||
strcpy(debugfilename, "motif.dbg");
|
||||
|
||||
for (argc--, argv++; argc; argc--, argv++)
|
||||
{
|
||||
if (strcmp("-debug", *argv) == 0)
|
||||
{
|
||||
DEBUG=TRUE;
|
||||
}
|
||||
else if ((strcmp("-o", *argv) == 0))
|
||||
{
|
||||
strcpy(outfilename, argv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
bfile = fopen(outfilename, "w");
|
||||
if (bfile == (FILE *) NULL)
|
||||
{
|
||||
printf("\nCouldnt't open %s", outfilename);
|
||||
exit (1);
|
||||
}
|
||||
if (DEBUG)
|
||||
{
|
||||
afile = fopen(debugfilename, "w");
|
||||
if (afile == (FILE *) NULL)
|
||||
{
|
||||
printf("\nCouldn't open %s", debugfilename);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
emit_globals();
|
||||
|
||||
/*
|
||||
* UilConst
|
||||
* UilSymArty
|
||||
* UilSymCset - parts of it
|
||||
* UilSymChCl
|
||||
*/
|
||||
emit_chars(Constraint_Tab);
|
||||
emit_chars(Argument_Type_Table_Value);
|
||||
emit_chars(Charset_Wrdirection_Table);
|
||||
emit_chars(Charset_Parsdirection_Table);
|
||||
emit_chars(Charset_Charsize_Table);
|
||||
emit_chars(Child_Class_Table);
|
||||
/*
|
||||
* UilKeyTab
|
||||
*/
|
||||
emit_ints_and_string (Key_Table);
|
||||
emit_ints_and_string (Key_Table_Case_Ins);
|
||||
/*
|
||||
* UilSymArTa
|
||||
* UilSymCtl
|
||||
* UilSymReas
|
||||
* UilSymChTa
|
||||
*/
|
||||
emit_char_table (Allowed_Argument_Table);
|
||||
emit_char_table (Allowed_Control_Table);
|
||||
emit_char_table (Allowed_Reason_Table);
|
||||
emit_char_table (Allowed_Child_Table);
|
||||
/*
|
||||
* UilSymCset
|
||||
* UilSymNam
|
||||
* UilUrmClas
|
||||
*/
|
||||
emit_length_and_string (Charset_Xmstring_Names_Table);
|
||||
emit_length_and_string (Charset_Lang_Names_Table);
|
||||
emit_length_and_string (Uil_Widget_Names);
|
||||
emit_length_and_string (Uil_Argument_Names);
|
||||
emit_length_and_string (Uil_Reason_Names);
|
||||
emit_length_and_string (Uil_Enumval_names);
|
||||
emit_length_and_string (Uil_Charset_Names);
|
||||
emit_length_and_string (Uil_Widget_Funcs);
|
||||
emit_length_and_string (Uil_Argument_Toolkit_Names);
|
||||
emit_length_and_string (Uil_Reason_Toolkit_Names);
|
||||
emit_length_and_string (Uil_Children_Names);
|
||||
/*
|
||||
* UilSymCset
|
||||
* UilSymEnum
|
||||
* UilSymRArg
|
||||
* UilUrmClas
|
||||
*/
|
||||
emit_shorts (Charset_Lang_Codes_Table);
|
||||
emit_shorts (Argument_Enum_Set_Table);
|
||||
emit_shorts (Related_Argument_Table);
|
||||
emit_shorts (Uil_Gadget_Funcs);
|
||||
emit_shorts (Uil_Urm_Nondialog_Class);
|
||||
emit_shorts (Uil_Urm_Subtree_Resource);
|
||||
/*
|
||||
* UilSymEnum
|
||||
*/
|
||||
emit_int_and_table_shorts(Enum_Set_Table);
|
||||
/*
|
||||
* UilSymEnum
|
||||
*/
|
||||
emit_ints (Enumval_Values_Table);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
void emit_globals()
|
||||
{
|
||||
_db_globals globals;
|
||||
|
||||
globals.version = DB_Compiled_Version;
|
||||
globals.uil_max_arg = uil_max_arg;
|
||||
globals.uil_max_charset = uil_max_charset;
|
||||
globals.charset_lang_table_max = charset_lang_table_max;
|
||||
globals.uil_max_object = uil_max_object;
|
||||
globals.uil_max_reason = uil_max_reason;
|
||||
globals.uil_max_enumval = uil_max_enumval;
|
||||
globals.uil_max_enumset = uil_max_enumset;
|
||||
globals.key_k_keyword_count = key_k_keyword_count;
|
||||
globals.key_k_keyword_max_length = key_k_keyword_max_length;
|
||||
globals.uil_max_child = uil_max_child;
|
||||
|
||||
fwrite (&globals, sizeof (_db_globals), 1, bfile);
|
||||
if (DEBUG)
|
||||
fprintf(afile, "%d %d %d %d %d %d %d %d %d %d ", globals.version,
|
||||
globals.uil_max_arg, globals.uil_max_charset,
|
||||
globals.charset_lang_table_max, globals.uil_max_object,
|
||||
globals.uil_max_reason, globals.uil_max_enumval,
|
||||
globals.uil_max_enumset, globals.key_k_keyword_count,
|
||||
globals.key_k_keyword_max_length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void emit_header(header)
|
||||
_db_header_ptr header;
|
||||
{
|
||||
|
||||
fwrite (header, sizeof(_db_header), 1, bfile);
|
||||
if (DEBUG)
|
||||
fprintf(afile,
|
||||
"\n\nTableId=%d, NumEntries=%d, TableSize=%d \n",
|
||||
header->table_id, header->num_items, header->table_size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void emit_chars(table_id)
|
||||
int table_id;
|
||||
{
|
||||
_db_header header;
|
||||
unsigned char *ptr;
|
||||
int i;
|
||||
|
||||
switch (table_id)
|
||||
{
|
||||
case Constraint_Tab:
|
||||
/*
|
||||
* NOTE: The first entry is not used but we copy it anyway
|
||||
*/
|
||||
header.table_size = sizeof(constraint_tab_vec);
|
||||
header.num_items = header.table_size;
|
||||
header.table_id = Constraint_Tab;
|
||||
ptr = constraint_tab;
|
||||
break;
|
||||
case Argument_Type_Table_Value:
|
||||
/*
|
||||
* NOTE: The first entry is not used but we copy it anyway
|
||||
*/
|
||||
header.table_size = sizeof(argument_type_table_vec);
|
||||
header.num_items = header.table_size;
|
||||
header.table_id = Argument_Type_Table_Value;
|
||||
ptr = argument_type_table;
|
||||
break;
|
||||
case Charset_Wrdirection_Table:
|
||||
/*
|
||||
* NOTE: The first entry is not used but we copy it anyway
|
||||
*/
|
||||
header.table_size = sizeof(charset_wrdirection_table_vec);
|
||||
header.num_items = header.table_size;
|
||||
header.table_id = Charset_Wrdirection_Table;
|
||||
ptr = charset_writing_direction_table;
|
||||
break;
|
||||
case Charset_Parsdirection_Table:
|
||||
/*
|
||||
* NOTE: The first entry is not used but we copy it anyway
|
||||
*/
|
||||
header.table_size = sizeof(charset_parsdirection_table_vec);
|
||||
header.num_items = header.table_size;
|
||||
header.table_id = Charset_Parsdirection_Table;
|
||||
ptr = charset_parsing_direction_table;
|
||||
break;
|
||||
case Charset_Charsize_Table:
|
||||
/*
|
||||
* NOTE: The first entry is not used but we copy it anyway
|
||||
*/
|
||||
header.table_size = sizeof(charset_charsize_table_vec);
|
||||
header.num_items = header.table_size;
|
||||
header.table_id = Charset_Charsize_Table;
|
||||
ptr = charset_character_size_table;
|
||||
break;
|
||||
case Child_Class_Table:
|
||||
/*
|
||||
* NOTE: The first entry is not used but we copy it anyway
|
||||
*/
|
||||
header.table_size = sizeof(child_class_table_vec);
|
||||
header.num_items = header.table_size;
|
||||
header.table_id = Child_Class_Table;
|
||||
ptr = child_class_table;
|
||||
break;
|
||||
}
|
||||
|
||||
emit_header(&header);
|
||||
|
||||
fwrite (ptr, header.table_size, 1, bfile);
|
||||
if (DEBUG)
|
||||
{
|
||||
for (i=0; i<=header.num_items; i++)
|
||||
{
|
||||
fprintf(afile, "%d ", ptr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emit_ints_and_string(table_id)
|
||||
int table_id;
|
||||
{
|
||||
_db_header header;
|
||||
key_keytable_entry_type *table;
|
||||
int i;
|
||||
|
||||
switch (table_id)
|
||||
{
|
||||
/*
|
||||
* All tables are zero based unless otherwise noted
|
||||
*/
|
||||
case Key_Table:
|
||||
header.table_size = sizeof(key_table_vec);
|
||||
header.num_items = key_k_keyword_count;
|
||||
header.table_id = Key_Table;
|
||||
table = key_table;
|
||||
break;
|
||||
case Key_Table_Case_Ins:
|
||||
header.table_size = sizeof(key_table_case_ins_vec);
|
||||
header.num_items = key_k_keyword_count;
|
||||
header.table_id = Key_Table_Case_Ins;
|
||||
table = key_table_case_ins;
|
||||
break;
|
||||
}
|
||||
emit_header(&header);
|
||||
|
||||
fwrite (table, header.table_size, 1, bfile);
|
||||
for (i=0; i<header.num_items; i++)
|
||||
{
|
||||
fwrite (table[i].at_name, table[i].b_length + 1, 1, bfile);
|
||||
if (DEBUG)
|
||||
fprintf (afile, "%d %d %d %d %s", table[i].b_class, table[i].b_subclass,
|
||||
table[i].b_length, table[i].b_token, table[i].at_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void emit_char_table(table_id)
|
||||
int table_id;
|
||||
{
|
||||
unsigned char **table;
|
||||
_db_header header;
|
||||
unsigned char *entry_vec;
|
||||
int i, j;
|
||||
int num_bits = (uil_max_object + 7) / 8;
|
||||
|
||||
switch (table_id)
|
||||
{
|
||||
/*
|
||||
* All tables are 1 based unless otherwise specified
|
||||
*/
|
||||
case Allowed_Argument_Table:
|
||||
header.table_size = sizeof(allowed_argument_table_vec);
|
||||
header.num_items = uil_max_arg;
|
||||
header.table_id = Allowed_Argument_Table;
|
||||
table = allowed_argument_table;
|
||||
break;
|
||||
case Allowed_Control_Table:
|
||||
header.table_size = sizeof(allowed_control_table_vec);
|
||||
header.num_items = uil_max_object;
|
||||
header.table_id = Allowed_Control_Table;
|
||||
table = allowed_control_table;
|
||||
break;
|
||||
case Allowed_Reason_Table:
|
||||
header.table_size = sizeof(allowed_reason_table_vec);
|
||||
header.num_items = uil_max_reason;
|
||||
header.table_id = Allowed_Reason_Table;
|
||||
table = allowed_reason_table;
|
||||
break;
|
||||
case Allowed_Child_Table:
|
||||
header.table_size = sizeof(allowed_child_table_vec);
|
||||
header.num_items = uil_max_child;
|
||||
header.table_id = Allowed_Child_Table;
|
||||
table = allowed_child_table;
|
||||
break;
|
||||
}
|
||||
|
||||
emit_header(&header);
|
||||
|
||||
for (i=1; i<=header.num_items; i++) /* First not used */
|
||||
{
|
||||
entry_vec = table[i];
|
||||
fwrite (entry_vec, sizeof (char) * num_bits, 1, bfile);
|
||||
if (DEBUG)
|
||||
{
|
||||
for (j=0; j<num_bits; j++)
|
||||
{
|
||||
fprintf (afile, "%d, ", entry_vec[j]);
|
||||
}
|
||||
fprintf (afile, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emit_length_and_string(table_id)
|
||||
int table_id;
|
||||
{
|
||||
_db_header header;
|
||||
int *lengths;
|
||||
char *string_table;
|
||||
char **table;
|
||||
int i;
|
||||
|
||||
switch (table_id)
|
||||
{
|
||||
/*
|
||||
* all the tables are 1 based unless otherwise documented
|
||||
*/
|
||||
case Charset_Xmstring_Names_Table:
|
||||
header.table_size = sizeof(charset_xmstring_names_table_vec);
|
||||
header.num_items = uil_max_charset;
|
||||
header.table_id = Charset_Xmstring_Names_Table;
|
||||
table = charset_xmstring_names_table;
|
||||
break;
|
||||
case Charset_Lang_Names_Table:
|
||||
/*
|
||||
* This table is 0 based
|
||||
*/
|
||||
header.table_size = sizeof(charset_lang_names_table_vec);
|
||||
header.num_items = charset_lang_table_max - 1;
|
||||
header.table_id = Charset_Lang_Names_Table;
|
||||
table = charset_lang_names_table;
|
||||
break;
|
||||
case Uil_Widget_Names:
|
||||
header.table_size = sizeof(uil_widget_names_vec);
|
||||
header.num_items = uil_max_object;
|
||||
header.table_id = Uil_Widget_Names;
|
||||
table = uil_widget_names ;
|
||||
break;
|
||||
case Uil_Argument_Names:
|
||||
header.table_size = sizeof(uil_argument_names_vec);
|
||||
header.num_items = uil_max_arg;
|
||||
header.table_id = Uil_Argument_Names;
|
||||
table = uil_argument_names;
|
||||
break;
|
||||
case Uil_Reason_Names:
|
||||
header.table_size = sizeof(uil_reason_names_vec);
|
||||
header.num_items = uil_max_reason;
|
||||
header.table_id = Uil_Reason_Names;
|
||||
table = uil_reason_names;
|
||||
break;
|
||||
case Uil_Enumval_names:
|
||||
header.table_size = sizeof(uil_enumval_names_vec);
|
||||
header.num_items = uil_max_enumval;
|
||||
header.table_id = Uil_Enumval_names;
|
||||
table = uil_enumval_names;
|
||||
break;
|
||||
case Uil_Charset_Names:
|
||||
header.table_size = sizeof(uil_charset_names_vec);
|
||||
header.num_items = uil_max_charset;
|
||||
header.table_id = Uil_Charset_Names;
|
||||
table = uil_charset_names;
|
||||
break;
|
||||
case Uil_Widget_Funcs:
|
||||
header.table_size = sizeof(uil_widget_funcs_vec);
|
||||
header.num_items = uil_max_object;
|
||||
header.table_id = Uil_Widget_Funcs;
|
||||
table = uil_widget_funcs;
|
||||
break;
|
||||
case Uil_Argument_Toolkit_Names:
|
||||
header.table_size = sizeof(uil_argument_toolkit_names_vec);
|
||||
header.num_items = uil_max_arg;
|
||||
header.table_id = Uil_Argument_Toolkit_Names;
|
||||
table = uil_argument_toolkit_names;
|
||||
break;
|
||||
case Uil_Reason_Toolkit_Names:
|
||||
header.table_size = sizeof(uil_reason_toolkit_names_vec);
|
||||
header.num_items = uil_max_reason;
|
||||
header.table_id = Uil_Reason_Toolkit_Names;
|
||||
table = uil_reason_toolkit_names;
|
||||
break;
|
||||
case Uil_Children_Names:
|
||||
header.table_size = sizeof(uil_child_names_vec);
|
||||
header.num_items = uil_max_child;
|
||||
header.table_id = Uil_Children_Names;
|
||||
table = uil_child_names ;
|
||||
break;
|
||||
}
|
||||
|
||||
emit_header(&header);
|
||||
|
||||
lengths = (int *) malloc (sizeof (int) * (header.num_items + 1));
|
||||
|
||||
for (i=0; i<=header.num_items; i++)
|
||||
{
|
||||
if (table[i] != NULL)
|
||||
{
|
||||
/*
|
||||
* Add one to the length for the null terminator
|
||||
*/
|
||||
lengths[i] = strlen(table[i]) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lengths[i] = 0;
|
||||
}
|
||||
if (DEBUG)
|
||||
fprintf (afile, "%d ", lengths[i]);
|
||||
}
|
||||
fwrite (lengths, sizeof (int) * (header.num_items + 1), 1, bfile);
|
||||
for (i=0; i<=header.num_items; i++)
|
||||
{
|
||||
if (lengths[i])
|
||||
{
|
||||
/*
|
||||
* assumed lengths[i] = lengths[i] * sizeof(char)
|
||||
* Add one for the null terminator
|
||||
*/
|
||||
fwrite (table[i], lengths[i] + 1, 1, bfile);
|
||||
if (DEBUG)
|
||||
fprintf (afile, "%s ", table[i]);
|
||||
}
|
||||
}
|
||||
free (lengths);
|
||||
}
|
||||
|
||||
|
||||
void emit_shorts(table_id)
|
||||
int table_id;
|
||||
{
|
||||
_db_header header;
|
||||
unsigned short int *ptr;
|
||||
int i;
|
||||
|
||||
switch (table_id)
|
||||
{
|
||||
/*
|
||||
* All tables are 1 based unless otherwise noted
|
||||
*/
|
||||
case Charset_Lang_Codes_Table:
|
||||
/*
|
||||
* 0 based table
|
||||
*/
|
||||
header.table_size = sizeof(charset_lang_codes_table_vec);
|
||||
header.num_items = charset_lang_table_max - 1;
|
||||
header.table_id = Charset_Lang_Codes_Table;
|
||||
ptr = charset_lang_codes_table;
|
||||
break;
|
||||
case Argument_Enum_Set_Table:
|
||||
header.table_size = sizeof(argument_enumset_table_vec);
|
||||
header.num_items = uil_max_arg;
|
||||
header.table_id = Argument_Enum_Set_Table;
|
||||
ptr = argument_enumset_table;
|
||||
break;
|
||||
case Related_Argument_Table:
|
||||
header.table_size = sizeof(related_argument_table_vec);
|
||||
header.num_items = uil_max_arg;
|
||||
header.table_id = Related_Argument_Table;
|
||||
ptr = related_argument_table;
|
||||
break;
|
||||
case Uil_Gadget_Funcs:
|
||||
header.table_size = sizeof(uil_gadget_variants_vec);
|
||||
header.num_items = uil_max_object;
|
||||
header.table_id = Uil_Gadget_Funcs;
|
||||
ptr = uil_gadget_variants;
|
||||
break;
|
||||
case Uil_Urm_Nondialog_Class:
|
||||
header.table_size = sizeof(uil_urm_nondialog_class_vec);
|
||||
header.num_items = uil_max_object;
|
||||
header.table_id = Uil_Urm_Nondialog_Class;
|
||||
ptr = uil_urm_nondialog_class;
|
||||
break;
|
||||
case Uil_Urm_Subtree_Resource:
|
||||
header.table_size = sizeof(uil_urm_subtree_resource_vec);
|
||||
header.num_items = uil_max_object;
|
||||
header.table_id = Uil_Urm_Subtree_Resource;
|
||||
ptr = uil_urm_subtree_resource;
|
||||
break;
|
||||
}
|
||||
|
||||
emit_header(&header);
|
||||
|
||||
fwrite (ptr, header.table_size, 1, bfile);
|
||||
if (DEBUG)
|
||||
{
|
||||
for (i=0; i<header.num_items; i++)
|
||||
{
|
||||
fprintf(afile, "%d ", ptr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emit_int_and_table_shorts(table_id)
|
||||
int table_id;
|
||||
{
|
||||
_db_header header;
|
||||
UilEnumSetDescDef *table;
|
||||
int j, i;
|
||||
unsigned short int *value_vec;
|
||||
|
||||
switch (table_id)
|
||||
{
|
||||
/*
|
||||
* All tables are 1 based unless otherwise noted
|
||||
*/
|
||||
case Enum_Set_Table:
|
||||
header.table_size = sizeof(enum_set_table_vec);
|
||||
header.num_items = uil_max_enumset;
|
||||
header.table_id = Enum_Set_Table;
|
||||
table = enum_set_table;
|
||||
break;
|
||||
}
|
||||
|
||||
emit_header(&header);
|
||||
fwrite (table, header.table_size, 1, bfile);
|
||||
for (i=0; i<=header.num_items; i++) /* first is not used */
|
||||
{
|
||||
if (table[i].values_cnt)
|
||||
{
|
||||
fwrite (table[i].values, sizeof (short) * table[i].values_cnt, 1, bfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emit_ints(table_id)
|
||||
int table_id;
|
||||
{
|
||||
_db_header header;
|
||||
int *ptr;
|
||||
int i;
|
||||
|
||||
switch (table_id)
|
||||
/*
|
||||
* all tables are 1 based unless otherwise noted
|
||||
*/
|
||||
{
|
||||
case Enumval_Values_Table:
|
||||
header.table_size = sizeof(enumval_values_table_vec);
|
||||
header.num_items = uil_max_enumval;
|
||||
header.table_id = Enumval_Values_Table;
|
||||
ptr = enumval_values_table;
|
||||
break;
|
||||
}
|
||||
|
||||
emit_header(&header);
|
||||
|
||||
fwrite (ptr, header.table_size, 1, bfile);
|
||||
if (DEBUG)
|
||||
{
|
||||
for (i=0; i<header.num_items; i++)
|
||||
{
|
||||
fprintf(afile, "%d ", ptr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
127
cde/osf/wml/wmllex.l
Normal file
127
cde/osf/wml/wmllex.l
Normal file
@@ -0,0 +1,127 @@
|
||||
%{
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#if defined(__STDC__)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef XmConst
|
||||
#if (defined(__STDC__) && __STDC__) || !defined( NO_CONST )
|
||||
#define XmConst const
|
||||
#else
|
||||
#define XmConst
|
||||
#endif /* __STDC__ */
|
||||
#endif /* XmConst */
|
||||
|
||||
#ifdef YY_BUFFER_SIZE
|
||||
#define BUF_SIZE YY_BUFFER_SIZE
|
||||
#else
|
||||
#define BUF_SIZE 8192
|
||||
#endif
|
||||
|
||||
char yystringval[BUF_SIZE]; /* any string value */
|
||||
char yynameval[BUF_SIZE]; /* any identifier (name) */
|
||||
int yytknval1; /* terminal token value 1 */
|
||||
int yytknval2; /* terminal token value 2 */
|
||||
|
||||
%}
|
||||
|
||||
%p 3000
|
||||
%%
|
||||
|
||||
[ \t\f] {}
|
||||
|
||||
[\n] { wml_line_count += 1; }
|
||||
|
||||
"Class" { return CLASS; }
|
||||
"Resource" { return RESOURCE; }
|
||||
"DataType" { return DATATYPE; }
|
||||
"ControlList" { return CONTROLLIST; }
|
||||
"EnumerationSet" { return ENUMERATIONSET; }
|
||||
"EnumerationValue" { return ENUMERATIONVALUE; }
|
||||
"CharacterSet" { return CHARACTERSET; }
|
||||
"Child" { return CHILD; }
|
||||
|
||||
"DocName" { return DOCNAME; }
|
||||
"ConvenienceFunction" { return CONVFUNC; }
|
||||
"Alias" { return ALIAS; }
|
||||
"Type" { return TYPE; }
|
||||
"ResourceLiteral" { return RESOURCELITERAL; }
|
||||
"Related" { return RELATED; }
|
||||
"InternalLiteral" { return INTERNALLITERAL; }
|
||||
"Constraint" { return CONSTRAINT; }
|
||||
"Exclude" { return EXCLUDE;}
|
||||
"Resources" { return RESOURCES; }
|
||||
"SuperClass" { return SUPERCLASS; }
|
||||
"ParentClass" { return PARENTCLASS; }
|
||||
"Controls" { return CONTROLS; }
|
||||
"WidgetClass" { return WIDGETCLASS; }
|
||||
"DialogClass" { return DIALOGCLASS; }
|
||||
"Default" { return DEFAULT; }
|
||||
"EnumLiteral" { return ENUMLITERAL; }
|
||||
"XmStringCharsetName" { return XMSTRINGCHARSETNAME; }
|
||||
"FontListElementTag" { return XMSTRINGCHARSETNAME; }
|
||||
"Direction" { return DIRECTION; }
|
||||
"ParseDirection" { return PARSEDIRECTION; }
|
||||
"CharacterSize" { return CHARACTERSIZE; }
|
||||
"ControlsMapToResource" { return CTRLMAPSRESOURCE; }
|
||||
"Children" { return CHILDREN; }
|
||||
|
||||
"MetaClass" { return METACLASS;}
|
||||
"Widget" { return WIDGET;}
|
||||
"Gadget" { return GADGET;}
|
||||
"Argument" { return ARGUMENT;}
|
||||
"Reason" { return REASON;}
|
||||
"Constraint" { return CONSTRAINT;}
|
||||
"SubResource" { return SUBRESOURCE;}
|
||||
"True" { return ATTRTRUE; }
|
||||
"False" { return ATTRFALSE; }
|
||||
"LeftToRight" { return LEFTTORIGHT; }
|
||||
"RightToLeft" { return RIGHTTOLEFT; }
|
||||
"OneByte" { return ONEBYTE; }
|
||||
"TwoByte" { return TWOBYTE; }
|
||||
"MixedOneAndTwoByte" { return MIXED1_2BYTE; }
|
||||
|
||||
":" { return COLON; }
|
||||
";" { return SEMICOLON; }
|
||||
"=" { return EQUALS; }
|
||||
"{" { return LBRACE; }
|
||||
"}" { return RBRACE; }
|
||||
|
||||
"!"[^\n]* {}
|
||||
|
||||
"#"[^\n]* {}
|
||||
|
||||
[a-zA-Z_][a-zA-Z0-9$_]* { /* string without quotes */
|
||||
strcpy (yystringval, (XmConst char *) yytext);
|
||||
return STRING;
|
||||
}
|
||||
|
||||
\"[^"\n]*\\ { /* escaped character in the string */
|
||||
yymore();
|
||||
}
|
||||
|
||||
\"[^"\n]*\" { /* String in quotes */
|
||||
strncpy(yystringval, (XmConst char *) yytext+1, yyleng - 2);
|
||||
yystringval[yyleng-2] = '\0' ;
|
||||
return STRING;
|
||||
}
|
||||
\"[^"\n]* {
|
||||
printf ("\nUnterminated string near %s, line %d",
|
||||
yytext, wml_line_count);
|
||||
return ERRORTOKEN;
|
||||
}
|
||||
|
||||
. {
|
||||
printf ("\nEncountered illegal character '%c', line %d",
|
||||
yytext[0], wml_line_count);
|
||||
return ERRORTOKEN;
|
||||
}
|
||||
1942
cde/osf/wml/wmlouth.c
Normal file
1942
cde/osf/wml/wmlouth.c
Normal file
File diff suppressed because it is too large
Load Diff
812
cde/osf/wml/wmloutkey.c
Normal file
812
cde/osf/wml/wmloutkey.c
Normal file
@@ -0,0 +1,812 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#ifdef REV_INFO
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$TOG: wmloutkey.c /main/8 1997/04/14 12:55:51 dbl $"
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This module contains routines responsible for writing the .h files which
|
||||
* define the UIL lexer's keyword (token) tables. All files are written
|
||||
* into the current directory.
|
||||
*
|
||||
* Input:
|
||||
* The resolved objects
|
||||
* .dat files required to specify objects defined in Uil.y:
|
||||
* keyword.dat
|
||||
* reserved.dat
|
||||
*
|
||||
* Output:
|
||||
* UilKeyTab.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "wml.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Routines used only in this module
|
||||
*/
|
||||
void wmlKeyWBuildTables ();
|
||||
void wmlKeyWClassTokens ();
|
||||
void wmlKeyWGrammarTokens ();
|
||||
int wmlKeyWGrammarClass ();
|
||||
void wmlKeyWArgTokens ();
|
||||
void wmlKeyWReasonTokens ();
|
||||
void wmlKeyWCharsetTokens ();
|
||||
void wmlKeyWEnumvalTokens ();
|
||||
void wmlKeyWChildTokens ();
|
||||
void wmlKeyWMakeTokens ();
|
||||
void wmlOutputUilKeyTab ();
|
||||
void wmlOutputUilKeyTabBody ();
|
||||
void wmlTokenClassString ();
|
||||
void wmlTokenSymKString ();
|
||||
void wmlTokenTokenString ();
|
||||
void wmlOutputUilTokName ();
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
|
||||
static char *canned_warn =
|
||||
"/*\n\
|
||||
**\tThis file is automatically generated. Do not edit it by hand.\n\
|
||||
**/\n\n";
|
||||
|
||||
#define GrTokenMax 200 /* limit on grammar tokens */
|
||||
static int grtok_max_val = 0;
|
||||
static WmlGrammarTokenPtr grtok_vec[GrTokenMax];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Output control routine
|
||||
*/
|
||||
|
||||
void wmlOutputKeyWordFiles ()
|
||||
|
||||
{
|
||||
|
||||
wmlKeyWBuildTables ();
|
||||
wmlOutputUilKeyTab ();
|
||||
wmlOutputUilTokName ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to construct token tables for building UilKeyTab.h
|
||||
*
|
||||
* This routine constructs token entries for each token class which appears
|
||||
* in UilKeyTab.h (the token classes are defined in UilKeyDef.h). These
|
||||
* tokens are defined both by WML objects in object vectors, and by
|
||||
* tokens defined in Uil.y.
|
||||
*/
|
||||
|
||||
void wmlKeyWBuildTables ()
|
||||
|
||||
{
|
||||
|
||||
int ndx;
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the token vectors
|
||||
*/
|
||||
wmlInitHList (wml_tok_sens_ptr, 1000, TRUE);
|
||||
wmlInitHList (wml_tok_insens_ptr, 1000, TRUE);
|
||||
for ( ndx=0 ; ndx<GrTokenMax ; ndx++ )
|
||||
grtok_vec[ndx] = NULL;
|
||||
|
||||
/*
|
||||
* Read and enter the tokens from Uil.y (via tokens.dat)
|
||||
*/
|
||||
wmlKeyWGrammarTokens ();
|
||||
|
||||
/*
|
||||
* Enter the class, argument, reason, charset, child, and enumval tokens
|
||||
*/
|
||||
wmlKeyWClassTokens ();
|
||||
wmlKeyWArgTokens ();
|
||||
wmlKeyWReasonTokens ();
|
||||
wmlKeyWCharsetTokens ();
|
||||
wmlKeyWEnumvalTokens ();
|
||||
wmlKeyWChildTokens ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to read and enter tokens defined in Uil.y into the token tables.
|
||||
*/
|
||||
|
||||
void wmlKeyWGrammarTokens ()
|
||||
|
||||
{
|
||||
|
||||
FILE *infil; /* input file (tokens.dat) */
|
||||
int scanres; /* result of fscanf */
|
||||
int lineno = 1; /* current line number */
|
||||
char token[100]; /* current token */
|
||||
char class[100]; /* current class */
|
||||
int tokval; /* current token id (as value) */
|
||||
WmlGrammarTokenPtr grtok; /* new grammar token */
|
||||
int ndx;
|
||||
char sens_name[100]; /* for case-insensitive name */
|
||||
|
||||
|
||||
/*
|
||||
* Read tokens.dat. Recognize and save all tokens. Some are saved in the
|
||||
* global tokens vector so they will be put into UilKeyTab.h. All are
|
||||
* saved in an ordered vector to write UilTokName.h
|
||||
*
|
||||
* Special handling is required for tokens whose yacc definition conflicts
|
||||
* with common literals. In these cases, the token literal does not map
|
||||
* directly to its keyword in the language, and must be mapped as a special
|
||||
* case:
|
||||
* UILTRUE -> true/TRUE
|
||||
* UILFALSE -> false/FALSE
|
||||
* UILfile -> file/FILE
|
||||
* UILeof -> eof/EOF
|
||||
*/
|
||||
infil = fopen ("tokens.dat", "r");
|
||||
if ( infil == NULL )
|
||||
{
|
||||
printf ("\nCouldn't open tokens.dat");
|
||||
return;
|
||||
}
|
||||
|
||||
while ( TRUE )
|
||||
{
|
||||
scanres = fscanf (infil, "%s %d %s", token, &tokval, class);
|
||||
if ( scanres == EOF ) break;
|
||||
if ( scanres != 3 )
|
||||
{
|
||||
printf ("\nBadly formatted at line %d in tokens.dat", lineno);
|
||||
continue;
|
||||
}
|
||||
lineno += 1;
|
||||
|
||||
/*
|
||||
* Convert the token class, and construct a grammar token.
|
||||
*/
|
||||
grtok = (WmlGrammarTokenPtr) malloc(sizeof(WmlGrammarToken));
|
||||
grtok->class = wmlKeyWGrammarClass (class);
|
||||
grtok->token = wmlAllocateString (token);
|
||||
grtok->val = tokval;
|
||||
|
||||
/*
|
||||
* Save the token in the grammar token vector, indexed by its value
|
||||
* (for UilTokName.h)
|
||||
*/
|
||||
if ( grtok->val < GrTokenMax )
|
||||
{
|
||||
grtok_vec[grtok->val] = grtok;
|
||||
if ( grtok->val > grtok_max_val )
|
||||
grtok_max_val = grtok->val;
|
||||
}
|
||||
else
|
||||
printf ("\nToken id %d for %s exceed GrTokenMax",
|
||||
grtok->val, grtok->token);
|
||||
|
||||
/*
|
||||
* Enter tokens which appear in the keyword tables as keyword tokens.
|
||||
* These have their lower case names entered as the case-insensitive
|
||||
* keyword token string. Do special token literal mapping.
|
||||
*/
|
||||
switch ( grtok->class )
|
||||
{
|
||||
case WmlTokenClassKeyword:
|
||||
case WmlTokenClassReserved:
|
||||
strcpy (sens_name, grtok->token);
|
||||
for ( ndx=0 ; ndx<(int)strlen(sens_name) ; ndx++ )
|
||||
sens_name[ndx] = _lower(sens_name[ndx]);
|
||||
if ( strcmp(sens_name,"uiltrue") == 0 )
|
||||
strcpy (sens_name, "true");
|
||||
if ( strcmp(sens_name,"uilfalse") == 0 )
|
||||
strcpy (sens_name, "false");
|
||||
if ( strcmp(sens_name,"uilfile") == 0 )
|
||||
strcpy (sens_name, "file");
|
||||
if ( strcmp(sens_name,"uileof") == 0 )
|
||||
strcpy (sens_name, "eof");
|
||||
wmlKeyWMakeTokens (sens_name, grtok->class, (ObjectPtr)grtok);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (infil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This routine translates a string identifying a token class into
|
||||
* its matching internal literal.
|
||||
*/
|
||||
int wmlKeyWGrammarClass (token)
|
||||
char *token;
|
||||
|
||||
{
|
||||
|
||||
if ( strcmp(token,"argument") == 0 )
|
||||
return WmlTokenClassArgument;
|
||||
if ( strcmp(token,"charset") == 0 )
|
||||
return WmlTokenClassCharset;
|
||||
if ( strcmp(token,"color") == 0 )
|
||||
return WmlTokenClassColor;
|
||||
if ( strcmp(token,"enumval") == 0 )
|
||||
return WmlTokenClassEnumval;
|
||||
if ( strcmp(token,"font") == 0 )
|
||||
return WmlTokenClassFont;
|
||||
if ( strcmp(token,"identifier") == 0 )
|
||||
return WmlTokenClassIdentifier;
|
||||
if ( strcmp(token,"keyword") == 0 )
|
||||
return WmlTokenClassKeyword;
|
||||
if ( strcmp(token,"literal") == 0 )
|
||||
return WmlTokenClassLiteral;
|
||||
if ( strcmp(token,"reason") == 0 )
|
||||
return WmlTokenClassReason;
|
||||
if ( strcmp(token,"reserved") == 0 )
|
||||
return WmlTokenClassReserved;
|
||||
if ( strcmp(token,"special") == 0 )
|
||||
return WmlTokenClassSpecial;
|
||||
if ( strcmp(token,"unused") == 0 )
|
||||
return WmlTokenClassUnused;
|
||||
if ( strcmp(token,"class") == 0 )
|
||||
return WmlTokenClassClass;
|
||||
if (strcmp(token,"child") == 0) return WmlTokenClassChild;
|
||||
|
||||
printf ("\nUnrecognized token class %s", token);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to process the class objects and enter them in the token tables.
|
||||
* Aliases are also entered, under their own names.
|
||||
*/
|
||||
|
||||
void wmlKeyWClassTokens ()
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlClassDefPtr clsobj; /* class object */
|
||||
WmlSynClassDefPtr synobj; /* syntactic object */
|
||||
|
||||
|
||||
/*
|
||||
* Make tokens for all class entries
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
|
||||
{
|
||||
clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
|
||||
synobj = clsobj->syndef;
|
||||
wmlKeyWMakeTokens (synobj->name, WmlTokenClassClass, (ObjectPtr)clsobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to process the argument objects and enter them in the token tables.
|
||||
* Aliases are also entered, under their own names.
|
||||
*/
|
||||
|
||||
void wmlKeyWArgTokens ()
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlResourceDefPtr resobj; /* resource object */
|
||||
WmlSynResourceDefPtr synobj; /* syntactic object */
|
||||
int alias_ndx; /* alias loop index */
|
||||
|
||||
|
||||
/*
|
||||
* Make tokens for all argument entries
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
|
||||
{
|
||||
resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
|
||||
synobj = resobj->syndef;
|
||||
wmlKeyWMakeTokens (synobj->name, WmlTokenClassArgument, (ObjectPtr)resobj);
|
||||
for ( alias_ndx=0 ; alias_ndx<synobj->alias_cnt ; alias_ndx++ )
|
||||
wmlKeyWMakeTokens (synobj->alias_list[alias_ndx],
|
||||
WmlTokenClassArgument,
|
||||
(ObjectPtr)resobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to process the reason objects and enter them in the token tables.
|
||||
*/
|
||||
|
||||
void wmlKeyWReasonTokens ()
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlResourceDefPtr resobj; /* resource object */
|
||||
WmlSynResourceDefPtr synobj; /* syntactic object */
|
||||
int alias_ndx; /* alias loop index */
|
||||
|
||||
|
||||
/*
|
||||
* Make tokens for all reason entries
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
|
||||
{
|
||||
resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
|
||||
synobj = resobj->syndef;
|
||||
wmlKeyWMakeTokens (synobj->name, WmlTokenClassReason, (ObjectPtr)resobj);
|
||||
for ( alias_ndx=0 ; alias_ndx<synobj->alias_cnt ; alias_ndx++ )
|
||||
wmlKeyWMakeTokens (synobj->alias_list[alias_ndx],
|
||||
WmlTokenClassReason,
|
||||
(ObjectPtr)resobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Routine to process the child objects and enter them in the token tables.
|
||||
*/
|
||||
|
||||
void wmlKeyWChildTokens ()
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlChildDefPtr childobj; /* child object */
|
||||
WmlSynChildDefPtr synobj; /* syntactic object */
|
||||
|
||||
/*
|
||||
* Make tokens for all child entries
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
|
||||
{
|
||||
childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
|
||||
synobj = childobj->syndef;
|
||||
wmlKeyWMakeTokens (synobj->name, WmlTokenClassChild, (ObjectPtr)childobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to process the charset objects and enter them in the token tables.
|
||||
*/
|
||||
|
||||
void wmlKeyWCharsetTokens ()
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlCharSetDefPtr csobj; /* character set object */
|
||||
WmlSynCharSetDefPtr synobj; /* syntactic object */
|
||||
int alias_ndx; /* alias loop index */
|
||||
|
||||
|
||||
/*
|
||||
* Make tokens for all charset entries
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
|
||||
{
|
||||
csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
|
||||
synobj = csobj->syndef;
|
||||
wmlKeyWMakeTokens (synobj->name, WmlTokenClassCharset, (ObjectPtr)csobj);
|
||||
for ( alias_ndx=0 ; alias_ndx<synobj->alias_cnt ; alias_ndx++ )
|
||||
wmlKeyWMakeTokens (synobj->alias_list[alias_ndx],
|
||||
WmlTokenClassCharset,
|
||||
(ObjectPtr)csobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to process the enumval objects and enter them in the token tables.
|
||||
*/
|
||||
|
||||
void wmlKeyWEnumvalTokens ()
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlEnumValueDefPtr esobj; /* enumeration value object */
|
||||
WmlSynEnumValueDefPtr synobj; /* syntactic object */
|
||||
|
||||
|
||||
/*
|
||||
* Make tokens for all enumval entries
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
|
||||
{
|
||||
esobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
|
||||
synobj = esobj->syndef;
|
||||
wmlKeyWMakeTokens (synobj->name, WmlTokenClassEnumval, (ObjectPtr)esobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to create tokens and enter them in the token list.
|
||||
*
|
||||
* This routine constructs a case-sensitive and a case-insensitive token
|
||||
* and enters them the token vectors.
|
||||
*/
|
||||
void wmlKeyWMakeTokens (sens_name, class, obj)
|
||||
char *sens_name;
|
||||
int class;
|
||||
ObjectPtr obj;
|
||||
|
||||
{
|
||||
|
||||
WmlKeyWTokenPtr senstok; /* case-sensitive token */
|
||||
WmlKeyWTokenPtr insenstok; /* case-insensitive token */
|
||||
char insens_name[100];
|
||||
int ndx;
|
||||
|
||||
|
||||
/*
|
||||
* Create both tokens, with one having an upper-case name. The names are
|
||||
* entered only in the order vector, not in the token itself.
|
||||
*/
|
||||
senstok = (WmlKeyWTokenPtr) malloc (sizeof(WmlKeyWToken));
|
||||
insenstok = (WmlKeyWTokenPtr) malloc (sizeof(WmlKeyWToken));
|
||||
senstok->class = class;
|
||||
senstok->objdef = obj;
|
||||
insenstok->class = class;
|
||||
insenstok->objdef = obj;
|
||||
|
||||
strcpy (insens_name, sens_name);
|
||||
for ( ndx=0 ; ndx<(int)strlen(insens_name) ; ndx++ )
|
||||
insens_name[ndx] = _upper (insens_name[ndx]);
|
||||
|
||||
wmlInsertInKeyList(wml_tok_sens_ptr, sens_name, senstok);
|
||||
wmlInsertInKeyList(wml_tok_insens_ptr, insens_name, insenstok);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Routine to output UilKeyTab.h
|
||||
*
|
||||
* This routine dumps the tokens defined in the token tables into
|
||||
* UilKeyTab.h. Both the case-sensitive and case-insensitive token
|
||||
* lists are used.
|
||||
*/
|
||||
|
||||
void wmlOutputUilKeyTab ()
|
||||
|
||||
{
|
||||
|
||||
char *canned1 =
|
||||
"\n/* case sensitive keyword table */\n\
|
||||
static key_keytable_entry_type key_table_vec[] =\n\
|
||||
{\n";
|
||||
|
||||
char *canned2 =
|
||||
" };\n\
|
||||
externaldef(uil_sym_glbl) key_keytable_entry_type *key_table =\n\
|
||||
\t\tkey_table_vec;\n\n\
|
||||
/* Maximum length of a keyword, and table size */\n\
|
||||
externaldef(uil_sym_glbl) int key_k_keyword_max_length = %d;\n\
|
||||
externaldef(uil_sym_glbl) int key_k_keyword_count = %d;\n\n\
|
||||
/* case insensitive keyword table */\n\
|
||||
static key_keytable_entry_type key_table_case_ins_vec[] =\n\
|
||||
{\n";
|
||||
|
||||
char *canned3 =
|
||||
" };\n\
|
||||
externaldef(uil_sym_glbl) key_keytable_entry_type *key_table_case_ins =\n\
|
||||
\t\tkey_table_case_ins_vec;\n";
|
||||
|
||||
|
||||
FILE *outfil; /* output file */
|
||||
int ndx; /* loop index */
|
||||
int maxlen = 0; /* max keyword length */
|
||||
int maxkey = 0; /* # entries in keyword table */
|
||||
|
||||
|
||||
/*
|
||||
* Open the output file.
|
||||
*/
|
||||
outfil = fopen ("UilKeyTab.h", "w");
|
||||
if ( outfil == NULL )
|
||||
{
|
||||
printf ("\nCouldn't open UilKeyTab.h");
|
||||
return;
|
||||
}
|
||||
fprintf (outfil, canned_warn);
|
||||
|
||||
/*
|
||||
* Print the case sensitive and insensitive tables
|
||||
*/
|
||||
fprintf (outfil, canned1);
|
||||
wmlOutputUilKeyTabBody (outfil, wml_tok_sens_ptr, &maxlen, &maxkey);
|
||||
fprintf (outfil, canned2, maxlen, maxkey);
|
||||
wmlOutputUilKeyTabBody (outfil, wml_tok_insens_ptr, &maxlen, &maxkey);
|
||||
fprintf (outfil, canned3);
|
||||
|
||||
/*
|
||||
* close the output file
|
||||
*/
|
||||
printf ("\nCreated UilKeyTab.h");
|
||||
fclose (outfil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to output the body of a keyword table
|
||||
*/
|
||||
void wmlOutputUilKeyTabBody (outfil, tokvec, maxlen, maxkey)
|
||||
FILE *outfil;
|
||||
DynamicHandleListDefPtr tokvec;
|
||||
int *maxlen;
|
||||
int *maxkey;
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
WmlKeyWTokenPtr tok; /* current token */
|
||||
char *tokstg; /* string for token (keyword) */
|
||||
char tkclass[100]; /* token class string */
|
||||
char tksym[100]; /* token sym_k string */
|
||||
char tktoken[100]; /* token tkn_k_num string */
|
||||
|
||||
|
||||
/*
|
||||
* Loop over all tokens, and put out an entry for each.
|
||||
*/
|
||||
for ( ndx=0 ; ndx<tokvec->cnt ; ndx++ )
|
||||
{
|
||||
tok = (WmlKeyWTokenPtr) tokvec->hvec[ndx].objptr;
|
||||
tokstg = tokvec->hvec[ndx].objname;
|
||||
wmlTokenClassString (tkclass, tok);
|
||||
wmlTokenSymKString (tksym, tok);
|
||||
wmlTokenTokenString (tktoken, tok);
|
||||
fprintf (outfil, " {%s, %s, %d, %s, \"%s\"},\n",
|
||||
tkclass,
|
||||
tksym,
|
||||
strlen(tokstg),
|
||||
tktoken,
|
||||
tokstg);
|
||||
if ( (int)strlen(tokstg) > *maxlen )
|
||||
*maxlen = strlen (tokstg);
|
||||
*maxkey += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to return the string for a token class, tkn_k_class_...
|
||||
*/
|
||||
void wmlTokenClassString (dststg, tok)
|
||||
char *dststg;
|
||||
WmlKeyWTokenPtr tok;
|
||||
|
||||
{
|
||||
|
||||
switch ( tok->class )
|
||||
{
|
||||
case WmlTokenClassArgument:
|
||||
strcpy (dststg, "tkn_k_class_argument");
|
||||
return;
|
||||
case WmlTokenClassCharset:
|
||||
strcpy (dststg, "tkn_k_class_charset");
|
||||
return;
|
||||
case WmlTokenClassEnumval:
|
||||
strcpy (dststg, "tkn_k_class_enumval");
|
||||
return;
|
||||
case WmlTokenClassKeyword:
|
||||
strcpy (dststg, "tkn_k_class_keyword");
|
||||
return;
|
||||
case WmlTokenClassReason:
|
||||
strcpy (dststg, "tkn_k_class_reason");
|
||||
return;
|
||||
case WmlTokenClassReserved:
|
||||
strcpy (dststg, "tkn_k_class_reserved");
|
||||
return;
|
||||
case WmlTokenClassClass:
|
||||
strcpy (dststg, "tkn_k_class_class");
|
||||
return;
|
||||
case WmlTokenClassChild:
|
||||
strcpy (dststg, "tkn_k_class_child");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to return the string for a sym_k_... for some object
|
||||
*/
|
||||
void wmlTokenSymKString (dststg, tok)
|
||||
char *dststg;
|
||||
WmlKeyWTokenPtr tok;
|
||||
|
||||
{
|
||||
|
||||
WmlClassDefPtr clsobj; /* class object */
|
||||
WmlResourceDefPtr resobj; /* resource object */
|
||||
WmlCharSetDefPtr csobj; /* character set object */
|
||||
WmlEnumValueDefPtr esobj; /* enumeration value object */
|
||||
WmlChildDefPtr chobj; /* child object */
|
||||
|
||||
|
||||
switch ( tok->class )
|
||||
{
|
||||
case WmlTokenClassArgument:
|
||||
resobj = (WmlResourceDefPtr) tok->objdef;
|
||||
sprintf (dststg, "sym_k_%s_arg", resobj->tkname);
|
||||
return;
|
||||
case WmlTokenClassCharset:
|
||||
csobj = (WmlCharSetDefPtr) tok->objdef;
|
||||
sprintf (dststg, "sym_k_%s_charset", csobj->syndef->name);
|
||||
return;
|
||||
case WmlTokenClassEnumval:
|
||||
esobj = (WmlEnumValueDefPtr) tok->objdef;
|
||||
sprintf (dststg, "sym_k_%s_enumval", esobj->syndef->name);
|
||||
return;
|
||||
case WmlTokenClassKeyword:
|
||||
strcpy (dststg, "0");
|
||||
return;
|
||||
case WmlTokenClassReason:
|
||||
resobj = (WmlResourceDefPtr) tok->objdef;
|
||||
sprintf (dststg, "sym_k_%s_reason", resobj->tkname);
|
||||
return;
|
||||
case WmlTokenClassReserved:
|
||||
strcpy (dststg, "0");
|
||||
return;
|
||||
case WmlTokenClassClass:
|
||||
clsobj = (WmlClassDefPtr) tok->objdef;
|
||||
sprintf (dststg, "sym_k_%s_object", clsobj->tkname);
|
||||
return;
|
||||
case WmlTokenClassChild:
|
||||
chobj = (WmlChildDefPtr) tok->objdef;
|
||||
sprintf (dststg, "sym_k_%s_child", chobj->tkname);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to return the string for a token number, tkn_k_num_...
|
||||
*/
|
||||
void wmlTokenTokenString (dststg, tok)
|
||||
char *dststg;
|
||||
WmlKeyWTokenPtr tok;
|
||||
|
||||
{
|
||||
|
||||
WmlGrammarTokenPtr grtok; /* grammar token */
|
||||
|
||||
|
||||
switch ( tok->class )
|
||||
{
|
||||
case WmlTokenClassArgument:
|
||||
strcpy (dststg, "ARGUMENT_NAME");
|
||||
return;
|
||||
case WmlTokenClassCharset:
|
||||
strcpy (dststg, "CHARSET_NAME");
|
||||
return;
|
||||
case WmlTokenClassEnumval:
|
||||
strcpy (dststg, "ENUMVAL_NAME");
|
||||
return;
|
||||
case WmlTokenClassReason:
|
||||
strcpy (dststg, "REASON_NAME");
|
||||
return;
|
||||
case WmlTokenClassKeyword:
|
||||
case WmlTokenClassReserved:
|
||||
grtok = (WmlGrammarTokenPtr) tok->objdef;
|
||||
strcpy (dststg, grtok->token);
|
||||
return;
|
||||
case WmlTokenClassClass:
|
||||
strcpy (dststg, "CLASS_NAME");
|
||||
return;
|
||||
case WmlTokenClassChild:
|
||||
strcpy (dststg, "CHILD_NAME");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* routine to output UilTokName.h
|
||||
*/
|
||||
|
||||
void wmlOutputUilTokName ()
|
||||
|
||||
{
|
||||
|
||||
char *canned1 =
|
||||
"/*\tToken name table */\n\
|
||||
static char *tok_token_name_table_vec[] = \n\
|
||||
{\n";
|
||||
|
||||
char *canned2 =
|
||||
" };\n\
|
||||
externaldef(uil_sym_glbl) char **tok_token_name_table =\n\
|
||||
\t\ttok_token_name_table_vec;\n\n\
|
||||
/*\tNumber of entries in table */\n\
|
||||
externaldef(uil_sym_glbl) int tok_num_tokens = %d;\n";
|
||||
|
||||
|
||||
FILE *outfil; /* output file */
|
||||
int ndx; /* loop index */
|
||||
WmlGrammarTokenPtr grtok; /* current grammar token */
|
||||
|
||||
|
||||
/*
|
||||
* Open the output file.
|
||||
*/
|
||||
outfil = fopen ("UilTokName.h", "w");
|
||||
if ( outfil == NULL )
|
||||
{
|
||||
printf ("\nCouldn't open UilTokName.h");
|
||||
return;
|
||||
}
|
||||
fprintf (outfil, canned_warn);
|
||||
fprintf (outfil, canned1);
|
||||
|
||||
/*
|
||||
* Print the token name entries
|
||||
* Note: vector size is max_val + 1 for zeroth token
|
||||
*/
|
||||
for ( ndx=0 ; ndx<grtok_max_val+1 ; ndx++ )
|
||||
{
|
||||
grtok = grtok_vec[ndx];
|
||||
if ( grtok != NULL )
|
||||
fprintf (outfil, " \"%s\",\n", grtok->token);
|
||||
else
|
||||
fprintf (outfil, " \"UNKNOWN_TOKEN\",\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* close the output file
|
||||
*/
|
||||
fprintf (outfil, canned2, grtok_max_val+1);
|
||||
printf ("\nCreated UilTokName.h");
|
||||
fclose (outfil);
|
||||
|
||||
}
|
||||
310
cde/osf/wml/wmloutmm.c
Normal file
310
cde/osf/wml/wmloutmm.c
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#ifdef REV_INFO
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$XConsortium: wmloutmm.c /main/9 1995/08/29 11:10:59 drk $"
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This module contains routines responsible for writing the .mm files
|
||||
* produced by WML. All files are written into the current directory.
|
||||
*
|
||||
* Input:
|
||||
* The resolved objects
|
||||
*
|
||||
* Output:
|
||||
* wml-uil.mm
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "wml.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Routines used only in this module
|
||||
*/
|
||||
void wmlOutputWmlUilMm ();
|
||||
void wmlOutputWmlUilMmClass ();
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
int tabno = 1; /* table number */
|
||||
|
||||
/*
|
||||
* lists re-used repeatedly to order lists for printing
|
||||
*/
|
||||
DynamicHandleListDef mm_arg;
|
||||
DynamicHandleListDefPtr mm_arg_ptr = &mm_arg;
|
||||
DynamicHandleListDef mm_rsn;
|
||||
DynamicHandleListDefPtr mm_rsn_ptr = &mm_rsn;
|
||||
DynamicHandleListDef mm_ctl;
|
||||
DynamicHandleListDefPtr mm_ctl_ptr = &mm_ctl;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Output control routine, which simply outputs each .mm file in turn.
|
||||
*/
|
||||
|
||||
void wmlOutputMmFiles ()
|
||||
|
||||
{
|
||||
|
||||
wmlOutputWmlUilMm ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to write out wml-uil.mm
|
||||
*
|
||||
* This .mm file contains the tables which are to be included as an
|
||||
* appendix to the Uil manual. The tables give the arguments with their
|
||||
* default values, reasons, constraints, and controls for each class
|
||||
* in the class vectors.
|
||||
*/
|
||||
|
||||
void wmlOutputWmlUilMm ()
|
||||
|
||||
{
|
||||
|
||||
FILE *outfil; /* output file */
|
||||
int ndx; /* loop index */
|
||||
WmlClassDefPtr clsobj; /* class object */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Open the output file. Write the canned header stuff
|
||||
*/
|
||||
outfil = fopen ("wml-uil.mm", "w");
|
||||
if ( outfil == NULL )
|
||||
{
|
||||
printf ("\nCouldn't open wml-uil.mm");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize order lists for the tables.
|
||||
*/
|
||||
wmlInitHList (mm_arg_ptr, 200, TRUE);
|
||||
wmlInitHList (mm_rsn_ptr, 200, TRUE);
|
||||
wmlInitHList (mm_ctl_ptr, 200, TRUE);
|
||||
|
||||
/*
|
||||
* Write out a table for each class, for both widget and gadget variants
|
||||
*/
|
||||
for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
|
||||
{
|
||||
clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
|
||||
wmlOutputWmlUilMmClass (outfil, clsobj, clsobj->syndef->name);
|
||||
}
|
||||
|
||||
/*
|
||||
* close the output file
|
||||
*/
|
||||
printf ("\nCreated wml-uil.mm");
|
||||
fclose (outfil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to write a table for a class entry
|
||||
*/
|
||||
|
||||
void wmlOutputWmlUilMmClass (outfil, clsobj, name)
|
||||
FILE *outfil;
|
||||
WmlClassDefPtr clsobj;
|
||||
char *name;
|
||||
|
||||
{
|
||||
|
||||
char *canned1 =
|
||||
".bp\n\
|
||||
.ps 12\n";
|
||||
|
||||
char *canned2 =
|
||||
".ps 10\n\
|
||||
.vs 12\n\
|
||||
.LP\n\
|
||||
.TS H\n\
|
||||
tab(@);\n\
|
||||
lB lB\n\
|
||||
l l.\n\
|
||||
_\n\
|
||||
.sp 6p\n\
|
||||
Controls@Reasons\n\
|
||||
.sp 6p\n\
|
||||
_\n\
|
||||
.sp 6p\n\
|
||||
.TH\n";
|
||||
|
||||
char *canned3 =
|
||||
".TE\n\
|
||||
.TS H\n\
|
||||
tab(@);\n\
|
||||
lB lB lB\n\
|
||||
l l l.\n\
|
||||
_\n\
|
||||
.sp 6p\n\
|
||||
UIL Argument Name@Argument Type@Default Value\n\
|
||||
.sp 6p\n\
|
||||
_\n\
|
||||
.sp 6p\n\
|
||||
.TH\n";
|
||||
|
||||
char *canned4 =
|
||||
".TE\n";
|
||||
|
||||
WmlClassResDefPtr argref; /* current argument reference */
|
||||
WmlClassResDefPtr rsnref; /* current reason reference */
|
||||
WmlClassCtrlDefPtr ctlref; /* current controls reference */
|
||||
int argndx; /* to access ordered vector */
|
||||
int rsnndx; /* to access ordered vector */
|
||||
int ctlndx; /* to access ordered vector */
|
||||
|
||||
|
||||
/*
|
||||
* Write out header information
|
||||
*/
|
||||
fprintf (outfil, canned1);
|
||||
fprintf (outfil, "%s\n", name);
|
||||
fprintf (outfil, canned2);
|
||||
|
||||
/*
|
||||
* Alphabetize the controls, reason, and argument lists
|
||||
*/
|
||||
wmlClearHList (mm_arg_ptr);
|
||||
wmlClearHList (mm_rsn_ptr);
|
||||
wmlClearHList (mm_ctl_ptr);
|
||||
|
||||
argref = clsobj->arguments;
|
||||
while ( argref!= NULL )
|
||||
{
|
||||
while ( argref != NULL && argref->exclude == WmlAttributeTrue )
|
||||
argref = argref->next;
|
||||
if ( argref != NULL )
|
||||
{
|
||||
wmlInsertInHList (mm_arg_ptr,
|
||||
argref->act_resource->syndef->name,
|
||||
(ObjectPtr)argref);
|
||||
argref = argref->next;
|
||||
}
|
||||
}
|
||||
|
||||
rsnref = clsobj->reasons;
|
||||
while ( rsnref!=NULL )
|
||||
{
|
||||
while ( rsnref != NULL && rsnref->exclude == WmlAttributeTrue )
|
||||
rsnref = rsnref->next;
|
||||
if ( rsnref != NULL )
|
||||
{
|
||||
wmlInsertInHList (mm_rsn_ptr,
|
||||
rsnref->act_resource->syndef->name,
|
||||
(ObjectPtr)rsnref);
|
||||
|
||||
rsnref = rsnref->next;
|
||||
}
|
||||
}
|
||||
|
||||
ctlref = clsobj->controls;
|
||||
while ( ctlref != NULL )
|
||||
{
|
||||
wmlInsertInHList (mm_ctl_ptr,
|
||||
ctlref->ctrl->syndef->name,
|
||||
(ObjectPtr)ctlref);
|
||||
ctlref = ctlref->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the controls and reason table.
|
||||
*/
|
||||
rsnndx = 0;
|
||||
ctlndx = 0;
|
||||
if ( mm_ctl_ptr->cnt == 0 )
|
||||
fprintf (outfil, "No children are supported");
|
||||
while ( rsnndx<mm_rsn_ptr->cnt || ctlndx<mm_ctl_ptr->cnt )
|
||||
{
|
||||
if ( ctlndx < mm_ctl_ptr->cnt )
|
||||
{
|
||||
ctlref = (WmlClassCtrlDefPtr) mm_ctl_ptr->hvec[ctlndx].objptr;
|
||||
fprintf (outfil, "%s@",
|
||||
ctlref->ctrl->syndef->name);
|
||||
ctlndx += 1;
|
||||
}
|
||||
else
|
||||
fprintf (outfil, "@");
|
||||
|
||||
if ( rsnndx < mm_rsn_ptr->cnt )
|
||||
{
|
||||
rsnref = (WmlClassResDefPtr) mm_rsn_ptr->hvec[rsnndx].objptr;
|
||||
fprintf (outfil, "%s\n",
|
||||
rsnref->act_resource->syndef->name);
|
||||
rsnndx += 1;
|
||||
}
|
||||
else
|
||||
fprintf (outfil, "\n");
|
||||
}
|
||||
fprintf (outfil, canned3);
|
||||
|
||||
/*
|
||||
* Write out the argument table
|
||||
*/
|
||||
argndx = 0;
|
||||
while ( argndx < mm_arg_ptr->cnt )
|
||||
{
|
||||
argref = (WmlClassResDefPtr) mm_arg_ptr->hvec[argndx].objptr;
|
||||
fprintf (outfil, "%s@%s@",
|
||||
argref->act_resource->syndef->name,
|
||||
argref->act_resource->dtype_def->syndef->name);
|
||||
if ( argref->dflt != NULL )
|
||||
{
|
||||
if ( strchr(argref->dflt,' ') != 0 )
|
||||
fprintf (outfil, "T{\n%s\nT}\n",
|
||||
argref->dflt);
|
||||
else
|
||||
fprintf (outfil, "%s\n",
|
||||
argref->dflt);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (argref->act_resource->syndef->dflt != NULL) {
|
||||
if ( strchr(argref->act_resource->syndef->dflt,' ') != 0 )
|
||||
fprintf (outfil, "T{\n%s\nT}\n",
|
||||
argref->act_resource->syndef->dflt);
|
||||
else
|
||||
fprintf (outfil, "%s\n",
|
||||
argref->act_resource->syndef->dflt);
|
||||
}
|
||||
else
|
||||
fprintf (outfil, " \n");
|
||||
}
|
||||
argndx += 1;
|
||||
}
|
||||
fprintf (outfil, canned4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
53
cde/osf/wml/wmloutp1.c
Normal file
53
cde/osf/wml/wmloutp1.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#ifdef REV_INFO
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$XConsortium: wmloutp1.c /main/7 1995/07/13 21:04:31 drk $"
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This is the standard output module for creating the UIL compiler
|
||||
* .h files.
|
||||
*/
|
||||
|
||||
|
||||
#include "wml.h"
|
||||
|
||||
|
||||
void wmlOutput ()
|
||||
|
||||
{
|
||||
|
||||
/*
|
||||
* Output the .h files
|
||||
*/
|
||||
wmlOutputHFiles ();
|
||||
if ( wml_err_count > 0 ) return;
|
||||
|
||||
/*
|
||||
* Output the keyword (token) tables
|
||||
*/
|
||||
wmlOutputKeyWordFiles ();
|
||||
if ( wml_err_count > 0 ) return;
|
||||
|
||||
/*
|
||||
* Output the .mm files
|
||||
*/
|
||||
wmlOutputMmFiles ();
|
||||
if ( wml_err_count > 0 ) return;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
728
cde/osf/wml/wmlparse.y
Normal file
728
cde/osf/wml/wmlparse.y
Normal file
@@ -0,0 +1,728 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
/* "$TOG: wmlparse.y /main/10 1997/04/14 12:56:03 dbl $" */
|
||||
/*
|
||||
* This file defines the grammar for the Motif Widget Meta Language (WML),
|
||||
* the declarative language which describes the widget, gadgets, and
|
||||
* resources in the UIL language.
|
||||
*/
|
||||
|
||||
|
||||
%{
|
||||
|
||||
#include "wml.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <string.h> /* for strcpy() */
|
||||
#endif
|
||||
|
||||
#ifndef XmConst
|
||||
#if (defined(__STDC__) && __STDC__) || !defined( NO_CONST )
|
||||
#define XmConst const
|
||||
#else
|
||||
#define XmConst
|
||||
#endif /* __STDC__ */
|
||||
#endif /* XmConst */
|
||||
|
||||
/*
|
||||
* Undefine NULL, since it is defined in stdio
|
||||
*/
|
||||
#undef NULL
|
||||
|
||||
%}
|
||||
|
||||
|
||||
/*
|
||||
* Tokens defining terminals of the language
|
||||
*/
|
||||
|
||||
/*
|
||||
* token 0 is EOF, not defined here
|
||||
*/
|
||||
|
||||
/*
|
||||
* WML statements
|
||||
*/
|
||||
%token CLASS 1 /* CLASS statement */
|
||||
%token RESOURCE 2 /* RESOURCE statement */
|
||||
%token DATATYPE 3 /* DATATYPE statement */
|
||||
%token CONTROLLIST 4 /* CONTROLLIST statement */
|
||||
%token ENUMERATIONSET 5 /* ENUMERATIONSET statement */
|
||||
%token ENUMERATIONVALUE 6 /* ENUMERATIONVALUE statement */
|
||||
%token CHARACTERSET 7 /* CHARACTERSET statement */
|
||||
%token CHILD 50 /* CHILD statement */
|
||||
/*
|
||||
* Statement attributes
|
||||
*/
|
||||
%token DOCNAME 8 /* DOCNAME attribute */
|
||||
%token CONVFUNC 9 /* CONVENIENCEFUNCTION attribute */
|
||||
%token ALIAS 10 /* ALIAS attribute */
|
||||
%token TYPE 11 /* TYPE attribute */
|
||||
%token RESOURCELITERAL 12 /* RESOURCELITERAL attribute */
|
||||
%token RELATED 13 /* RELATED attribute */
|
||||
%token INTERNALLITERAL 14 /* INTERNALLITERAL attribute */
|
||||
%token XRMRESOURCE 15 /* XRMRESOURCE attribute */
|
||||
%token EXCLUDE 16 /* EXCLUDE attribute */
|
||||
%token RESOURCES 17 /* RESOURCES attribute */
|
||||
%token SUPERCLASS 18 /* SUPERCLASS attribute */
|
||||
%token CONTROLS 19 /* CONTROLS attribute */
|
||||
%token WIDGETCLASS 20 /* WIDGETCLASS attribute */
|
||||
%token DIALOGCLASS 21 /* DIALOGCLASS attribute */
|
||||
%token DEFAULT 22 /* DEFAULT attribute */
|
||||
%token ENUMLITERAL 23 /* ENUMLITERAL attribute */
|
||||
%token XMSTRINGCHARSETNAME 24 /* XMSTRINGCHARSETNAME attribute */
|
||||
%token DIRECTION 25 /* DIRECTION attribute */
|
||||
%token PARSEDIRECTION 26 /* PARSEDIRECTION attribute */
|
||||
%token CHARACTERSIZE 27 /* CHARACTERSIZE attribute */
|
||||
%token CTRLMAPSRESOURCE 28 /* CTRLMAPSRESOURCE attribute */
|
||||
%token CHILDREN 51 /* CHILDREN attribute */
|
||||
%token PARENTCLASS 52 /* PARENTCLASS attribute */
|
||||
/*
|
||||
* Other keywords
|
||||
*/
|
||||
%token METACLASS 29 /* CLASS type */
|
||||
%token WIDGET 30 /* CLASS type */
|
||||
%token GADGET 31 /* CLASS type */
|
||||
%token ARGUMENT 32 /* RESOURCE type */
|
||||
%token REASON 33 /* RESOURCE type */
|
||||
%token CONSTRAINT 34 /* RESOURCE type */
|
||||
%token SUBRESOURCE 35 /* RESOURCE type */
|
||||
%token ATTRTRUE 36 /* attribute value */
|
||||
%token ATTRFALSE 37 /* attribute value */
|
||||
%token LEFTTORIGHT 38 /* DIRECTION attribute */
|
||||
%token RIGHTTOLEFT 39 /* DIRECTION attribute */
|
||||
%token ONEBYTE 40 /* CHARACTERSIZE attribute */
|
||||
%token TWOBYTE 41 /* CHARACTERSIZE attribute */
|
||||
%token MIXED1_2BYTE 42 /* CHARACTERSIZE attribute */
|
||||
|
||||
|
||||
/*
|
||||
* Special characters
|
||||
*/
|
||||
%token COLON 43
|
||||
%token SEMICOLON 44
|
||||
%token EQUALS 45
|
||||
%token LBRACE 46
|
||||
%token RBRACE 47
|
||||
|
||||
/*
|
||||
* non-terminals
|
||||
*/
|
||||
%token STRING 48 /* Any user literal */
|
||||
|
||||
/*
|
||||
* Others
|
||||
*/
|
||||
%token ERRORTOKEN 49 /* Any unrecognized character */
|
||||
|
||||
|
||||
%start statement_block_list
|
||||
|
||||
%%
|
||||
|
||||
|
||||
/*
|
||||
* Productions of the WML grammar. All routines assume that current
|
||||
* data structures are kept in globals. This works as the language has
|
||||
* no recursive elements.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The language consists of blocks of statements. The blocks may occur
|
||||
* in any order, and blocks of the same kind may be arbitrarily repeated.
|
||||
*/
|
||||
|
||||
statement_block_list
|
||||
: /* empty */
|
||||
| statement_block_list statement_block
|
||||
;
|
||||
|
||||
statement_block
|
||||
: class_statement_block
|
||||
| resource_statement_block
|
||||
| child_statement_block
|
||||
| datatype_statement_block
|
||||
| ctrlist_statement_block
|
||||
| enumset_statement_block
|
||||
| enumval_statement_block
|
||||
| charset_statement_block
|
||||
| error { LexIssueError(0); } SEMICOLON
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
* Statement blocks. Each statement block begins with its identifying
|
||||
* keyword, then includes an arbitrary number of statements
|
||||
*/
|
||||
class_statement_block
|
||||
: CLASS
|
||||
class_statement_list
|
||||
;
|
||||
|
||||
class_statement_list
|
||||
: class_statement SEMICOLON
|
||||
| class_statement_list class_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
resource_statement_block
|
||||
: RESOURCE
|
||||
resource_statement_list
|
||||
;
|
||||
|
||||
resource_statement_list
|
||||
: resource_statement SEMICOLON
|
||||
| resource_statement_list resource_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
child_statement_block
|
||||
: CHILD
|
||||
child_statement_list
|
||||
;
|
||||
|
||||
child_statement_list
|
||||
: child_statement SEMICOLON
|
||||
| child_statement_list child_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
datatype_statement_block
|
||||
: DATATYPE
|
||||
datatype_statement_list
|
||||
;
|
||||
|
||||
datatype_statement_list
|
||||
: datatype_statement SEMICOLON
|
||||
| datatype_statement_list datatype_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
ctrlist_statement_block
|
||||
: CONTROLLIST
|
||||
ctrlist_statement_list
|
||||
;
|
||||
|
||||
ctrlist_statement_list
|
||||
: ctrlist_statement SEMICOLON
|
||||
| ctrlist_statement_list ctrlist_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
enumset_statement_block
|
||||
: ENUMERATIONSET
|
||||
enumset_statement_list
|
||||
;
|
||||
|
||||
enumset_statement_list
|
||||
: enumset_statement SEMICOLON
|
||||
| enumset_statement_list enumset_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
enumval_statement_block
|
||||
: ENUMERATIONVALUE
|
||||
enumval_statement_list
|
||||
;
|
||||
|
||||
enumval_statement_list
|
||||
: enumval_statement SEMICOLON
|
||||
| enumval_statement_list enumval_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
charset_statement_block
|
||||
: CHARACTERSET
|
||||
charset_statement_list
|
||||
;
|
||||
|
||||
charset_statement_list
|
||||
: charset_statement SEMICOLON
|
||||
| charset_statement_list charset_statement SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The CLASS statement
|
||||
*/
|
||||
class_statement
|
||||
: name
|
||||
COLON
|
||||
class_type
|
||||
{ wmlCreateClass (yynameval, yytknval1); }
|
||||
class_definition
|
||||
;
|
||||
|
||||
class_type
|
||||
: METACLASS { yytknval1 = METACLASS; }
|
||||
| WIDGET { yytknval1 = WIDGET; }
|
||||
| GADGET { yytknval1 = GADGET; }
|
||||
;
|
||||
|
||||
class_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE class_attribute_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
class_attribute_list
|
||||
: class_attribute
|
||||
| class_attribute_list class_attribute
|
||||
;
|
||||
|
||||
class_attribute
|
||||
: class_attribute_name
|
||||
EQUALS
|
||||
STRING
|
||||
{ wmlAddClassAttribute (yytknval1, yystringval); }
|
||||
SEMICOLON
|
||||
| boolean_class_attribute_name
|
||||
EQUALS
|
||||
boolean_attribute_value
|
||||
{ wmlAddClassAttribute (yytknval1, yytknval2); }
|
||||
SEMICOLON
|
||||
| class_resources SEMICOLON
|
||||
| class_controls SEMICOLON
|
||||
| class_children SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
class_attribute_name
|
||||
: SUPERCLASS { yytknval1 = SUPERCLASS; }
|
||||
| PARENTCLASS { yytknval1 = PARENTCLASS; }
|
||||
| INTERNALLITERAL { yytknval1 = INTERNALLITERAL; }
|
||||
| DOCNAME { yytknval1 = DOCNAME; }
|
||||
| CONVFUNC { yytknval1 = CONVFUNC; }
|
||||
| WIDGETCLASS { yytknval1 = WIDGETCLASS; }
|
||||
| CTRLMAPSRESOURCE { yytknval1 = CTRLMAPSRESOURCE; }
|
||||
;
|
||||
|
||||
boolean_class_attribute_name
|
||||
: DIALOGCLASS { yytknval1 = DIALOGCLASS; }
|
||||
|
||||
boolean_attribute_value
|
||||
: ATTRTRUE { yytknval2 = ATTRTRUE; }
|
||||
| ATTRFALSE { yytknval2 = ATTRFALSE; }
|
||||
;
|
||||
|
||||
class_resources
|
||||
: RESOURCES class_resources_block
|
||||
;
|
||||
|
||||
class_resources_block
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE class_resource_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
class_resource_list
|
||||
: class_resource_element
|
||||
| class_resource_list class_resource_element
|
||||
;
|
||||
|
||||
class_resource_element
|
||||
: name
|
||||
{ wmlAddClassResource (yynameval); }
|
||||
class_resource_attributes
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
class_resource_attributes
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE class_resource_attribute_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
class_resource_attribute_list
|
||||
: class_resource_attribute_element
|
||||
| class_resource_attribute_list class_resource_attribute_element
|
||||
;
|
||||
|
||||
class_resource_attribute_element
|
||||
: class_resource_attribute_name
|
||||
EQUALS
|
||||
STRING
|
||||
{ wmlAddClassResourceAttribute (yytknval1, yystringval); }
|
||||
SEMICOLON
|
||||
| boolean_class_resource_attribute_name
|
||||
EQUALS
|
||||
boolean_attribute_value
|
||||
{ wmlAddClassResourceAttribute (yytknval1, yytknval2); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
class_resource_attribute_name
|
||||
: TYPE { yytknval1 = TYPE; }
|
||||
| DEFAULT { yytknval1 = DEFAULT; }
|
||||
;
|
||||
|
||||
boolean_class_resource_attribute_name
|
||||
: EXCLUDE { yytknval1 = EXCLUDE; }
|
||||
;
|
||||
|
||||
class_controls
|
||||
: CONTROLS class_controls_block
|
||||
;
|
||||
|
||||
class_controls_block
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE class_controls_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
class_controls_list
|
||||
: class_controls_element
|
||||
| class_controls_list class_controls_element
|
||||
;
|
||||
|
||||
class_controls_element
|
||||
: name
|
||||
{ wmlAddClassControl (yynameval); }
|
||||
class_controls_attributes
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
class_controls_attributes
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
class_children
|
||||
: CHILDREN class_children_block
|
||||
;
|
||||
|
||||
class_children_block
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE class_children_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
class_children_list
|
||||
: class_children_element
|
||||
| class_children_list class_children_element
|
||||
;
|
||||
|
||||
class_children_element
|
||||
: name
|
||||
{ wmlAddClassChild (yynameval); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The RESOURCE statement
|
||||
*/
|
||||
resource_statement
|
||||
: name
|
||||
COLON
|
||||
resource_type
|
||||
{ wmlCreateResource (yynameval, yytknval1); }
|
||||
resource_definition
|
||||
;
|
||||
|
||||
resource_type
|
||||
: ARGUMENT { yytknval1 = ARGUMENT; }
|
||||
| REASON { yytknval1 = REASON; }
|
||||
| CONSTRAINT { yytknval1 = CONSTRAINT; }
|
||||
| SUBRESOURCE { yytknval1 = SUBRESOURCE; }
|
||||
;
|
||||
|
||||
resource_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE resource_attribute_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
resource_attribute_list
|
||||
: resource_attribute
|
||||
| resource_attribute_list resource_attribute
|
||||
;
|
||||
|
||||
resource_attribute
|
||||
: resource_attribute_name
|
||||
EQUALS
|
||||
STRING
|
||||
{ wmlAddResourceAttribute (yytknval1, yystringval); }
|
||||
SEMICOLON
|
||||
| boolean_resource_resource_attribute_name
|
||||
EQUALS
|
||||
boolean_attribute_value
|
||||
{ wmlAddResourceAttribute (yytknval1, yytknval2); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
resource_attribute_name
|
||||
: TYPE { yytknval1 = TYPE; }
|
||||
| RESOURCELITERAL { yytknval1 = RESOURCELITERAL; }
|
||||
| ENUMERATIONSET { yytknval1 = ENUMERATIONSET; }
|
||||
| INTERNALLITERAL { yytknval1 = INTERNALLITERAL; }
|
||||
| RELATED { yytknval1 = RELATED; }
|
||||
| DOCNAME { yytknval1 = DOCNAME; }
|
||||
| DEFAULT { yytknval1 = DEFAULT; }
|
||||
| ALIAS { yytknval1 = ALIAS; }
|
||||
;
|
||||
|
||||
boolean_resource_resource_attribute_name
|
||||
: XRMRESOURCE { yytknval1 = XRMRESOURCE; }
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
* The CHILD statement
|
||||
*/
|
||||
child_statement
|
||||
: name COLON STRING
|
||||
{ wmlCreateChild(yynameval, yystringval); }
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
* DATATYPE statement
|
||||
*/
|
||||
datatype_statement
|
||||
: name
|
||||
{ wmlCreateDatatype (yystringval); }
|
||||
datatype_definition
|
||||
;
|
||||
|
||||
datatype_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE datatype_attribute_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
datatype_attribute_list
|
||||
: datatype_attribute
|
||||
| datatype_attribute_list datatype_attribute
|
||||
;
|
||||
|
||||
datatype_attribute
|
||||
: datatype_attribute_name
|
||||
EQUALS
|
||||
STRING
|
||||
{ wmlAddDatatypeAttribute (yytknval1, yystringval); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
datatype_attribute_name
|
||||
: INTERNALLITERAL { yytknval1 = INTERNALLITERAL; }
|
||||
| DOCNAME { yytknval1 = DOCNAME; }
|
||||
| XRMRESOURCE { yytknval1 = XRMRESOURCE; }
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The CONTROLLIST statement
|
||||
*/
|
||||
ctrlist_statement
|
||||
: name
|
||||
{ wmlCreateOrAppendCtrlList (yynameval); }
|
||||
ctrlist_definition
|
||||
;
|
||||
|
||||
ctrlist_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE ctrlist_controls_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
ctrlist_controls_list
|
||||
: ctrlist_control
|
||||
| ctrlist_controls_list ctrlist_control
|
||||
;
|
||||
|
||||
ctrlist_control
|
||||
: name
|
||||
{ wmlAddCtrlListControl (yynameval); }
|
||||
ctrlist_controls_attributes
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
ctrlist_controls_attributes
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The ENUMERATIONSET statement
|
||||
*/
|
||||
enumset_statement
|
||||
: name
|
||||
COLON
|
||||
enumset_data_type
|
||||
{ wmlCreateEnumSet (yynameval, yystringval); }
|
||||
enumset_definition
|
||||
;
|
||||
|
||||
enumset_data_type
|
||||
:
|
||||
STRING
|
||||
;
|
||||
|
||||
enumset_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE enumset_value_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
enumset_value_list
|
||||
: enumset_value
|
||||
| enumset_value_list enumset_value
|
||||
;
|
||||
|
||||
enumset_value
|
||||
: name
|
||||
{ wmlAddEnumSetValue (yynameval); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The ENUMERATIONVALUE statement
|
||||
*/
|
||||
enumval_statement
|
||||
: name
|
||||
COLON
|
||||
{ wmlCreateEnumValue (yynameval); }
|
||||
enumvalue_definition
|
||||
;
|
||||
|
||||
enumvalue_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE enumvalue_attributes_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
enumvalue_attributes_list
|
||||
: enumvalue_attribute
|
||||
| enumvalue_attributes_list enumvalue_attribute
|
||||
;
|
||||
|
||||
enumvalue_attribute
|
||||
: enumvalue_attribute_name
|
||||
EQUALS
|
||||
STRING
|
||||
{ wmlAddEnumValueAttribute (yytknval1, yystringval); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
enumvalue_attribute_name
|
||||
: ENUMLITERAL { yytknval1 = ENUMLITERAL; }
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CHARACTERSET statement
|
||||
*/
|
||||
charset_statement
|
||||
: name
|
||||
{ wmlCreateCharset (yystringval); }
|
||||
charset_definition
|
||||
;
|
||||
|
||||
charset_definition
|
||||
: /* empty */
|
||||
| LBRACE RBRACE
|
||||
| LBRACE charset_attribute_list RBRACE
|
||||
| error { LexIssueError(RBRACE); } RBRACE
|
||||
;
|
||||
|
||||
charset_attribute_list
|
||||
: charset_attribute
|
||||
| charset_attribute_list charset_attribute
|
||||
;
|
||||
|
||||
charset_attribute
|
||||
: charset_attribute_name
|
||||
EQUALS
|
||||
STRING
|
||||
{ wmlAddCharsetAttribute (yytknval1, yystringval); }
|
||||
SEMICOLON
|
||||
| predefined_charset_attribute_name
|
||||
EQUALS
|
||||
predefined_charset_attribute_value
|
||||
{ wmlAddCharsetAttribute (yytknval1, yytknval2); }
|
||||
SEMICOLON
|
||||
| error { LexIssueError(SEMICOLON); } SEMICOLON
|
||||
;
|
||||
|
||||
charset_attribute_name
|
||||
: INTERNALLITERAL { yytknval1 = INTERNALLITERAL; }
|
||||
| ALIAS { yytknval1 = ALIAS; }
|
||||
| XMSTRINGCHARSETNAME { yytknval1 = XMSTRINGCHARSETNAME; }
|
||||
;
|
||||
|
||||
predefined_charset_attribute_name
|
||||
: DIRECTION { yytknval1 = DIRECTION; }
|
||||
| PARSEDIRECTION { yytknval1 = PARSEDIRECTION; }
|
||||
| CHARACTERSIZE { yytknval1 = CHARACTERSIZE; }
|
||||
;
|
||||
|
||||
predefined_charset_attribute_value
|
||||
: LEFTTORIGHT { yytknval2 = LEFTTORIGHT; }
|
||||
| RIGHTTOLEFT { yytknval2 = RIGHTTOLEFT; }
|
||||
| ONEBYTE { yytknval2 = ONEBYTE; }
|
||||
| TWOBYTE { yytknval2 = TWOBYTE; }
|
||||
| MIXED1_2BYTE { yytknval2 = MIXED1_2BYTE; }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Other productions
|
||||
*/
|
||||
name
|
||||
: STRING
|
||||
{ strcpy (yynameval, (XmConst char *)yystringval); }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
/*
|
||||
* Dummmy error routine, since we output our own.
|
||||
*/
|
||||
int yyerror (s)
|
||||
char *s;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include "wmllex.c"
|
||||
|
||||
1807
cde/osf/wml/wmlresolve.c
Normal file
1807
cde/osf/wml/wmlresolve.c
Normal file
File diff suppressed because it is too large
Load Diff
1277
cde/osf/wml/wmlsynbld.c
Normal file
1277
cde/osf/wml/wmlsynbld.c
Normal file
File diff suppressed because it is too large
Load Diff
194
cde/osf/wml/wmluiltok.l
Normal file
194
cde/osf/wml/wmluiltok.l
Normal file
@@ -0,0 +1,194 @@
|
||||
%{
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef XmConst
|
||||
#if (defined(__STDC__) && __STDC__) || !defined( NO_CONST )
|
||||
#define XmConst const
|
||||
#else
|
||||
#define XmConst
|
||||
#endif /* __STDC__ */
|
||||
#endif /* XmConst */
|
||||
|
||||
/*
|
||||
* lex program to construct token data for WML to generate token
|
||||
* table data.
|
||||
*
|
||||
* stdin is the file Uil.y
|
||||
*
|
||||
* it is searched for each occurance of a line starting with '%token'
|
||||
* when found various fields are extracted.
|
||||
*
|
||||
* when Uil.y has been scanned the collected data is written
|
||||
* to stdout.
|
||||
*/
|
||||
|
||||
%}
|
||||
|
||||
%a 9999 /* transitions */
|
||||
|
||||
%{
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define MAX_SYN 10
|
||||
|
||||
#ifdef yywrap
|
||||
#undef yywrap
|
||||
#endif
|
||||
|
||||
typedef struct _token
|
||||
{
|
||||
char * name;
|
||||
char * id;
|
||||
char * class;
|
||||
int num_syn;
|
||||
char * syn[MAX_SYN];
|
||||
}
|
||||
TokenRec, *Token;
|
||||
|
||||
TokenRec token[1000];
|
||||
TokenRec temp;
|
||||
|
||||
void add_token ();
|
||||
|
||||
int phase = 0;
|
||||
int keyword_count;
|
||||
int line_num = 0;
|
||||
int in_comment = 0;
|
||||
int in_include = 0;
|
||||
int in_token = 0;
|
||||
int state = 0;
|
||||
int used = 0;
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
%%
|
||||
|
||||
|
||||
[\n] {
|
||||
if (in_token == TRUE)
|
||||
{
|
||||
add_token (&temp);
|
||||
}
|
||||
|
||||
in_token = FALSE;
|
||||
line_num++;
|
||||
}
|
||||
|
||||
[ \t] { /* swallow */
|
||||
}
|
||||
|
||||
|
||||
"/\*" { /* swallow */
|
||||
}
|
||||
|
||||
|
||||
^%token {
|
||||
in_token = TRUE;
|
||||
state = 0;
|
||||
}
|
||||
|
||||
[a-zA-Z0-9_]+ {
|
||||
if (in_token == TRUE)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
temp.name = (char *)
|
||||
strcpy ((char *)
|
||||
malloc (strlen ((XmConst char *)yytext) + 1), (XmConst char *)yytext);
|
||||
|
||||
temp.num_syn = 0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
temp.id = (char *)
|
||||
strcpy ((char *)
|
||||
malloc (strlen ((XmConst char *)yytext) + 1), (XmConst char *)yytext);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
temp.class = (char *)
|
||||
strcpy ((char *)
|
||||
malloc (strlen ((XmConst char *)yytext) + 1), (XmConst char *)yytext);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
temp.syn[temp.num_syn] = (char *)
|
||||
strcpy ((char *)
|
||||
malloc (strlen ((XmConst char *)yytext) + 1), (XmConst char *)yytext);
|
||||
temp.num_syn++;
|
||||
|
||||
if (temp.num_syn > MAX_SYN)
|
||||
printf (
|
||||
"ERROR, too many synonyms, line %d\n",
|
||||
line_num);
|
||||
break;
|
||||
}
|
||||
|
||||
state++;
|
||||
}
|
||||
}
|
||||
|
||||
. { /* swallow */
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
|
||||
void
|
||||
add_token (t) /* keep sorted by name */
|
||||
Token t;
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (j=0; j<used; j++) /* for each token */
|
||||
{
|
||||
if (strcmp (token[j].name, t->name) > 0) /* goes here */
|
||||
{
|
||||
for (i=used++; i>j; i--) /* make hole */
|
||||
token[i] = token[i-1];
|
||||
|
||||
token[j] = *t; /* insert it */
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if we get there then it goes at the end of the list
|
||||
*/
|
||||
|
||||
token[used++] = *t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
yywrap ()
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (i=0; i<used; i++)
|
||||
{
|
||||
printf ("%s %s %s\n", token[i].name, token[i].id, token[i].class);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
416
cde/osf/wml/wmlutils.c
Normal file
416
cde/osf/wml/wmlutils.c
Normal file
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
* COPYRIGHT NOTICE
|
||||
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
|
||||
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
|
||||
* the full copyright text.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
#ifdef REV_INFO
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$XConsortium: wmlutils.c /main/8 1995/08/29 11:11:24 drk $"
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
|
||||
|
||||
/*
|
||||
* This file contains utilities used by WML.
|
||||
*/
|
||||
|
||||
|
||||
#include "wml.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Utility to allocate dynamic space for a string, and return the
|
||||
* dynamic copy. Produces a NULL on null input.
|
||||
*/
|
||||
|
||||
char *wmlAllocateString (stg)
|
||||
char *stg;
|
||||
|
||||
{
|
||||
|
||||
char *dynstg; /* the dynamic copy */
|
||||
|
||||
|
||||
if ( stg == NULL ) return NULL;
|
||||
|
||||
dynstg = (char *) malloc (strlen(stg)+1);
|
||||
strcpy (dynstg, stg);
|
||||
return dynstg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Utility to convert a string to upper case. The conversion happens in
|
||||
* place, destroying the original string.
|
||||
*/
|
||||
|
||||
void wmlUpperCaseString (stg)
|
||||
char *stg;
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* loop index */
|
||||
|
||||
|
||||
if ( stg == NULL ) return;
|
||||
for ( ndx=0 ; ndx<strlen(stg) ; ndx++ )
|
||||
stg[ndx] = _upper (stg[ndx]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routines for accessing and manipulating dynamic handle lists.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Initialize a dynamic handle list. Allocate a vector of the given
|
||||
* size, and set the count and number used (0).
|
||||
*
|
||||
* listptr the list to be inited
|
||||
* size # entries in handle vector
|
||||
* is_ordered TRUE is list is to be ordered
|
||||
*/
|
||||
|
||||
void wmlInitHList (listptr, size, is_ordered)
|
||||
DynamicHandleListDefPtr listptr;
|
||||
int size;
|
||||
int is_ordered;
|
||||
|
||||
{
|
||||
|
||||
listptr->cnt = 0;
|
||||
listptr->max = size;
|
||||
listptr->ordered = is_ordered;
|
||||
listptr->hvec = (ObjectHandleDefPtr) malloc(size*sizeof(ObjectHandleDef));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to resize a dynamic handle list. Increases the size if required,
|
||||
* but does nothing if the list is already big enough.
|
||||
*
|
||||
* listptr the dynamic list
|
||||
* new_size new list size
|
||||
*/
|
||||
|
||||
void wmlResizeHList (listptr, new_size)
|
||||
DynamicHandleListDefPtr listptr;
|
||||
int new_size;
|
||||
|
||||
{
|
||||
|
||||
ObjectHandleDefPtr new_vec; /* reallocated vector */
|
||||
|
||||
|
||||
if ( listptr->max >= new_size ) return;
|
||||
listptr->max = new_size;
|
||||
new_vec = (ObjectHandleDefPtr) realloc
|
||||
(listptr->hvec, new_size*sizeof(ObjectHandleDef));
|
||||
listptr->hvec = new_vec;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to clear a dynamic handle list. It leaves the handle vector intact,
|
||||
* but frees all the allocated names. The count is reset to 0.
|
||||
* but does nothing if the list is already big enough.
|
||||
*
|
||||
* listptr the dynamic list
|
||||
*/
|
||||
|
||||
void wmlClearHList (listptr)
|
||||
DynamicHandleListDefPtr listptr;
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* current index in list */
|
||||
|
||||
|
||||
for ( ndx=0 ; ndx<listptr->cnt ; ndx++ )
|
||||
{
|
||||
free (listptr->hvec[ndx].objname);
|
||||
listptr->hvec[ndx].objname = NULL;
|
||||
}
|
||||
listptr->cnt = 0;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Function to find a name in a dynamic list. This will function on both
|
||||
* ordered and unordered lists.
|
||||
*
|
||||
* listptr the dynamic list
|
||||
* name the name to look up in the list
|
||||
*
|
||||
* returns:
|
||||
* >= 0 name found, index in list
|
||||
* < 0 name not found
|
||||
*/
|
||||
|
||||
int wmlFindInHList (listptr, name)
|
||||
DynamicHandleListDefPtr listptr;
|
||||
char *name;
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* current index in list */
|
||||
int londx; /* low index */
|
||||
int hindx; /* high index */
|
||||
int midndx; /* midpoint index */
|
||||
int cmpres; /* strcmp result */
|
||||
|
||||
|
||||
/*
|
||||
* Binary search if ordered, brute force otherwise
|
||||
*/
|
||||
if ( listptr->ordered )
|
||||
{
|
||||
for ( londx=0,hindx=listptr->cnt-1 ; hindx>=londx ; )
|
||||
{
|
||||
midndx = (londx+hindx) / 2;
|
||||
cmpres = strcmp (name, listptr->hvec[midndx].objname);
|
||||
if ( cmpres < 0 )
|
||||
hindx = midndx - 1;
|
||||
if ( cmpres > 0 )
|
||||
londx = midndx + 1;
|
||||
if ( cmpres == 0 )
|
||||
return midndx;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ndx=0 ; ndx<listptr->cnt ; ndx++ )
|
||||
if ( strcmp(name,listptr->hvec[ndx].objname) == 0 )
|
||||
return ndx;
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Routine to insert an entry into a list. The insertion is ordered or
|
||||
* unordered depending on the way the list is marked. Unordered lists
|
||||
* insert at the end. This routine assumes no duplicates will be entered
|
||||
* in the list.
|
||||
*
|
||||
* listptr the list
|
||||
* name the name under which to insert
|
||||
* obj the object to insert
|
||||
*/
|
||||
|
||||
void wmlInsertInHList (listptr, name, obj)
|
||||
DynamicHandleListDefPtr listptr;
|
||||
char *name;
|
||||
ObjectPtr obj;
|
||||
|
||||
{
|
||||
|
||||
int ndx; /* current index in list */
|
||||
int londx; /* low index */
|
||||
int hindx; /* high index */
|
||||
int midndx; /* midpoint index */
|
||||
int newndx; /* new entry index */
|
||||
int cmpres; /* strcmp result */
|
||||
|
||||
|
||||
/*
|
||||
* Guarantee enough space in the list
|
||||
*/
|
||||
wmlResizeHList (listptr, listptr->cnt+1);
|
||||
|
||||
/*
|
||||
* Binary search and insert if ordered, brute force otherwise
|
||||
*/
|
||||
if ( listptr->ordered )
|
||||
{
|
||||
if ( listptr->cnt == 0 )
|
||||
{
|
||||
listptr->hvec[0].objname = wmlAllocateString (name);
|
||||
listptr->hvec[0].objptr = obj;
|
||||
listptr->cnt += 1;
|
||||
return;
|
||||
}
|
||||
for ( londx=0,hindx=listptr->cnt-1 ; hindx>=londx ; )
|
||||
{
|
||||
midndx = (londx+hindx) / 2;
|
||||
cmpres = strcmp (name, listptr->hvec[midndx].objname);
|
||||
if ( cmpres == 0 )
|
||||
{
|
||||
printf ("\nwmlInsertInHList: duplicate name '%s'found\n", name);
|
||||
return;
|
||||
}
|
||||
if ( londx == hindx ) break;
|
||||
if ( cmpres < 0 )
|
||||
hindx = midndx - 1;
|
||||
if ( cmpres > 0 )
|
||||
londx = midndx + 1;
|
||||
}
|
||||
/*
|
||||
* The new entry will go either at midndx or after midndx. Move down
|
||||
* the vector appropriately.
|
||||
*/
|
||||
if ( cmpres < 0 )
|
||||
newndx = midndx;
|
||||
else
|
||||
newndx = midndx + 1;
|
||||
for ( ndx=listptr->cnt-1 ; ndx>=newndx ; ndx-- )
|
||||
{
|
||||
listptr->hvec[ndx+1].objname = listptr->hvec[ndx].objname;
|
||||
listptr->hvec[ndx+1].objptr = listptr->hvec[ndx].objptr;
|
||||
}
|
||||
listptr->hvec[newndx].objname = wmlAllocateString (name);
|
||||
listptr->hvec[newndx].objptr = obj;
|
||||
listptr->cnt += 1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
listptr->hvec[listptr->cnt].objname = wmlAllocateString (name);
|
||||
listptr->hvec[listptr->cnt].objptr = obj;
|
||||
listptr->cnt += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Routine to insert an entry into a token list. The insertion is ordered.
|
||||
* This routine allows duplicates
|
||||
*
|
||||
* listptr the list
|
||||
* name the name under which to insert
|
||||
* obj the object to insert
|
||||
*/
|
||||
void wmlInsertInKeyList (listptr, name, obj)
|
||||
DynamicHandleListDefPtr listptr;
|
||||
char *name;
|
||||
ObjectPtr obj;
|
||||
|
||||
{
|
||||
int ndx; /* current index in list */
|
||||
int londx; /* low index */
|
||||
int hindx; /* high index */
|
||||
int midndx; /* midpoint index */
|
||||
int newndx; /* new entry index */
|
||||
int cmpres; /* strcmp result */
|
||||
|
||||
/*
|
||||
* Guarantee enough space in the list
|
||||
*/
|
||||
wmlResizeHList (listptr, listptr->cnt+1);
|
||||
|
||||
/*
|
||||
* Binary search and insert
|
||||
*/
|
||||
if ( listptr->cnt == 0 )
|
||||
{
|
||||
listptr->hvec[0].objname = wmlAllocateString (name);
|
||||
listptr->hvec[0].objptr = obj;
|
||||
listptr->cnt += 1;
|
||||
return;
|
||||
}
|
||||
for ( londx=0,hindx=listptr->cnt-1 ; hindx>=londx ; )
|
||||
{
|
||||
midndx = (londx+hindx) / 2;
|
||||
cmpres = strcmp (name, listptr->hvec[midndx].objname);
|
||||
if ( londx == hindx ) break;
|
||||
if ( cmpres < 0 )
|
||||
hindx = midndx - 1;
|
||||
if ( cmpres >= 0 )
|
||||
londx = midndx + 1;
|
||||
}
|
||||
/*
|
||||
* The new entry will go either at midndx or after midndx. Move down
|
||||
* the vector appropriately.
|
||||
*/
|
||||
if ( cmpres < 0 )
|
||||
newndx = midndx;
|
||||
else
|
||||
newndx = midndx + 1;
|
||||
for ( ndx=listptr->cnt-1 ; ndx>=newndx ; ndx-- )
|
||||
{
|
||||
listptr->hvec[ndx+1].objname = listptr->hvec[ndx].objname;
|
||||
listptr->hvec[ndx+1].objptr = listptr->hvec[ndx].objptr;
|
||||
}
|
||||
listptr->hvec[newndx].objname = wmlAllocateString (name);
|
||||
listptr->hvec[newndx].objptr = obj;
|
||||
listptr->cnt += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Indicate if a resource is in a resource reference list by returning its
|
||||
* reference pointer.
|
||||
*/
|
||||
|
||||
WmlClassResDefPtr wmlResolveResIsMember (resobj, resref)
|
||||
WmlResourceDefPtr resobj;
|
||||
WmlClassResDefPtr resref;
|
||||
|
||||
{
|
||||
|
||||
while ( resref != NULL )
|
||||
{
|
||||
if ( resref->act_resource == resobj ) return resref;
|
||||
resref = resref->next;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Indicate if a child is in a child reference list by returning its
|
||||
* reference pointer.
|
||||
*/
|
||||
|
||||
WmlClassChildDefPtr wmlResolveChildIsMember (childobj, childref)
|
||||
WmlChildDefPtr childobj;
|
||||
WmlClassChildDefPtr childref;
|
||||
|
||||
{
|
||||
|
||||
while ( childref != NULL )
|
||||
{
|
||||
if ( childref->act_child == childobj ) return childref;
|
||||
childref = childref->next;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user