Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
12
cde/programs/dthelp/parser/pass2/Imakefile
Normal file
12
cde/programs/dthelp/parser/pass2/Imakefile
Normal file
@@ -0,0 +1,12 @@
|
||||
XCOMM $XConsortium: Imakefile /main/3 1995/11/08 10:40:52 rswiston $
|
||||
#define IHaveSubdirs
|
||||
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)'
|
||||
|
||||
#if !UseCCMakeDepend
|
||||
MDEP_DIR = makedepend
|
||||
#endif
|
||||
|
||||
SUBDIRS = util build eltdef htag2 parser
|
||||
|
||||
MakeSubdirs($(SUBDIRS))
|
||||
DependSubdirs($(SUBDIRS))
|
||||
75
cde/programs/dthelp/parser/pass2/build/Imakefile
Normal file
75
cde/programs/dthelp/parser/pass2/build/Imakefile
Normal file
@@ -0,0 +1,75 @@
|
||||
XCOMM $XConsortium: Imakefile /main/3 1995/11/08 10:41:11 rswiston $
|
||||
/* build Imakefile */
|
||||
|
||||
HTAG2 = ..
|
||||
HTAG2SRC = $(HTAG2)/htag2
|
||||
SDLPARSERSRC = $(HTAG2)/parser
|
||||
SDLELTDEFSRC = $(HTAG2)/eltdef
|
||||
SDLDTDFILE = $(HTAG2SRC)/sdl.dtd
|
||||
SDLUTILSRC = $(HTAG2)/util
|
||||
SDLBUILDSRC = $(HTAG2)/build
|
||||
SDLUTILLIB = $(HTAG2)/util/libutil.a
|
||||
|
||||
INCLUDES = -I. -I$(SDLUTILSRC)
|
||||
|
||||
SRCS = \
|
||||
build.c buildutl.c eltree.c except.c fsa.c out.c param.c \
|
||||
scan.c sref.c tree.c
|
||||
|
||||
OBJS = \
|
||||
build.o buildutl.o eltree.o except.o fsa.o out.o param.o \
|
||||
scan.o sref.o tree.o
|
||||
|
||||
CHPRODS = context.h delim.h
|
||||
CCPRODS = case.c
|
||||
|
||||
BHPRODS = dtd.h entity.h arc.h
|
||||
BCPRODS =
|
||||
|
||||
CTRASH = error delim.dat
|
||||
BTRASH = error template
|
||||
|
||||
CPRODS = $(CHPRODS) $(CCPRODS)
|
||||
BPRODS = $(BHPRODS) $(BCPRODS)
|
||||
TRASH = error delim.dat template
|
||||
|
||||
PRODUCTS = $(CPRODS) $(BPRODS)
|
||||
|
||||
LOCAL_LIBRARIES = $(SDLUTILLIB)
|
||||
|
||||
/* Don't use shared libs for hp */
|
||||
#ifdef HPArchitecture
|
||||
#if OSMajorVersion > 7
|
||||
EXTRA_LOAD_FLAGS = -Wl,-a archive
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SunArchitecture
|
||||
.NO_PARALLEL:
|
||||
#endif
|
||||
|
||||
all:: $(PRODUCTS)
|
||||
|
||||
$(BPRODS): build $(SDLDTDFILE)
|
||||
$(RM) $(BPRODS) $(BTRASH)
|
||||
./build < $(SDLDTDFILE)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalProgramTarget(build,$(OBJS),delim.h $(LOCAL_LIBRARIES),$(LOCAL_LIBRARIES),)
|
||||
|
||||
$(CPRODS): $(SDLUTILSRC)/context $(HTAG2SRC)/delim.bld context.dat
|
||||
$(RM) $(CPRODS) $(CTRASH)
|
||||
/* get application-specific delim.dat */
|
||||
$(CP) $(HTAG2SRC)/delim.bld delim.dat
|
||||
$(SDLUTILSRC)/context sparse
|
||||
|
||||
$(SDLUTILSRC)/context:
|
||||
cd $(SDLUTILSRC); make context
|
||||
|
||||
clean::
|
||||
$(RM) $(PRODUCTS) $(TRASH)
|
||||
|
||||
depend:: $(SRCS)
|
||||
DependTarget()
|
||||
|
||||
includes:: $(PRODUCTS)
|
||||
52
cde/programs/dthelp/parser/pass2/build/build.c
Normal file
52
cde/programs/dthelp/parser/pass2/build/build.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/* $XConsortium: build.c /main/3 1995/11/08 10:41:26 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Build.c contains the main procedure for program BUILD */
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "context.h"
|
||||
#define BUILDEF
|
||||
#include "build.h"
|
||||
#include "delim.h"
|
||||
#include "entdef.h"
|
||||
|
||||
/* Main procedure */
|
||||
void main(argc, argv)
|
||||
int argc ;
|
||||
char **argv ;
|
||||
{
|
||||
int m_prevcon ;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strchr(argv[1], 'a')) m_malftrace = TRUE ;
|
||||
if (strchr(argv[1], 'A')) m_malftrace = TRUE ;
|
||||
if (strchr(argv[1], 'a')) m_malftrace = TRUE ;
|
||||
if (strchr(argv[1], 'H')) m_heapchk = TRUE ;
|
||||
if (strchr(argv[1], 'm')) standard = TRUE ;
|
||||
if (strchr(argv[1], 'M')) standard = TRUE ;
|
||||
if (strchr(argv[1], 's')) scantrace = TRUE ;
|
||||
if (strchr(argv[1], 'S')) scantrace = TRUE ;
|
||||
}
|
||||
initialize() ;
|
||||
while (TRUE)
|
||||
{
|
||||
m_token = scan() ;
|
||||
m_prevcon = curcon ;
|
||||
curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
|
||||
if (scantrace)
|
||||
printf(
|
||||
"m_prevcon=%d, m_token=%d, curcon=%d, scanval = %c (%d), line=%d\n",
|
||||
m_prevcon, m_token, curcon, scanval, scanval, m_line) ;
|
||||
#include "case.c"
|
||||
if (m_token == ENDFILE) exit(FALSE) ;
|
||||
}
|
||||
}
|
||||
406
cde/programs/dthelp/parser/pass2/build/build.h
Normal file
406
cde/programs/dthelp/parser/pass2/build/build.h
Normal file
@@ -0,0 +1,406 @@
|
||||
/* $XConsortium: build.h /main/3 1995/11/08 10:41:43 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Build.h is the primary include file for allocation of global variables
|
||||
for program BUILD. */
|
||||
|
||||
|
||||
#if defined(BUILDEF)
|
||||
#define BUILDEXTERN
|
||||
#define BUILDINIT(a) = a
|
||||
#else
|
||||
#define BUILDEXTERN extern
|
||||
#define BUILDINIT(a)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "common.h"
|
||||
|
||||
/* Defined types */
|
||||
typedef struct arc ARC ;
|
||||
typedef struct state STATE ;
|
||||
typedef struct tree TREE ;
|
||||
typedef struct statelist STATELIST ;
|
||||
typedef struct parameter PARAMETER ;
|
||||
typedef struct exception EXCEPTION ;
|
||||
typedef struct ptype PTYPE ;
|
||||
typedef struct eltstruct ELTSTRUCT ;
|
||||
typedef struct lhsstruct LHS ;
|
||||
typedef struct stack STACK ;
|
||||
typedef struct srefstruct SREFSTRUCT ;
|
||||
typedef struct srefdata SREFDATA ;
|
||||
typedef struct mapstruct MAP ;
|
||||
typedef struct andgroup ANDGROUP ;
|
||||
|
||||
/* Each item in a list of states contains value, a pointer to a state;
|
||||
next, a pointer to the next item in the list; and level, which
|
||||
indicates the level of nested subexpressions within the regular expression
|
||||
when the state was added to the FSA. */
|
||||
BUILDEXTERN struct statelist {
|
||||
STATE *value ;
|
||||
STATELIST *next ;
|
||||
int level ;
|
||||
} ;
|
||||
|
||||
struct stack {
|
||||
STACK *oldtop ;
|
||||
STATELIST *starts ;
|
||||
STATELIST *finals ;
|
||||
STATELIST *allfinal ;
|
||||
STATELIST *newfinal ;
|
||||
ARC *starta ;
|
||||
} ;
|
||||
|
||||
BUILDEXTERN STACK bot
|
||||
#if defined(BUILDEF)
|
||||
= {
|
||||
NULL, NULL, NULL, NULL, NULL, NULL
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
BUILDEXTERN STACK *top BUILDINIT(&bot) ;
|
||||
|
||||
BUILDEXTERN int stacklevels BUILDINIT(0) ;
|
||||
|
||||
|
||||
/* Used to report nondeterminism in and groups */
|
||||
#define ANDCONFLICT 1
|
||||
#define DATACONFLICT 2
|
||||
#define ELTCONFLICT 3
|
||||
|
||||
/* Name of an element, and of the first element on the left-hand side of
|
||||
the current rule */
|
||||
#define thisrule lhs->elt->enptr
|
||||
|
||||
/* Set declared entity type */
|
||||
#define SETETYPE(p,t) adddefent(p) ; entity->type = t
|
||||
|
||||
/* Definitions for entities */
|
||||
|
||||
#define EMPTYMAP 1
|
||||
|
||||
#define ERREXIT 1
|
||||
|
||||
/* Prefix for default short reference map and entities */
|
||||
#define M_PREFIX "M-"
|
||||
|
||||
/* State transition network generated by CONTEXT */
|
||||
#define sparse
|
||||
#include "sparse.h"
|
||||
|
||||
/* Function prototypes */
|
||||
#include "proto.h"
|
||||
|
||||
/* Frequently output strings */
|
||||
#define ndif "}\n#endif\n ;\n\n"
|
||||
#define SUBONE else fputs("[1] ;\n\n", dtd) ;
|
||||
|
||||
/* An array used to indicate which characters can appear within
|
||||
element names */
|
||||
#if defined(BUILDEF)
|
||||
#include "chartype.h"
|
||||
#else
|
||||
extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
|
||||
#endif
|
||||
|
||||
/* Current state of the finite-state machine which controls BUILD */
|
||||
BUILDEXTERN int curcon BUILDINIT(RULE) ;
|
||||
BUILDEXTERN int m_token ;
|
||||
BUILDEXTERN M_WCHAR scanval ;
|
||||
|
||||
/* Used to pass names and literals from the scanner */
|
||||
BUILDEXTERN M_WCHAR name[M_NAMELEN + 1] ;
|
||||
BUILDEXTERN M_WCHAR literal[M_LITLEN + 1] ;
|
||||
|
||||
/* Scanner buffer for read-ahead */
|
||||
BUILDEXTERN int toundo BUILDINIT(0) ;
|
||||
BUILDEXTERN int maxundo BUILDINIT(0) ;
|
||||
/* Size of scanner buffer for read-ahead */
|
||||
#define SAVECHAR 50
|
||||
BUILDEXTERN int savechar[SAVECHAR] ;
|
||||
|
||||
/* Whether errors have occurred */
|
||||
BUILDEXTERN LOGICAL errexit BUILDINIT(FALSE) ;
|
||||
|
||||
/* FSA storage */
|
||||
|
||||
/* Each state in an FSA is represented by a flag indicating whether it is
|
||||
a final state, a pointer to a list of transitions from the state,
|
||||
and a flag that indicates whether parsed character data is possible
|
||||
from the state */
|
||||
BUILDEXTERN struct state {
|
||||
LOGICAL final ;
|
||||
LOGICAL datacontent ;
|
||||
LOGICAL frompcdata ;
|
||||
ARC *first ;
|
||||
int count ;
|
||||
STATE *next ;
|
||||
} ;
|
||||
BUILDEXTERN STATE *firststate BUILDINIT(NULL) ;
|
||||
BUILDEXTERN STATE **nextstate BUILDINIT(&firststate) ;
|
||||
BUILDEXTERN STATE *startstate ;
|
||||
|
||||
/* Each arc in an FSA is an element in the arc list emanating from a
|
||||
particular state. Associated fields include label, a pointer to
|
||||
the name of the element labelling the arc (garbage if the label is an
|
||||
and group); optional, a flag indicating whether or not the label is
|
||||
contextually required; minim, a flag indicating whether or not the arc
|
||||
corresponds to an element selected by explicit minimization;
|
||||
and group, a pointer to the list of FSA's making
|
||||
up the andgroup if the arc's label is an andgroup; to, a pointer to the
|
||||
state entered by the arc; next, a pointer to the next arc
|
||||
in the current arc list; and finally, id, a pointer to the node in the
|
||||
tree representation of the model corresponding to the arc (id is used
|
||||
in the detection of ambiguity to differentiate between arcs with the same
|
||||
label corresponding to one model token and those with the same label
|
||||
corresponding to more than one model token).
|
||||
*/
|
||||
BUILDEXTERN struct arc {
|
||||
ELTSTRUCT *label ;
|
||||
LOGICAL optional ;
|
||||
LOGICAL minim ;
|
||||
ANDGROUP *group ;
|
||||
STATE *to ;
|
||||
ARC *next ;
|
||||
int id ;
|
||||
} ;
|
||||
|
||||
/* Andgroups are elements in a list of the FSA's corresponding to the
|
||||
content submodels in an andgroup. Each list element contains a pointer
|
||||
to the start state of the FSA and a pointer to the next element in the
|
||||
list */
|
||||
BUILDEXTERN struct andgroup{
|
||||
STATE *start ;
|
||||
ANDGROUP *nextptr ;
|
||||
ANDGROUP *next ;
|
||||
int count ;
|
||||
} ;
|
||||
BUILDEXTERN ANDGROUP *firstand BUILDINIT(NULL) ;
|
||||
BUILDEXTERN ANDGROUP **nextand BUILDINIT(&firstand) ;
|
||||
|
||||
/* Tree representation of a rule */
|
||||
/* Each node in the tree representation corresponds to a submodel.
|
||||
Associated with the node is the submodel's connector and occurrence
|
||||
indicator; terminal, a flag indicating whether the submodel in turn
|
||||
has submodels; value, the element of which a terminal submodel consists;
|
||||
pointers first and last to the first and last submodel of the node;
|
||||
and right pointing to the node's next sibling in the tree. */
|
||||
struct tree {
|
||||
int connector, occurrence ;
|
||||
ELTSTRUCT *value ;
|
||||
LOGICAL terminal ;
|
||||
LOGICAL minim ;
|
||||
TREE *first, *right, *parent ;
|
||||
int eltid ;
|
||||
} ;
|
||||
BUILDEXTERN TREE *ruletree BUILDINIT(NULL) ;
|
||||
BUILDEXTERN TREE *curtree ;
|
||||
|
||||
/* Various counters */
|
||||
BUILDEXTERN int eltsinrule BUILDINIT(0) ;
|
||||
BUILDEXTERN int stateused BUILDINIT(0) ;
|
||||
BUILDEXTERN int andused BUILDINIT(0) ;
|
||||
|
||||
/* Element names on the left-hand side of the current rule */
|
||||
struct lhsstruct {
|
||||
ELTSTRUCT *elt ;
|
||||
LHS *next ;
|
||||
} ;
|
||||
BUILDEXTERN LHS *lhs BUILDINIT(NULL) ;
|
||||
BUILDEXTERN LHS **nextlhs BUILDINIT(&lhs) ;
|
||||
|
||||
/* Content type (regular expression, ANY, NONE, CDATA, RCDATA) of the
|
||||
current rule. */
|
||||
BUILDEXTERN int contype ;
|
||||
|
||||
/* Indicates whether <PARAM>, <USEMAP>, or <MIN> fields have occurred in
|
||||
current rule */
|
||||
BUILDEXTERN LOGICAL poccur, uoccur, moccur ;
|
||||
|
||||
/* Indicates whether an ID parameter for this rule has occurred */
|
||||
BUILDEXTERN LOGICAL idoccur ;
|
||||
|
||||
/* Short reference map for this rule */
|
||||
BUILDEXTERN int srefp ;
|
||||
BUILDEXTERN LOGICAL useoradd ;
|
||||
|
||||
/* Whether start- and end-tag minimization are permitted for the current
|
||||
rule */
|
||||
BUILDEXTERN LOGICAL smin, emin ;
|
||||
|
||||
/* Suffix for generated entity names */
|
||||
BUILDEXTERN int egensuf ;
|
||||
|
||||
/* Storage for exceptions */
|
||||
BUILDEXTERN int excount BUILDINIT(0) ;
|
||||
struct exception {
|
||||
int element ;
|
||||
EXCEPTION *next ;
|
||||
EXCEPTION *nextptr ;
|
||||
} ;
|
||||
BUILDEXTERN EXCEPTION *firstex BUILDINIT(NULL) ;
|
||||
BUILDEXTERN EXCEPTION **nextex BUILDINIT(&firstex) ;
|
||||
BUILDEXTERN EXCEPTION *exlist ;
|
||||
|
||||
/* Total number of parameters for all elements */
|
||||
BUILDEXTERN int parcount BUILDINIT(0) ;
|
||||
|
||||
/* Primary representation of parameters */
|
||||
struct parameter {
|
||||
M_WCHAR *paramname ;
|
||||
int type ;
|
||||
int kwlist ;
|
||||
PTYPE *ptypep ;
|
||||
int deftype ;
|
||||
int defval ;
|
||||
M_WCHAR *defstring ;
|
||||
/* Next parameter for this element */
|
||||
PARAMETER *next ;
|
||||
/* Link for list of all parameters for all elements */
|
||||
PARAMETER *nextptr ;
|
||||
} ;
|
||||
BUILDEXTERN PARAMETER *newpar BUILDINIT(NULL) ;
|
||||
BUILDEXTERN PARAMETER *plist BUILDINIT(NULL) ;
|
||||
BUILDEXTERN PARAMETER *firstpar BUILDINIT(NULL) ;
|
||||
BUILDEXTERN PARAMETER **nextpar BUILDINIT(&firstpar) ;
|
||||
|
||||
/* Storage for parameter names */
|
||||
BUILDEXTERN int pnamelen BUILDINIT(0) ;
|
||||
|
||||
/* Storage for parameter values that are named keywords */
|
||||
BUILDEXTERN int ptypelen BUILDINIT(0) ;
|
||||
struct ptype {
|
||||
M_WCHAR *keyword ;
|
||||
int next ;
|
||||
PTYPE *nextptr ;
|
||||
} ;
|
||||
BUILDEXTERN PTYPE *firstptype BUILDINIT(NULL) ;
|
||||
BUILDEXTERN PTYPE *thisptype ;
|
||||
BUILDEXTERN PTYPE **nextptype BUILDINIT(&firstptype) ;
|
||||
BUILDEXTERN int kwlen BUILDINIT(0) ;
|
||||
|
||||
/* Storage for parameter default values */
|
||||
BUILDEXTERN int deflen BUILDINIT(0) ;
|
||||
|
||||
/* Characters needed for element names */
|
||||
BUILDEXTERN int enamelen BUILDINIT(0) ;
|
||||
|
||||
/* Description of an element: */
|
||||
struct eltstruct {
|
||||
/* Pointer to element name */
|
||||
M_WCHAR *enptr ;
|
||||
/* Start state of element's content model's FSA */
|
||||
STATE *model ;
|
||||
/* Type of element's content (Regular expression, ANY, RCDATA, etc) */
|
||||
int content ;
|
||||
/* Pointer to element's inclusion list */
|
||||
int inptr ;
|
||||
/* Pointer to element's exclusion list */
|
||||
int exptr ;
|
||||
/* Pointer to element's parameter list */
|
||||
PARAMETER *parptr ;
|
||||
/* Index in output of first item in element's parameter list */
|
||||
int parindex ;
|
||||
/* Number of element's parameters */
|
||||
int paramcount ;
|
||||
/* Whether start- and end-tag minimization are permitted */
|
||||
LOGICAL stmin, etmin ;
|
||||
/* Pointer to short reference map, if any */
|
||||
int srefptr ;
|
||||
/* TRUE for USEMAP, FALSE for ADDMAP */
|
||||
LOGICAL useoradd ;
|
||||
|
||||
ELTSTRUCT *next ;
|
||||
int eltno ;
|
||||
} ;
|
||||
BUILDEXTERN ELTSTRUCT *firstelt BUILDINIT(NULL) ;
|
||||
BUILDEXTERN ELTSTRUCT **nextelt BUILDINIT(&firstelt) ;
|
||||
|
||||
/* Most number of parameters had by a single element */
|
||||
BUILDEXTERN int maxpar BUILDINIT(0) ;
|
||||
/* Number of parameters current element has */
|
||||
BUILDEXTERN int pcount ;
|
||||
|
||||
BUILDEXTERN FILE *dtd ;
|
||||
BUILDEXTERN FILE *m_errfile ;
|
||||
|
||||
/* Line number in input file */
|
||||
BUILDEXTERN int m_line BUILDINIT(1) ;
|
||||
|
||||
/* Options */
|
||||
/* Scan trace */
|
||||
BUILDEXTERN LOGICAL scantrace BUILDINIT(FALSE) ;
|
||||
/* Trace calls to malloc/free */
|
||||
BUILDEXTERN LOGICAL m_malftrace BUILDINIT(FALSE) ;
|
||||
/* Test validity of heap in calls to malloc/free */
|
||||
BUILDEXTERN LOGICAL m_heapchk BUILDINIT(FALSE) ;
|
||||
/* Flag set if strictly conforming to ISO 8879 */
|
||||
BUILDEXTERN LOGICAL standard BUILDINIT(FALSE) ;
|
||||
|
||||
/* File pointer used by utilities in ..\util\scanutil for input file */
|
||||
BUILDEXTERN FILE *ifile ;
|
||||
|
||||
/* Element names are stored in a trie. */
|
||||
BUILDEXTERN M_TRIE eltree ;
|
||||
|
||||
/* Count of elements */
|
||||
BUILDEXTERN int ecount BUILDINIT(0) ;
|
||||
|
||||
/* Storage for short reference map names and definitions */
|
||||
BUILDEXTERN M_TRIE maptree ;
|
||||
BUILDEXTERN M_TRIE sreftree ;
|
||||
BUILDEXTERN int mapcnt BUILDINIT(0) ;
|
||||
BUILDEXTERN int curmap ;
|
||||
struct srefstruct {
|
||||
int srefcnt ;
|
||||
SREFDATA *data ;
|
||||
SREFSTRUCT *next ;
|
||||
} ;
|
||||
BUILDEXTERN SREFSTRUCT *firstsref BUILDINIT(NULL) ;
|
||||
BUILDEXTERN SREFSTRUCT **nextsref BUILDINIT(&firstsref) ;
|
||||
struct srefdata {
|
||||
int map ;
|
||||
int entidx ;
|
||||
SREFDATA *next ;
|
||||
} ;
|
||||
BUILDEXTERN SREFDATA *thissref ;
|
||||
BUILDEXTERN int sreflen BUILDINIT(0) ;
|
||||
BUILDEXTERN M_WCHAR mapname[M_NAMELEN + 1] ;
|
||||
BUILDEXTERN int maxsr ;
|
||||
BUILDEXTERN int maxseq ;
|
||||
struct mapstruct {
|
||||
int map ;
|
||||
M_WCHAR *mapname ;
|
||||
LOGICAL defined ;
|
||||
MAP *nextptr ;
|
||||
} ;
|
||||
BUILDEXTERN MAP *firstmap BUILDINIT(NULL) ;
|
||||
BUILDEXTERN MAP **nextmap BUILDINIT(&firstmap) ;
|
||||
|
||||
|
||||
/* Storage for entities */
|
||||
BUILDEXTERN M_TRIE m_enttrie[1] ;
|
||||
BUILDEXTERN M_ENTITY *entity ;
|
||||
BUILDEXTERN M_ENTITY *lastent BUILDINIT(NULL) ;
|
||||
BUILDEXTERN M_ENTITY *firstent BUILDINIT(NULL) ;
|
||||
BUILDEXTERN M_WCHAR entcontent[M_LITLEN + 1] ;
|
||||
BUILDEXTERN int entclen ;
|
||||
BUILDEXTERN int m_entcnt BUILDINIT(0) ;
|
||||
BUILDEXTERN FILE *entfile ;
|
||||
|
||||
BUILDEXTERN LOGICAL entrule BUILDINIT(FALSE) ;
|
||||
|
||||
BUILDEXTERN M_WCHAR genname[M_NAMELEN + sizeof(M_PREFIX)] ;
|
||||
|
||||
M_WCHAR *MakeWideCharString(
|
||||
#if defined(M_PROTO)
|
||||
const char *from
|
||||
#endif
|
||||
);
|
||||
148
cde/programs/dthelp/parser/pass2/build/buildutl.c
Normal file
148
cde/programs/dthelp/parser/pass2/build/buildutl.c
Normal file
@@ -0,0 +1,148 @@
|
||||
/* $XConsortium: buildutl.c /main/3 1995/11/08 10:41:58 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Buildult.c contains the main supporting utilities for program BUILD */
|
||||
|
||||
#include <malloc.h>
|
||||
#include "context.h"
|
||||
#include "build.h"
|
||||
#include "delim.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
/* Verify that <PARAM>, <MIN> or <USEMAP> has not previously occurred in
|
||||
this rule */
|
||||
void found(flag, delim)
|
||||
LOGICAL *flag;
|
||||
char *delim;
|
||||
{
|
||||
M_WCHAR wcbuff[129];
|
||||
size_t length;
|
||||
|
||||
wcbuff[128] = 0;
|
||||
length = mbstowcs(wcbuff,delim,128);
|
||||
if (length < 0)
|
||||
{
|
||||
m_error("An invalid multibyte character was seen");
|
||||
wcbuff[0] = 0;
|
||||
}
|
||||
|
||||
if (*flag)
|
||||
{
|
||||
m_err1("A rule can contain only one %s clause", wcbuff) ;
|
||||
return ;
|
||||
}
|
||||
*flag = TRUE ;
|
||||
}
|
||||
|
||||
/* Program initialization */
|
||||
void initialize(M_NOPAR)
|
||||
{
|
||||
char **mb_delims;
|
||||
M_WCHAR **wc_delims;
|
||||
|
||||
ifile = stdin ;
|
||||
m_openchk(&m_errfile, "error", "w") ;
|
||||
|
||||
fprintf(stderr, "MARKUP System - BUILD %s\n", M_VERSION) ;
|
||||
fprintf(stderr, "Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.\n") ;
|
||||
if (! standard)
|
||||
warning("Warning: optional enhancements of SGML enabled.") ;
|
||||
|
||||
mb_delims = mb_dlmptr;
|
||||
wc_delims = m_dlmptr;
|
||||
|
||||
while (*mb_delims)
|
||||
{
|
||||
*wc_delims++ = MakeWideCharString(*mb_delims);
|
||||
mb_delims++;
|
||||
}
|
||||
*wc_delims = 0;
|
||||
|
||||
ruleinit() ;
|
||||
}
|
||||
|
||||
|
||||
/* Initialization before starting a new rule */
|
||||
void ruleinit(M_NOPAR)
|
||||
{
|
||||
/* Reinitialize for next rule */
|
||||
lhs = NULL ;
|
||||
nextlhs = &lhs ;
|
||||
eltsinrule = 0 ;
|
||||
plist = NULL ;
|
||||
pcount = 0 ;
|
||||
dellist(&bot.finals) ;
|
||||
dellist(&bot.allfinal) ;
|
||||
dellist(&bot.newfinal) ;
|
||||
poccur = uoccur = moccur = FALSE ;
|
||||
smin = emin = FALSE ;
|
||||
srefp = 0 ;
|
||||
useoradd = TRUE ;
|
||||
egensuf = 1 ;
|
||||
idoccur = FALSE ;
|
||||
}
|
||||
|
||||
/* Rule end processing */
|
||||
void rulend(M_NOPAR)
|
||||
{
|
||||
STATE *fsa ;
|
||||
LOGICAL canbenull ;
|
||||
LHS *lhsp ;
|
||||
LHS *discard ;
|
||||
int inptr ;
|
||||
int exptr ;
|
||||
|
||||
if (contype == GRPO) fsa = startfsa(ruletree, &canbenull) ;
|
||||
if (pcount > maxpar) maxpar = pcount ;
|
||||
inptr = lhs->elt->inptr ;
|
||||
exptr = lhs->elt->exptr ;
|
||||
for (lhsp = lhs ; lhsp ; ) {
|
||||
lhsp->elt->model = contype == GRPO ? fsa : (STATE *) M_NULLVAL ;
|
||||
lhsp->elt->content = contype ;
|
||||
lhsp->elt->inptr = inptr ;
|
||||
lhsp->elt->exptr = exptr ;
|
||||
if (plist) {
|
||||
if (lhsp->elt->parptr)
|
||||
warning1("Redefining parameter list for element %s",
|
||||
lhsp->elt->enptr) ;
|
||||
lhsp->elt->parptr = plist ;
|
||||
lhsp->elt->paramcount = pcount ;
|
||||
lhsp->elt->parindex = parcount - pcount + 1 ;
|
||||
}
|
||||
lhsp->elt->stmin = smin ;
|
||||
lhsp->elt->etmin = emin ;
|
||||
lhsp->elt->srefptr = srefp ;
|
||||
lhsp->elt->useoradd = useoradd ;
|
||||
discard = lhsp ;
|
||||
lhsp = lhsp->next ;
|
||||
m_free((M_POINTER) discard, "lhs") ;
|
||||
}
|
||||
if (ruletree) freetree(ruletree) ;
|
||||
ruletree = NULL ;
|
||||
ruleinit() ;
|
||||
}
|
||||
|
||||
/* Skip rest of statement after an error */
|
||||
void skiptoend(M_NOPAR)
|
||||
{
|
||||
int i ;
|
||||
static errlev = 0 ;
|
||||
|
||||
if (! errlev++) {
|
||||
curcon = ERROR ;
|
||||
for (i = scan() ; ; i = scan())
|
||||
if ((i == REND && ! entrule) ||
|
||||
(i == TAGC && entrule) ||
|
||||
i == ENDFILE) break ;
|
||||
curcon = RULE ;
|
||||
entrule = FALSE ;
|
||||
}
|
||||
errlev-- ;
|
||||
ruleinit() ;
|
||||
}
|
||||
|
||||
819
cde/programs/dthelp/parser/pass2/build/context.dat
Normal file
819
cde/programs/dthelp/parser/pass2/build/context.dat
Normal file
@@ -0,0 +1,819 @@
|
||||
comment
|
||||
comcon:comcon {
|
||||
/* $XConsortium: context.dat /main/3 1995/07/17 19:50:00 lehors $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
|
||||
Context.dat defines the state transitions for program BUILD.
|
||||
*/
|
||||
}
|
||||
;
|
||||
|
||||
produces
|
||||
postel:content
|
||||
postsref:entity
|
||||
post2sref:entity2
|
||||
;
|
||||
|
||||
except
|
||||
lastm:excon
|
||||
postc:excon
|
||||
;
|
||||
|
||||
paropen
|
||||
rule:firstparname
|
||||
;
|
||||
|
||||
param
|
||||
sref:pcon,
|
||||
postc:pcon,
|
||||
skipex:pcon,
|
||||
excon:pcon,
|
||||
lastm:pcon,
|
||||
mcon:pcon,
|
||||
postuse:pcon,
|
||||
typedent:pcon {found(&poccur, param) ;}
|
||||
|
||||
postsref:pcon {
|
||||
adddefent(thisrule);
|
||||
found(&poccur, param);
|
||||
}
|
||||
;
|
||||
|
||||
shortref
|
||||
rule:scon
|
||||
;
|
||||
|
||||
usemap
|
||||
pcon:ucon,
|
||||
postc:ucon,
|
||||
skipex:ucon,
|
||||
excon:ucon,
|
||||
lastm:ucon,
|
||||
mcon:ucon,
|
||||
default:ucon,
|
||||
iddefault:ucon,
|
||||
postdef:ucon,
|
||||
curdef:ucon {found(&uoccur, "<USEMAP> or <ADDMAP>") ;}
|
||||
;
|
||||
|
||||
addmap
|
||||
pcon:ucon,
|
||||
postc:ucon,
|
||||
skipex:ucon,
|
||||
excon:ucon,
|
||||
lastm:ucon,
|
||||
mcon:ucon,
|
||||
default:ucon,
|
||||
iddefault:ucon,
|
||||
postdef:ucon,
|
||||
curdef:ucon {
|
||||
if (standard)
|
||||
{
|
||||
M_WCHAR *w_addmap, *w_tagc;
|
||||
|
||||
w_addmap = MakeWideCharString(addmap);
|
||||
w_tagc = MakeWideCharString(tagc);
|
||||
m_err2("%s%s not defined in the SGML standard",w_addmap,w_tagc);
|
||||
m_free(w_addmap,"wide character string");
|
||||
m_free(w_tagc,"wide character string");
|
||||
}
|
||||
else {
|
||||
useoradd = FALSE;
|
||||
found(&uoccur, "<USEMAP> or <ADDMAP>");
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
empty
|
||||
ucon:postucon {srefp = EMPTYMAP ;}
|
||||
;
|
||||
|
||||
entstart
|
||||
rule:entdec {entrule = TRUE ;}
|
||||
;
|
||||
|
||||
tagc
|
||||
postucon:skipex
|
||||
|
||||
ucon:sref {
|
||||
defmapname();
|
||||
if (addmapname(genname, TRUE)) srefp = curmap + 1;
|
||||
else m_err1("Default map name %s already in use", genname) ;
|
||||
}
|
||||
|
||||
sconet:s2ref
|
||||
parname:p2con
|
||||
error:error
|
||||
|
||||
entval:rule,
|
||||
typedec:rule,
|
||||
postent:rule {entrule = FALSE ;}
|
||||
;
|
||||
|
||||
ero
|
||||
entity:entname
|
||||
entity2:ent2name
|
||||
;
|
||||
|
||||
entsystem
|
||||
entity:typedent {SETETYPE(thisrule, M_SYSTEM) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_SYSTEM) ;}
|
||||
entval:typedec {entity->type = M_SYSTEM ;}
|
||||
;
|
||||
|
||||
entst
|
||||
entity:typedent {SETETYPE(thisrule, M_STARTTAG) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_STARTTAG) ;}
|
||||
entval:typedec {entity->type = M_STARTTAG ;}
|
||||
mcon:mcon {smin = TRUE ;}
|
||||
;
|
||||
|
||||
entet
|
||||
entity:typedent {SETETYPE(thisrule, M_ENDTAG) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_ENDTAG) ;}
|
||||
entval:typedec {entity->type = M_ENDTAG ;}
|
||||
mcon:mcon {emin = TRUE ;}
|
||||
;
|
||||
|
||||
entmd
|
||||
entity:typedent {SETETYPE(thisrule, M_MD) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_MD) ;}
|
||||
entval:typedec {entity->type = M_MD ;}
|
||||
;
|
||||
|
||||
entpi
|
||||
entity:typedent {SETETYPE(thisrule, M_PI) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_PI) ;}
|
||||
entval:typedec {entity->type = M_PI ;}
|
||||
;
|
||||
|
||||
entsdata
|
||||
entity:typedent {SETETYPE(thisrule, M_SDATA) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_SDATA) ;}
|
||||
entval:typedec {entity->type = M_SDATA ;}
|
||||
;
|
||||
|
||||
min
|
||||
pcon:mcon,
|
||||
sref:mcon,
|
||||
postc:mcon,
|
||||
skipex:mcon,
|
||||
excon:mcon,
|
||||
lastm:mcon,
|
||||
default:mcon,
|
||||
iddefault:mcon,
|
||||
postdef:mcon,
|
||||
curdef:mcon,
|
||||
postuse:mcon,
|
||||
typedent:mcon {found(&moccur, min) ;}
|
||||
|
||||
postsref:mcon {
|
||||
adddefent(thisrule);
|
||||
found(&moccur, min);
|
||||
}
|
||||
;
|
||||
|
||||
grpo
|
||||
rule:ngname
|
||||
content:model {
|
||||
contype = m_token;
|
||||
ruletree = curtree = gettreenode();
|
||||
}
|
||||
model:model {
|
||||
curtree->first = gettreenode();
|
||||
curtree->first->parent = curtree;
|
||||
curtree = curtree->first;
|
||||
}
|
||||
submod:model {
|
||||
curtree->right = gettreenode();
|
||||
curtree->right->parent = curtree->parent;
|
||||
curtree = curtree->right;
|
||||
}
|
||||
openex:exname
|
||||
|
||||
type:ntname,
|
||||
type2:nt2name {
|
||||
newpar->type = m_token;
|
||||
newpar->kwlist = M_NULLVAL;
|
||||
}
|
||||
;
|
||||
|
||||
grpc
|
||||
namegroup:postel
|
||||
|
||||
modcon:occur2,
|
||||
samecon:occur2,
|
||||
occur:occur2,
|
||||
occur2:occur2 {endmodel() ;}
|
||||
|
||||
exlist:excon
|
||||
ntgroup:default
|
||||
nt2group:default2
|
||||
;
|
||||
|
||||
emi
|
||||
model:neednm {
|
||||
if (standard)
|
||||
m_error("Explicit minimization is not provided in IS 8879");
|
||||
else {
|
||||
curtree->first = gettreenode();
|
||||
curtree->first->parent = curtree;
|
||||
curtree = curtree->first;
|
||||
curtree->terminal = TRUE;
|
||||
curtree->minim = TRUE;
|
||||
}
|
||||
}
|
||||
submod:neednm2 {
|
||||
if (standard)
|
||||
m_error("Explicit minimization is not provided in IS 8879");
|
||||
else {
|
||||
curtree->right = gettreenode();
|
||||
curtree->right->parent = curtree->parent;
|
||||
curtree = curtree->right;
|
||||
curtree->terminal = TRUE;
|
||||
curtree->minim = TRUE;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
incl
|
||||
excon:openex {
|
||||
lhs->elt->inptr = excount + 1;
|
||||
exlist = NULL;
|
||||
}
|
||||
;
|
||||
|
||||
excl
|
||||
excon:openex {
|
||||
lhs->elt->exptr = excount + 1;
|
||||
exlist = NULL;
|
||||
}
|
||||
;
|
||||
|
||||
psep
|
||||
default:pcon
|
||||
default2:p2con
|
||||
iddefault:pcon
|
||||
id2default:p2con
|
||||
postdef:pcon
|
||||
post2def:p2con
|
||||
curdef:pcon
|
||||
cur2def:p2con
|
||||
postuse:sref
|
||||
post2use:s2ref
|
||||
typedent:sref
|
||||
typed2ent:s2ref
|
||||
postsref:sref {adddefent(thisrule) ;}
|
||||
post2sref:s2ref {adddefent(mapname) ;}
|
||||
;
|
||||
|
||||
rend
|
||||
rule:rule
|
||||
|
||||
lastm:rule,
|
||||
skipex:rule,
|
||||
postc:rule,
|
||||
excon:rule,
|
||||
default:rule,
|
||||
iddefault:rule,
|
||||
postdef:rule,
|
||||
curdef:rule,
|
||||
error:rule,
|
||||
mcon:rule,
|
||||
postuse:rule,
|
||||
pcon:rule,
|
||||
sref:rule,
|
||||
typedent:rule {rulend() ;}
|
||||
|
||||
postsref:rule {
|
||||
adddefent(thisrule);
|
||||
rulend();
|
||||
}
|
||||
|
||||
default2:rule,
|
||||
id2default:rule,
|
||||
post2def:rule,
|
||||
cur2def:rule {prulend() ;}
|
||||
|
||||
post2use:rule,
|
||||
s2ref:rule,
|
||||
typed2ent:rule {ruleinit() ;}
|
||||
|
||||
post2sref:rule {
|
||||
adddefent(mapname);
|
||||
ruleinit();
|
||||
}
|
||||
;
|
||||
|
||||
opt
|
||||
lastm:postc,
|
||||
occur:modcon,
|
||||
occur2:samecon {curtree->occurrence = m_token ;}
|
||||
;
|
||||
|
||||
plus
|
||||
lastm:postc,
|
||||
occur:modcon,
|
||||
occur2:samecon {curtree->occurrence = m_token ;}
|
||||
;
|
||||
|
||||
rep
|
||||
lastm:postc,
|
||||
occur:modcon,
|
||||
occur2:samecon {curtree->occurrence = m_token ;}
|
||||
;
|
||||
|
||||
seq
|
||||
modcon:submod,
|
||||
occur:submod {curtree->parent->connector = SEQ ; }
|
||||
|
||||
samecon:submod,
|
||||
occur2:submod {
|
||||
if (m_token != curtree->parent->connector)
|
||||
m_error("All connectors in a submodel should be identical");
|
||||
}
|
||||
;
|
||||
|
||||
or
|
||||
modcon:submod,
|
||||
occur:submod {curtree->parent->connector = OR ; }
|
||||
|
||||
samecon:submod,
|
||||
occur2:submod {
|
||||
if (m_token != curtree->parent->connector)
|
||||
m_error("All connectors in a submodel should be identical");
|
||||
}
|
||||
;
|
||||
|
||||
and
|
||||
modcon:submod,
|
||||
occur:submod {curtree->parent->connector = AND ; }
|
||||
|
||||
samecon:submod,
|
||||
occur2:submod {
|
||||
if (m_token != curtree->parent->connector)
|
||||
m_error("All connectors in a submodel should be identical");
|
||||
}
|
||||
;
|
||||
|
||||
vi
|
||||
curdef:defval,
|
||||
cur2def:def2val {
|
||||
if (standard) {
|
||||
M_WCHAR *w_current;
|
||||
|
||||
w_current = MakeWideCharString(current);
|
||||
warning1("Warning: %s initial values disallowed in ISO 8879",
|
||||
w_current);
|
||||
warning2(" Parameter %s for element %s",
|
||||
newpar->paramname,
|
||||
thisrule);
|
||||
m_free(w_current,"wide character string");
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
entlit
|
||||
entity:litent {
|
||||
adddefent(thisrule);
|
||||
entclen = 0;
|
||||
}
|
||||
entity2:lit2ent {
|
||||
adddefent(mapname);
|
||||
entclen = 0;
|
||||
}
|
||||
|
||||
declitent:postent,
|
||||
litent:postuse,
|
||||
lit2ent:post2use,
|
||||
edeclitent:postent,
|
||||
elitent:postuse,
|
||||
elit2ent:post2use {
|
||||
entcontent[entclen] = M_EOS;
|
||||
entity->content =
|
||||
(M_WCHAR *) m_malloc(entclen + 1, "entity content");
|
||||
w_strcpy(entity->content, entcontent);
|
||||
entity->wheredef = M_DBUILD;
|
||||
}
|
||||
|
||||
entval:declitent,
|
||||
typedec:declitent,
|
||||
typedent:litent,
|
||||
typed2ent:lit2ent {entclen = 0 ;}
|
||||
;
|
||||
|
||||
lit
|
||||
litcon:litcon
|
||||
default:default
|
||||
default2:default2
|
||||
defval:defval
|
||||
def2val:def2val
|
||||
sref:sref
|
||||
s2ref:s2ref
|
||||
;
|
||||
|
||||
entlita
|
||||
entity:litaent {
|
||||
adddefent(thisrule);
|
||||
entclen = 0;
|
||||
}
|
||||
entity2:lita2ent {
|
||||
adddefent(mapname);
|
||||
entclen = 0;
|
||||
}
|
||||
|
||||
declitaent:postent,
|
||||
litaent:postuse,
|
||||
lita2ent:post2use,
|
||||
edclitaent:postent
|
||||
elitaent:postuse
|
||||
elita2ent:post2use {
|
||||
entcontent[entclen] = M_EOS;
|
||||
entity->content =
|
||||
(M_WCHAR *) m_malloc(entclen + 1, "entity content");
|
||||
w_strcpy(entity->content, entcontent);
|
||||
entity->wheredef = M_DBUILD;
|
||||
}
|
||||
|
||||
entval:declitaent,
|
||||
typedec:declitaent,
|
||||
typedent:litaent,
|
||||
typed2ent:lita2ent {entclen = 0 ;}
|
||||
;
|
||||
|
||||
lita
|
||||
litcon:litcon
|
||||
default:default
|
||||
default2:default2
|
||||
defval:defval
|
||||
def2val:def2val
|
||||
sref:sref
|
||||
s2ref:s2ref
|
||||
;
|
||||
|
||||
rnicdata
|
||||
model:modcon {
|
||||
curtree->first = gettreenode();
|
||||
curtree->first->parent = curtree;
|
||||
curtree = curtree->first;
|
||||
curtree->terminal = TRUE;
|
||||
curtree->value = NULL;
|
||||
/* While the SGML Standard treats #CDATA as a single character
|
||||
with the occurrence indicator REP (optional and repeatable), here
|
||||
it is treated as a variable-length string with occurrence
|
||||
indicator OPT (optional). As a result, a single error message
|
||||
is issued when text occurs in an invalid context instead of
|
||||
repeating the diagnostic for each character */
|
||||
curtree->occurrence = OPT;
|
||||
}
|
||||
|
||||
submod:samecon {
|
||||
curtree->right = gettreenode();
|
||||
curtree->right->parent = curtree->parent;
|
||||
curtree = curtree->right;
|
||||
curtree->terminal = TRUE;
|
||||
curtree->value = NULL;
|
||||
curtree->occurrence = OPT;
|
||||
}
|
||||
;
|
||||
|
||||
connor
|
||||
namegroup:ngname
|
||||
exlist:exname
|
||||
ntgroup:ntname
|
||||
nt2group:nt2name
|
||||
;
|
||||
|
||||
connseq
|
||||
namegroup:ngname
|
||||
exlist:exname
|
||||
ntgroup:ntname
|
||||
nt2group:nt2name
|
||||
;
|
||||
|
||||
connand
|
||||
namegroup:ngname
|
||||
exlist:exname
|
||||
ntgroup:ntname
|
||||
nt2group:nt2name
|
||||
;
|
||||
|
||||
current
|
||||
default:curdef,
|
||||
default2:cur2def {
|
||||
newpar->deftype = m_token;
|
||||
newpar->defval = M_NULLVAL;
|
||||
}
|
||||
;
|
||||
|
||||
required
|
||||
iddefault:postdef,
|
||||
default:postdef,
|
||||
id2default:post2def,
|
||||
default2:post2def {newpar->deftype = m_token ;}
|
||||
;
|
||||
|
||||
nulldef
|
||||
default:postdef
|
||||
default2:post2def
|
||||
iddefault:postdef
|
||||
id2default:post2def
|
||||
;
|
||||
|
||||
any
|
||||
content:postc {contype = m_token ;}
|
||||
;
|
||||
|
||||
none
|
||||
content:skipex {contype = m_token ;}
|
||||
;
|
||||
|
||||
rcdata
|
||||
content:skipex {contype = m_token ;}
|
||||
;
|
||||
|
||||
cdata
|
||||
content:skipex {contype = m_token ;}
|
||||
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
|
||||
entity:typedent {SETETYPE(thisrule, M_CDATAENT) ;}
|
||||
entity2:typed2ent {SETETYPE(mapname, M_CDATAENT) ;}
|
||||
entval:typedec {entity->type = M_CDATAENT ;}
|
||||
;
|
||||
|
||||
cro
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litrs
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litrsc
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litre
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litrec
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
littab
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
littabc
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litspace
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litcspace
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
refc
|
||||
charent:charent
|
||||
;
|
||||
|
||||
id
|
||||
type:iddefault,
|
||||
type2:id2default {
|
||||
if (idoccur) m_error("Only one ID parameter allowed in a rule");
|
||||
else {
|
||||
idoccur = TRUE;
|
||||
newpar->type = m_token;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
idref
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
idrefs
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
nametype
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
names
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
nmtoken
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
nmtokens
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
number
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
numbers
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
nutoken
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
nutokens
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
entatt
|
||||
type:default,
|
||||
type2:default2 {newpar->type = m_token ;}
|
||||
;
|
||||
|
||||
|
||||
endfile
|
||||
curdef:rule,
|
||||
default:rule,
|
||||
iddefault:rule,
|
||||
excon:rule,
|
||||
lastm:rule,
|
||||
postc:rule,
|
||||
postdef:rule,
|
||||
skipex:rule,
|
||||
mcon:rule,
|
||||
postuse:rule,
|
||||
typedent:rule {
|
||||
rulend() ;
|
||||
done();
|
||||
}
|
||||
|
||||
postsref:rule {
|
||||
adddefent(thisrule);
|
||||
rulend();
|
||||
done();
|
||||
}
|
||||
|
||||
cur2def:rule,
|
||||
default2:rule,
|
||||
id2default:rule,
|
||||
post2def:rule {prulend() ; done() ;}
|
||||
|
||||
rule:rule,
|
||||
post2use:rule,
|
||||
post2sref:rule,
|
||||
typed2ent:rule {done() ;}
|
||||
;
|
||||
|
||||
name
|
||||
default:postdef,
|
||||
default2:post2def {
|
||||
newpar->deftype = NAME;
|
||||
setdefault(name);
|
||||
}
|
||||
|
||||
defval:postdef,
|
||||
def2val:post2def {setdefault(name) ;}
|
||||
|
||||
exname:exlist {addex() ;}
|
||||
|
||||
model:occur {
|
||||
curtree->first = gettreenode();
|
||||
curtree->first->parent = curtree;
|
||||
curtree = curtree->first;
|
||||
curtree->terminal = TRUE;
|
||||
curtree->value = ntrelt(name);
|
||||
}
|
||||
|
||||
submod:occur2 {
|
||||
curtree->right = gettreenode();
|
||||
curtree->right->parent = curtree->parent;
|
||||
curtree = curtree->right;
|
||||
curtree->terminal = TRUE;
|
||||
curtree->value = ntrelt(name);
|
||||
}
|
||||
|
||||
neednm:occur,
|
||||
neednm2:occur2
|
||||
{curtree->value = ntrelt(name) ;}
|
||||
|
||||
ngname:namegroup {savelhs(FALSE) ;}
|
||||
|
||||
nt2name:nt2group,
|
||||
ntname:ntgroup {addkeyword() ;}
|
||||
|
||||
pcon:type,
|
||||
p2con:type2 {addpar() ;}
|
||||
|
||||
rule:postel {savelhs(FALSE) ;}
|
||||
|
||||
ucon:postucon {
|
||||
addmapname(name, FALSE);
|
||||
srefp = curmap + 1;
|
||||
}
|
||||
|
||||
entname:postuse,
|
||||
ent2name:post2use {addndent(name) ;}
|
||||
|
||||
firstparname:parname,
|
||||
parname:parname {savelhs(TRUE) ;}
|
||||
|
||||
scon:sconet {
|
||||
if (! addmapname(name, TRUE))
|
||||
m_err1("Map name %s already in use", name);
|
||||
else w_strcpy(mapname, name);
|
||||
}
|
||||
|
||||
entdec:entval {
|
||||
if (! addent(name))
|
||||
m_err1("Entity %s already defined", name);
|
||||
}
|
||||
;
|
||||
|
||||
literal
|
||||
default:postdef,
|
||||
default2:post2def {
|
||||
newpar->deftype = NAME;
|
||||
setdefault(literal);
|
||||
}
|
||||
|
||||
defval:postdef,
|
||||
def2val:post2def {setdefault(literal) ;}
|
||||
|
||||
sref:postsref,
|
||||
s2ref:post2sref {addsref(literal) ;}
|
||||
;
|
||||
|
||||
text
|
||||
declitent:declitent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = EDECLITENT;
|
||||
m_error("Entity content too long");
|
||||
}
|
||||
else entcontent[entclen++] = scanval;
|
||||
}
|
||||
declitaent:declitaent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = EDCLITAENT;
|
||||
m_error("Entity content too long");
|
||||
}
|
||||
else entcontent[entclen++] = scanval;
|
||||
}
|
||||
litent:litent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = ELITENT;
|
||||
m_error("Entity content too long");
|
||||
}
|
||||
else entcontent[entclen++] = scanval;
|
||||
}
|
||||
lit2ent:lit2ent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = ELIT2ENT;
|
||||
m_error("Entity content too long");
|
||||
}
|
||||
else entcontent[entclen++] = scanval;
|
||||
}
|
||||
litaent:litaent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = ELITAENT;
|
||||
m_error("Entity content too long");
|
||||
}
|
||||
else entcontent[entclen++] = scanval;
|
||||
}
|
||||
lita2ent:lita2ent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = ELITA2ENT;
|
||||
m_error("Entity content too long");
|
||||
}
|
||||
else entcontent[entclen++] = scanval;
|
||||
}
|
||||
|
||||
edeclitent:edeclitent
|
||||
edclitaent:edclitaent
|
||||
elitent:elitent
|
||||
elit2ent:elit2ent
|
||||
elitaent:elitaent
|
||||
elita2ent:elita2ent
|
||||
;
|
||||
|
||||
45
cde/programs/dthelp/parser/pass2/build/eltree.c
Normal file
45
cde/programs/dthelp/parser/pass2/build/eltree.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/* $XConsortium: eltree.c /main/3 1995/11/08 10:42:15 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Eltree.c contains procedures that manipulate element names */
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "build.h"
|
||||
|
||||
/* Enters an element name into the element name tree */
|
||||
ELTSTRUCT *ntrelt(p)
|
||||
M_WCHAR *p ;
|
||||
{
|
||||
ELTSTRUCT *new ;
|
||||
ELTSTRUCT *old ;
|
||||
int length ;
|
||||
|
||||
new = (ELTSTRUCT *) m_malloc(sizeof(ELTSTRUCT), "element structure") ;
|
||||
if (old = (ELTSTRUCT *) m_ntrtrie(p, &eltree, (M_TRIE *) new)) {
|
||||
m_free((M_POINTER) new, "element structure") ;
|
||||
return(old) ;
|
||||
}
|
||||
*nextelt = new ;
|
||||
nextelt = &new->next ;
|
||||
new->eltno = ++ecount ;
|
||||
length = w_strlen(p) + 1 ;
|
||||
enamelen += length ;
|
||||
new->enptr = (M_WCHAR *) m_malloc(length, "element name") ;
|
||||
w_strcpy(new->enptr, p) ;
|
||||
new->model = M_NULLVAL ;
|
||||
new->content = M_NULLVAL ;
|
||||
new->inptr = new->exptr = NULL ;
|
||||
new->parptr = NULL ;
|
||||
new->parindex = M_NULLVAL ;
|
||||
new->paramcount = M_NULLVAL ;
|
||||
new->stmin = new->etmin = FALSE ;
|
||||
new->srefptr = M_NULLVAL ;
|
||||
new->useoradd = TRUE ;
|
||||
new->next = NULL ;
|
||||
return(new) ;
|
||||
}
|
||||
23
cde/programs/dthelp/parser/pass2/build/except.c
Normal file
23
cde/programs/dthelp/parser/pass2/build/except.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $XConsortium: except.c /main/3 1995/11/08 10:42:31 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Except.c contains procedures related to exceptions for program BUILD */
|
||||
|
||||
#include "build.h"
|
||||
|
||||
/* Add an exception (inclusion or exclusion) for the current element */
|
||||
void addex(M_NOPAR)
|
||||
{
|
||||
excount++ ;
|
||||
*nextex = (EXCEPTION *) m_malloc(sizeof(EXCEPTION), "exception") ;
|
||||
if (exlist) exlist->next = *nextex ;
|
||||
exlist = *nextex ;
|
||||
(*nextex)->next = NULL ;
|
||||
(*nextex)->nextptr = NULL ;
|
||||
(*nextex)->element = ntrelt(name)->eltno ;
|
||||
nextex = &(*nextex)->nextptr ;
|
||||
}
|
||||
734
cde/programs/dthelp/parser/pass2/build/fsa.c
Normal file
734
cde/programs/dthelp/parser/pass2/build/fsa.c
Normal file
@@ -0,0 +1,734 @@
|
||||
/* $XConsortium: fsa.c /main/3 1995/11/08 10:42:48 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Fsa.c contains the procedures used by program BUILD to convert a tree
|
||||
representation of a content model to an FSA */
|
||||
|
||||
#include <malloc.h>
|
||||
#include "build.h"
|
||||
#include "context.h"
|
||||
#include "delim.h"
|
||||
|
||||
/* Addarc adds an arc from FSA state <from> to state <to> setting other
|
||||
fields as indicated by the other parameters.*/
|
||||
#if defined(M_PROTO)
|
||||
int addarc(STATE *from, STATE *to, ELTSTRUCT *label, ANDGROUP *and, LOGICAL optional, int id, LOGICAL minim, ELTSTRUCT **errelt)
|
||||
#else
|
||||
int addarc(from, to, label, and, optional, id, minim, errelt)
|
||||
STATE *from, *to ;
|
||||
ELTSTRUCT *label ;
|
||||
ANDGROUP *and ;
|
||||
LOGICAL optional ;
|
||||
int id ;
|
||||
LOGICAL minim ;
|
||||
ELTSTRUCT **errelt ;
|
||||
#endif
|
||||
{
|
||||
ARC *parc, *qarc ;
|
||||
int determ ;
|
||||
|
||||
determ = checkdfsa(from, label, and, id, errelt) ;
|
||||
parc = from->first ;
|
||||
qarc = (ARC *) m_malloc(sizeof(ARC), "arc") ;
|
||||
from->first = qarc ;
|
||||
qarc->label = label ;
|
||||
qarc->optional = optional ;
|
||||
qarc->minim = minim ;
|
||||
qarc->group = and ;
|
||||
qarc->to = to ;
|
||||
qarc->next = parc ;
|
||||
qarc->id = id ;
|
||||
return(determ) ;
|
||||
}
|
||||
|
||||
/*checkand is used to verify nondeterminism from start and final states
|
||||
of FSA's generated from and groups*/
|
||||
void checkand(andstart, andptr, start, root, errelt)
|
||||
ANDGROUP *andstart, *andptr ;
|
||||
STATE *start ;
|
||||
TREE *root ;
|
||||
ELTSTRUCT **errelt ;
|
||||
{
|
||||
ARC *parc ;
|
||||
ANDGROUP *pand ;
|
||||
int c ;
|
||||
|
||||
for (parc = start->first ; parc ; parc = parc->next) {
|
||||
if (parc->group) {
|
||||
if (parc->group != andstart)
|
||||
for (pand = parc->group ; pand ; pand = pand->next)
|
||||
checkand(andstart, andptr, pand->start, root, errelt) ;
|
||||
}
|
||||
else if (c = checkdfsa(andptr->start,
|
||||
parc->label,
|
||||
parc->group,
|
||||
parc->id,
|
||||
errelt))
|
||||
nondeterm(root, c, *errelt) ;
|
||||
}
|
||||
}
|
||||
|
||||
/*Checkdfsa is called when adding an arc to an FSA in order to verify that
|
||||
no existing arc from the same state (or from a start state of an and-group
|
||||
FSA labelling an arc from the same state) has the same label. */
|
||||
int checkdfsa(from, label, and, id, errelt)
|
||||
STATE *from ;
|
||||
ELTSTRUCT *label ;
|
||||
ANDGROUP *and ;
|
||||
int id ;
|
||||
ELTSTRUCT **errelt ;
|
||||
{
|
||||
int c ;
|
||||
ARC *parc ;
|
||||
ANDGROUP *group ;
|
||||
|
||||
for (parc = from->first ; parc ; parc = parc->next) {
|
||||
if (parc->group) {
|
||||
if (and == parc->group) return(ANDCONFLICT) ;
|
||||
for (group = parc->group ; group ; group = group->next)
|
||||
if (c = checkdfsa(group->start, label, and, id, errelt))
|
||||
return(c) ;
|
||||
}
|
||||
else if (! and && label == parc->label && parc->id != id) {
|
||||
if (label) {
|
||||
*errelt = label ;
|
||||
return(ELTCONFLICT) ;
|
||||
}
|
||||
return(DATACONFLICT) ;
|
||||
}
|
||||
}
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Check use of repeated models with and groups */
|
||||
int checkrepeat(from, and, errelt)
|
||||
STATE *from ;
|
||||
ANDGROUP *and ;
|
||||
ELTSTRUCT **errelt ;
|
||||
{
|
||||
ARC *parc ;
|
||||
int c ;
|
||||
|
||||
for (; and ; and = and->next)
|
||||
for (parc = and->start->first ; parc ; parc = parc->next) {
|
||||
if (parc->group)
|
||||
if (c = checkrepeat(from, parc->group, errelt)) return(c) ;
|
||||
else ;
|
||||
else
|
||||
if (c = checkdfsa(from,
|
||||
parc->label,
|
||||
M_NULLVAL,
|
||||
parc->id,
|
||||
errelt))
|
||||
return(c) ;
|
||||
else ;
|
||||
}
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Copyintolist copies one list of states into another */
|
||||
void copyintolist(from, to)
|
||||
STATELIST *from, **to ;
|
||||
{
|
||||
STATELIST **new, *old ;
|
||||
|
||||
old = *to ;
|
||||
new = to ;
|
||||
for ( ; from ; from = from->next) {
|
||||
if (notinlist(from, old)) {
|
||||
*new = (STATELIST *) m_malloc(sizeof(STATELIST), "state list") ;
|
||||
(*new)->value = from->value ;
|
||||
(*new)->level = from->level ;
|
||||
new = &(*new)->next ;
|
||||
}
|
||||
}
|
||||
*new = old ;
|
||||
}
|
||||
|
||||
/* Dellist deletes a list of states */
|
||||
void dellist(list)
|
||||
STATELIST **list ;
|
||||
{
|
||||
STATELIST *p, *q ;
|
||||
|
||||
for (p = *list ; p ; ) {
|
||||
q = p ;
|
||||
p = p->next ;
|
||||
m_free(q, "state list") ;
|
||||
}
|
||||
*list = NULL ;
|
||||
}
|
||||
|
||||
/* Delstartarcs deletes the contents of the starta list of arcs from start
|
||||
states of a submodel */
|
||||
void delstartarcs(M_NOPAR)
|
||||
{
|
||||
ARC *arcptr ;
|
||||
ARC *discard ;
|
||||
|
||||
for (arcptr = top->starta ; arcptr ; ) {
|
||||
discard = arcptr ;
|
||||
arcptr = arcptr->next ;
|
||||
m_free(discard, "arc") ;
|
||||
}
|
||||
top->starta = NULL ;
|
||||
}
|
||||
|
||||
/* Getand allocates and initializes a new andgroup structure */
|
||||
ANDGROUP *getand(M_NOPAR)
|
||||
{
|
||||
ANDGROUP *new ;
|
||||
|
||||
new = (ANDGROUP *) m_malloc(sizeof(ANDGROUP), "and group") ;
|
||||
new->nextptr = new->next = NULL ;
|
||||
new->count = ++andused ;
|
||||
*nextand = new ;
|
||||
nextand = &new->nextptr ;
|
||||
return(new) ;
|
||||
}
|
||||
|
||||
/* Getstate obtains an FSA state */
|
||||
STATE *getstate(M_NOPAR)
|
||||
{
|
||||
STATE *new ;
|
||||
|
||||
new = (STATE *) m_malloc(sizeof(STATE), "state") ;
|
||||
new->final = FALSE ;
|
||||
new->datacontent = FALSE ;
|
||||
new->frompcdata = FALSE ;
|
||||
new->first = NULL ;
|
||||
new->count = ++stateused ;
|
||||
new->next = NULL ;
|
||||
*nextstate = new ;
|
||||
nextstate = &new->next ;
|
||||
return(new) ;
|
||||
}
|
||||
|
||||
/* Makeand processes a submodel whose connector is & */
|
||||
void makeand(canbenull, root, optional)
|
||||
LOGICAL *canbenull ;
|
||||
TREE *root ;
|
||||
int optional ;
|
||||
{
|
||||
TREE *child ;
|
||||
STATELIST *start, *final ;
|
||||
LOGICAL groupbenull ;
|
||||
ANDGROUP *andptr, *saveand, *otherand ;
|
||||
STATELIST *index ;
|
||||
ELTSTRUCT *errelt ;
|
||||
|
||||
for (child = root->first ; child ; child = child->right) {
|
||||
if (child == root->first) {
|
||||
*canbenull = TRUE ;
|
||||
andptr = getand() ;
|
||||
saveand = andptr ;
|
||||
push() ;
|
||||
copyintolist(top->oldtop->allfinal, &top->allfinal) ;
|
||||
}
|
||||
else {
|
||||
andptr->next = getand() ;
|
||||
andptr = andptr->next ;
|
||||
}
|
||||
andptr->start = startfsa(child, &groupbenull) ;
|
||||
if (andptr->start->datacontent)
|
||||
for (index = top->oldtop->starts ; index ; index = index->next)
|
||||
index->value->datacontent = TRUE ;
|
||||
if (! groupbenull) *canbenull = FALSE ;
|
||||
/* Check for ambiguity between start state of branch just completed
|
||||
and start state of the and-group (i.e., parent of branch just
|
||||
completed) */
|
||||
for (start = top->oldtop->starts ; start ; start = start->next)
|
||||
checkand(saveand, andptr, start->value, root, &errelt) ;
|
||||
/* Check for ambiguity between start state of branch just completed
|
||||
and final states of previous branches */
|
||||
for (final = top->allfinal ; final ; final = final->next)
|
||||
checkand(saveand, andptr, final->value, root, &errelt) ;
|
||||
copyintolist(top->finals, &top->allfinal) ;
|
||||
copyintolist(top->newfinal, &top->allfinal) ;
|
||||
copyintolist(top->finals, &top->oldtop->newfinal) ;
|
||||
copyintolist(top->newfinal, &top->oldtop->newfinal) ;
|
||||
dellist(&top->finals) ;
|
||||
dellist(&top->newfinal) ;
|
||||
/* Check for ambiguity between start states of branch just completed
|
||||
and start states of previous branches */
|
||||
for (otherand = saveand ; otherand != andptr ;
|
||||
otherand = otherand->next)
|
||||
checkand(saveand, andptr, otherand->start, root, &errelt) ;
|
||||
}
|
||||
pop() ;
|
||||
if (*canbenull) optional = stacklevels + 1 ;
|
||||
simplebranch(root, M_NULLVAL, saveand, optional) ;
|
||||
if (*canbenull) copyintolist(top->starts, &top->finals) ;
|
||||
for (final = top->finals ; final ; final = final->next)
|
||||
final->level = stacklevels ;
|
||||
}
|
||||
|
||||
/* Makefsa builds the portion of an FSA that corresponds to an entire
|
||||
submodel (i.e., a subtree of the tree representation of the rule).
|
||||
The value returned indicates whether the submodel can be null (i.e.,
|
||||
whether all its elements are optional). The parameters are a pointer
|
||||
to the root of the subtree and an integer indicating the level of
|
||||
nesting (if any) of submodels at which the subtree became optional.
|
||||
Note that as used here, "optional" means "not contextually required" in
|
||||
the terminology of the Standard rather than "contextually optional".
|
||||
|
||||
Makefsa is a recursive procedure. As the FSA is built, a stack is
|
||||
maintained of the nested content models that have been encountered
|
||||
but not yet terminated. For each open model on the stack, starts is
|
||||
a list of its start states (i.e., FSA states from which transitions
|
||||
correspond to elements which can occur at the beginning of the rule
|
||||
being processed), finals is a list of its final states, starta is a
|
||||
list of arcs emanating from the start states of the model, and
|
||||
allfinal and newfinal are lists of final states used in checking for
|
||||
determinism when and-groups are used. In more detail, allfinal is a
|
||||
list of final states of FSA's in and-groups that may occur just prior
|
||||
to the current context; i.e., 1) when starting a new FSA in an and-group,
|
||||
the set of final states of already-constructed FSA's in the same group
|
||||
(or final states of FSA's in submodel and-groups that end such FSA's)
|
||||
or 2) the set of final states of FSA's in an and-group that precedes
|
||||
the current context (e.g., the final states of the and-group FSA's
|
||||
when processing 'x' in ((a&b),x)). At each stage in the parse (or level
|
||||
on the stack), newfinal is the set of states to be added to those in
|
||||
allfinal as a result of processing at that level. Information in
|
||||
allfinal is passed from model to submodel; information in newfinal
|
||||
goes from submodel to model.
|
||||
*/
|
||||
LOGICAL makefsa(root, optional)
|
||||
TREE *root ;
|
||||
int optional ;
|
||||
{
|
||||
LOGICAL canbenull ;
|
||||
|
||||
canbenull = FALSE ;
|
||||
if (root->occurrence == OPT || root->occurrence == REP)
|
||||
optional = stacklevels + 1 ;
|
||||
/* The branch consists of a single element name */
|
||||
if (root->terminal)
|
||||
simplebranch(root, root->value, M_NULLVAL, optional) ;
|
||||
/* The submodel's connector is SEQ (,) */
|
||||
else if (root->connector == SEQ)
|
||||
makeseq(&canbenull, root, optional) ;
|
||||
/* The submodel's connector is OR (|) */
|
||||
else if (root->connector == OR)
|
||||
makeor(&canbenull, root) ;
|
||||
/* The submodel's connector is AND (&) */
|
||||
else if (root->connector == AND)
|
||||
makeand(&canbenull, root, optional) ;
|
||||
/* The submodel is a single item in parentheses */
|
||||
else canbenull = makefsa(root->first, optional) ;
|
||||
|
||||
/* The FSA is built, now repeat if occurrence indicator so indicates */
|
||||
if (root->occurrence == OPT || root->occurrence == REP) canbenull = TRUE ;
|
||||
if (root->occurrence == OPT) copyintolist(top->starts, &top->finals) ;
|
||||
else if (root->occurrence == REP) {
|
||||
repeat(root) ;
|
||||
copyintolist(top->starts, &top->finals) ;
|
||||
}
|
||||
else if (root->occurrence == PLUS) repeat(root) ;
|
||||
return(canbenull) ;
|
||||
}
|
||||
|
||||
/* Makeor processes a submodel whose connector is | */
|
||||
void makeor(canbenull, root)
|
||||
LOGICAL *canbenull ;
|
||||
TREE *root ;
|
||||
{
|
||||
TREE *child ;
|
||||
STATELIST *final ;
|
||||
|
||||
push() ;
|
||||
copyintolist(top->oldtop->starts, &top->starts) ;
|
||||
copyintolist(top->oldtop->allfinal, &top->allfinal) ;
|
||||
for (child = root->first ; child ; child = child->right) {
|
||||
if (makefsa(child, stacklevels)) *canbenull = TRUE ;
|
||||
savestartarcs() ;
|
||||
delstartarcs() ;
|
||||
copyintolist(top->finals, &top->oldtop->finals ) ;
|
||||
dellist(&top->finals) ;
|
||||
}
|
||||
copyintolist(top->newfinal, &top->oldtop->newfinal) ;
|
||||
pop() ;
|
||||
for (final = top->finals ; final ; final = final->next)
|
||||
final->level = stacklevels ;
|
||||
}
|
||||
|
||||
/* Makeseq processes a submodel whose connector is , */
|
||||
void makeseq(canbenull, root, optional)
|
||||
LOGICAL *canbenull ;
|
||||
TREE *root ;
|
||||
int optional ;
|
||||
{
|
||||
LOGICAL branchnull ;
|
||||
STATELIST *keepfinal = NULL, *final ;
|
||||
TREE *child ;
|
||||
|
||||
push() ;
|
||||
*canbenull = TRUE ;
|
||||
copyintolist(top->oldtop->starts, &top->starts) ;
|
||||
copyintolist(top->oldtop->allfinal, &top->allfinal) ;
|
||||
for (child = root->first ; child ; child = child->right) {
|
||||
branchnull = makefsa(child, optional) ;
|
||||
if (*canbenull) savestartarcs() ;
|
||||
if (! branchnull) {
|
||||
*canbenull = FALSE ;
|
||||
dellist(&top->allfinal) ;
|
||||
dellist(&keepfinal) ;
|
||||
}
|
||||
copyintolist(top->newfinal, &top->allfinal) ;
|
||||
copyintolist(top->newfinal, &keepfinal) ;
|
||||
dellist(&top->newfinal) ;
|
||||
delstartarcs() ;
|
||||
dellist(&top->starts) ;
|
||||
copyintolist(top->finals, &top->starts) ;
|
||||
dellist(&top->finals) ;
|
||||
if (! child->occurrence || child->occurrence == PLUS)
|
||||
optional = FALSE ;
|
||||
}
|
||||
copyintolist(top->starts, &top->oldtop->finals) ;
|
||||
copyintolist(keepfinal, &top->oldtop->newfinal) ;
|
||||
dellist(&keepfinal) ;
|
||||
pop() ;
|
||||
for (final = top->finals ; final ; final = final->next)
|
||||
final->level = stacklevels ;
|
||||
}
|
||||
|
||||
/* Nondeterm issues a diagnostic when a nondeterministic model is
|
||||
encountered */
|
||||
void nondeterm(root, c, eltp)
|
||||
TREE *root ;
|
||||
int c ;
|
||||
ELTSTRUCT *eltp ;
|
||||
{
|
||||
M_WCHAR *wtemp;
|
||||
|
||||
switch (c) {
|
||||
case ANDCONFLICT:
|
||||
wtemp = MakeWideCharString(and);
|
||||
warning2("Error in model for %s: Conflict in use of '%s'",
|
||||
thisrule,
|
||||
wtemp) ;
|
||||
m_free(wtemp, "wide character string");
|
||||
break ;
|
||||
case DATACONFLICT:
|
||||
wtemp = MakeWideCharString(rnicdata);
|
||||
warning2("Error in model for %s: Conflict in use of '%s'",
|
||||
thisrule,
|
||||
wtemp) ;
|
||||
m_free(wtemp, "wide character string");
|
||||
break ;
|
||||
case ELTCONFLICT:
|
||||
warning2("Error in model for %s: Conflict in use of '%s'",
|
||||
thisrule,
|
||||
eltp->enptr) ;
|
||||
break ;
|
||||
}
|
||||
regenerate(ruletree, root) ;
|
||||
msgline(" . . .\n") ;
|
||||
}
|
||||
|
||||
/* Notinlist returns TRUE iff item is not in list. If item is in list,
|
||||
it makes sure that the stored nesting level is the smaller of the two */
|
||||
LOGICAL notinlist(item, list)
|
||||
STATELIST *item, *list ;
|
||||
{
|
||||
for ( ; list ; list = list->next)
|
||||
if (list->value == item->value) {
|
||||
if (item->level < list->level) list->level = item->level ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
return(TRUE) ;
|
||||
}
|
||||
|
||||
/* Returns true if the arc is labeled #PCDATA or with an and-group that
|
||||
has an arc labelled #PCDATA from a start state */
|
||||
LOGICAL permitspcd(a)
|
||||
ARC *a ;
|
||||
{
|
||||
ANDGROUP *pand ;
|
||||
ARC *b ;
|
||||
|
||||
if (a->group) {
|
||||
for (pand = a->group ; pand ; pand = pand->next)
|
||||
for (b = pand->start->first ;
|
||||
b ;
|
||||
b = b->next)
|
||||
if (permitspcd(b)) return(TRUE) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
/* Not an and-group */
|
||||
if (a->label) return(FALSE) ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
|
||||
/* Pop pops the submodel stack when the end of the current submodel is
|
||||
encountered */
|
||||
void pop(M_NOPAR)
|
||||
{
|
||||
STACK *discard ;
|
||||
|
||||
dellist(&top->starts) ;
|
||||
dellist(&top->finals) ;
|
||||
dellist(&top->allfinal) ;
|
||||
dellist(&top->newfinal) ;
|
||||
delstartarcs() ;
|
||||
stacklevels-- ;
|
||||
discard = top ;
|
||||
top = top->oldtop ;
|
||||
m_free((M_POINTER) discard, "stack entry") ;
|
||||
}
|
||||
|
||||
/* Push pushes the submodel stack when a new group is encountered */
|
||||
void push(M_NOPAR)
|
||||
{
|
||||
STACK *new ;
|
||||
|
||||
new = (STACK *) m_malloc(sizeof(STACK), "stack entry") ;
|
||||
new->oldtop = top ;
|
||||
top = new ;
|
||||
stacklevels++ ;
|
||||
top->starts = top->finals = top->newfinal = top->allfinal = NULL ;
|
||||
top->starta = M_NULLVAL ;
|
||||
}
|
||||
|
||||
/* Regenerate is used in error processing to print the portion of a grammar
|
||||
rule preceding an error */
|
||||
LOGICAL regenerate(start, stop)
|
||||
TREE *start, *stop ;
|
||||
{
|
||||
TREE *child ;
|
||||
|
||||
if (start == stop) return(TRUE) ;
|
||||
|
||||
if (start->terminal)
|
||||
{
|
||||
char *mb_enptr;
|
||||
|
||||
if (start->value)
|
||||
mb_enptr = MakeMByteString(start->value->enptr);
|
||||
else
|
||||
mb_enptr = NULL;
|
||||
msg1line("%s", mb_enptr ? mb_enptr : rnicdata) ;
|
||||
if (mb_enptr)
|
||||
m_free(mb_enptr,"multi-byte string");
|
||||
}
|
||||
else
|
||||
{
|
||||
msgline("(") ;
|
||||
for (child = start->first ; child ; child = child->right)
|
||||
{
|
||||
if (regenerate(child, stop)) return(TRUE) ;
|
||||
if (child->right)
|
||||
{
|
||||
if (start->connector == SEQ) msg1line("%s", seq) ;
|
||||
if (start->connector == OR) msg1line("%s", or) ;
|
||||
if (start->connector == AND) msg1line("%s", and) ;
|
||||
}
|
||||
}
|
||||
msgline(")") ;
|
||||
}
|
||||
|
||||
if (start->occurrence == OPT) msg1line("%s", opt) ;
|
||||
if (start->occurrence == PLUS) msg1line("%s", plus) ;
|
||||
if (start->occurrence == REP) msg1line("%s", rep) ;
|
||||
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Repeat is called after a partial FSA is built for a submodel whose
|
||||
occurrence indicator is RPT (*) or PLUS (+). It handles repetition
|
||||
by adding arcs from all the final states to all the states reachable
|
||||
in one transition from a start state, labelling them as arcs from
|
||||
start states are labelled. */
|
||||
void repeat(root)
|
||||
TREE *root ;
|
||||
{
|
||||
STATELIST *final ;
|
||||
ARC *a ;
|
||||
int c ;
|
||||
ELTSTRUCT *errelt ;
|
||||
M_WCHAR *wtemp;
|
||||
|
||||
copyintolist(top->newfinal, &top->allfinal) ;
|
||||
dellist(&top->newfinal) ;
|
||||
for (a = top->starta ; a ; a = a->next) {
|
||||
for (final = top->allfinal ; final ; final = final->next) {
|
||||
if (a->group)
|
||||
if (c = checkrepeat(final->value, a->group, &errelt)) {
|
||||
wtemp = MakeWideCharString(root->occurrence == PLUS ? plus : rep);
|
||||
warning1("Conflict in use of %s", wtemp);
|
||||
m_free(wtemp, "wide character string");
|
||||
nondeterm(root, c, errelt) ;
|
||||
}
|
||||
else
|
||||
;
|
||||
else
|
||||
if (c = checkdfsa(final->value,
|
||||
a->label,
|
||||
a->group,
|
||||
a->id,
|
||||
&errelt))
|
||||
nondeterm (root, c, errelt) ;
|
||||
else
|
||||
;
|
||||
}
|
||||
for (final = top->finals ; final ; final = final->next) {
|
||||
if (samelabelarc(a, final->value)) continue ;
|
||||
if (a->group)
|
||||
if (c = checkrepeat(final->value, a->group, &errelt))
|
||||
nondeterm(root, c, errelt) ;
|
||||
if (a->label ||
|
||||
a->group ||
|
||||
! final->value->frompcdata) {
|
||||
if (c = addarc(final->value, a->to, a->label,
|
||||
a->group, TRUE, a->id,
|
||||
a->minim, &errelt))
|
||||
nondeterm(root, c, errelt) ;
|
||||
if (permitspcd(a)) final->value->datacontent = TRUE ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Used during processing of occurrence indicators in content models such
|
||||
as (a+)+ to prohibit duplicate arcs */
|
||||
LOGICAL samelabelarc(a, s)
|
||||
ARC *a ;
|
||||
STATE *s ;
|
||||
{
|
||||
ARC *b ;
|
||||
|
||||
for (b = s->first ; b ; b = b->next)
|
||||
if (b->id == a->id) return(TRUE) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Saves the name of an element appearing on the left-hand side of a
|
||||
grammar rule */
|
||||
#if defined(M_PROTO)
|
||||
void savelhs(LOGICAL param)
|
||||
#else
|
||||
void savelhs(param)
|
||||
LOGICAL param ;
|
||||
#endif
|
||||
{
|
||||
STATE *end ;
|
||||
ELTSTRUCT *errelt ;
|
||||
ELTSTRUCT *thiselt ;
|
||||
|
||||
*nextlhs = (LHS *) m_malloc(sizeof(LHS), "lhs") ;
|
||||
(*nextlhs)->next = NULL ;
|
||||
thiselt = ntrelt(name) ;
|
||||
(*nextlhs)->elt = thiselt ;
|
||||
nextlhs = &(*nextlhs)->next ;
|
||||
if (! startstate) {
|
||||
startstate = getstate() ;
|
||||
end = getstate() ;
|
||||
addarc(startstate, end, thiselt, M_NULLVAL, FALSE, 1, FALSE, &errelt) ;
|
||||
end->final = TRUE ;
|
||||
}
|
||||
if (param && thiselt->parptr) {
|
||||
m_err1("Parameters for %s already defined", thiselt->enptr) ;
|
||||
return ;
|
||||
}
|
||||
if (! param && thiselt->model)
|
||||
warning1("Duplicate model for element %s", thiselt->enptr) ;
|
||||
}
|
||||
|
||||
/* Called when arcs are added to the start state of a submodel that is
|
||||
also a start state of the parent model to set the parent model's
|
||||
starta list */
|
||||
void savestartarcs(M_NOPAR)
|
||||
{
|
||||
ARC *carcptr, *parcptr ;
|
||||
|
||||
for (carcptr = top->starta ; carcptr ; carcptr = carcptr->next) {
|
||||
parcptr = (ARC *) m_malloc(sizeof(ARC), "arc") ;
|
||||
parcptr->label = carcptr->label ;
|
||||
parcptr->optional = carcptr->optional ;
|
||||
parcptr->minim = carcptr->minim ;
|
||||
parcptr->group = carcptr->group ;
|
||||
parcptr->to = carcptr->to ;
|
||||
parcptr->next = top->oldtop->starta ;
|
||||
parcptr->id = carcptr->id ;
|
||||
top->oldtop->starta = parcptr ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Simplebranch adds a new state and transition to it in an FSA when a
|
||||
submodel consists of a single element or of an and group */
|
||||
void simplebranch(root, value, group, optional)
|
||||
TREE *root ;
|
||||
ELTSTRUCT *value ;
|
||||
ANDGROUP *group ;
|
||||
int optional ;
|
||||
{
|
||||
STATE *new = NULL ;
|
||||
STATELIST *index ;
|
||||
int c ;
|
||||
ELTSTRUCT *errelt ;
|
||||
|
||||
/* Check for ambiguity between an arc to be added and arcs from final
|
||||
states of and-groups that terminate at the start state of the new
|
||||
arc */
|
||||
for (index = top->allfinal ; index ; index = index->next)
|
||||
if (c = checkdfsa(index->value, value, group, root->eltid, &errelt))
|
||||
nondeterm(root, c, errelt) ;
|
||||
for (index = top->starts ; index ; index = index->next) {
|
||||
if (! group && ! value && index->value->frompcdata)
|
||||
continue ;
|
||||
if (! new) {
|
||||
new = getstate() ;
|
||||
new->frompcdata = (LOGICAL) (! group && ! value) ;
|
||||
}
|
||||
c = addarc(index->value, new, value, group,
|
||||
(LOGICAL) (optional > index->level),
|
||||
root->eltid, root->minim, &errelt) ;
|
||||
if (c) nondeterm(root, c, errelt) ;
|
||||
if (! group && ! value) index->value->datacontent = TRUE ;
|
||||
}
|
||||
if (new) {
|
||||
top->finals = (STATELIST *) m_malloc(sizeof(STATELIST), "state list") ;
|
||||
top->finals->value = new ;
|
||||
top->finals->level = stacklevels ;
|
||||
top->finals->next = NULL ;
|
||||
top->starta = (ARC *) m_malloc(sizeof(ARC), "arc") ;
|
||||
top->starta->label = value ;
|
||||
top->starta->optional = FALSE ;
|
||||
top->starta->minim = root->minim ;
|
||||
top->starta->group = group ;
|
||||
top->starta->to = new ;
|
||||
top->starta->next = NULL ;
|
||||
top->starta->id = root->eltid ;
|
||||
}
|
||||
else copyintolist(top->starts, &top->finals) ;
|
||||
}
|
||||
|
||||
/* Startfsa creates a new FSA. It is called once for each content model and
|
||||
once for each and group. Its parameters are the root of the
|
||||
subtree in the tree representing the grammar rule being processed and
|
||||
the pointer to a flag that is set to indicate whether or not the
|
||||
submodel can be null. */
|
||||
STATE *startfsa(root, canbenull)
|
||||
TREE *root ;
|
||||
LOGICAL *canbenull ;
|
||||
{
|
||||
STATELIST *item ;
|
||||
STATE *first ;
|
||||
|
||||
top->starts = (STATELIST *) m_malloc(sizeof(STATELIST), "state list") ;
|
||||
first = getstate() ;
|
||||
top->starts->value = first ;
|
||||
top->starts->level = stacklevels ;
|
||||
top->starts->next = NULL ;
|
||||
*canbenull = makefsa(root, FALSE) ;
|
||||
for (item = top->finals ; item ; item = item->next)
|
||||
item->value->final = TRUE ;
|
||||
dellist(&top->starts) ;
|
||||
delstartarcs() ;
|
||||
return(first) ;
|
||||
}
|
||||
|
||||
653
cde/programs/dthelp/parser/pass2/build/out.c
Normal file
653
cde/programs/dthelp/parser/pass2/build/out.c
Normal file
@@ -0,0 +1,653 @@
|
||||
/* $XConsortium: out.c /main/3 1995/11/08 10:43:06 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Out.c contains the procedures used by program BUILD to output results */
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "context.h"
|
||||
#include "build.h"
|
||||
#include "delim.h"
|
||||
#include "entdef.h"
|
||||
|
||||
#define boolean(x) x ? "TRUE" : "FALSE"
|
||||
|
||||
/* Macro names written to dtd.h */
|
||||
char many[] = "M_ANY" ;
|
||||
char mcdata[] = "M_CDATA" ;
|
||||
char mcdataent[] = "CDATAENT" ;
|
||||
char mcdata_att[] = "M_CDATT" ;
|
||||
char mcurrent[] = "M_CURRENT" ;
|
||||
char mentatt[] = "M_ENTATT" ;
|
||||
char merror[] = "M_ERROR" ;
|
||||
char mgeneral[] = "" ;
|
||||
char midrefs[] = "M_IDRFS" ;
|
||||
char midref[] = "M_IDRF" ;
|
||||
char mid[] = "M_ID" ;
|
||||
char mkeyword[] = "M_KEYWORD" ;
|
||||
char mnamedef[] = "M_NAMEDEF" ;
|
||||
char mnamepar[] = "M_NAMEPAR" ;
|
||||
char mnames[] = "M_NAMES" ;
|
||||
char mnmtkns[] = "M_NMSTOKEN" ;
|
||||
char mnmtoken[] = "M_NMTOKEN" ;
|
||||
char mnone[] = "M_NONE" ;
|
||||
char mnulldef[] = "M_NULLDEF" ;
|
||||
char mnumbers[] = "M_NUMS" ;
|
||||
char mnumber[] = "M_NUMBER" ;
|
||||
char mnutkns[] = "M_NUSTOKEN" ;
|
||||
char mnutoken[] = "M_NUTOKEN" ;
|
||||
char mrcdata[] = "M_RCDATA" ;
|
||||
char mregexp[] = "M_REGEXP" ;
|
||||
char mrequired[] = "M_REQUIRED" ;
|
||||
|
||||
/* Deftype returns a string indicating the default type of the nth parameter.
|
||||
*/
|
||||
char *deftype(n)
|
||||
int n ;
|
||||
{
|
||||
switch (n) {
|
||||
case NAME: return(mnamedef) ;
|
||||
case CURRENT: return(mcurrent) ;
|
||||
case REQUIRED: return(mrequired) ;
|
||||
case NULLDEF: return(mnulldef) ;
|
||||
default:
|
||||
errexit = ERREXIT ;
|
||||
return(merror) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Called after all input is read to generate output */
|
||||
void done(M_NOPAR)
|
||||
{
|
||||
|
||||
if (! eltree.data) {
|
||||
warning("Error: no elements specified") ;
|
||||
return ;
|
||||
}
|
||||
eltreeout() ;
|
||||
parout() ;
|
||||
srefout() ;
|
||||
entout("entity") ;
|
||||
fsa() ;
|
||||
exout() ;
|
||||
template() ;
|
||||
}
|
||||
|
||||
/* Prints data value of an entry in the element name tree */
|
||||
void dumpentnode(file, value)
|
||||
FILE *file ;
|
||||
M_TRIE *value ;
|
||||
{
|
||||
|
||||
fprintf(file, ", %d", ((ELTSTRUCT *) value)->eltno) ;
|
||||
}
|
||||
|
||||
/* Prints data value of an entry in the trie of short reference map names,
|
||||
reporting any maps that are referenced but not defined */
|
||||
void dumpmapnode(file, value)
|
||||
FILE *file ;
|
||||
M_TRIE *value ;
|
||||
{
|
||||
fprintf(file, ", %d", ((MAP *) value)->map) ;
|
||||
if (! ((MAP *) value)->defined)
|
||||
warning1("Short reference map \"%s\" referenced but not defined.",
|
||||
((MAP *) value)->mapname) ;
|
||||
}
|
||||
|
||||
|
||||
/* Prints data value of an entry in the trie of short reference delimiters */
|
||||
void dumpsrefnode(file, value)
|
||||
FILE *file ;
|
||||
M_TRIE *value ;
|
||||
{
|
||||
fprintf(file, ", %d", ((SREFSTRUCT *) value)->srefcnt) ;
|
||||
}
|
||||
|
||||
|
||||
/* Controls printing of element blocks in alphabetical order to the
|
||||
template file */
|
||||
void eltblocks(tempfile)
|
||||
FILE *tempfile ;
|
||||
{
|
||||
int n ;
|
||||
M_TRIE *node[M_NAMELEN + 1] ;
|
||||
M_TRIE *current ;
|
||||
char symbol ;
|
||||
|
||||
n = 0 ;
|
||||
current = eltree.data ;
|
||||
while (TRUE) {
|
||||
symbol = current->symbol ;
|
||||
node[n] = current->next ;
|
||||
if (! symbol) {
|
||||
tempelt((ELTSTRUCT *) current->data, tempfile) ;
|
||||
current = current->next ;
|
||||
while (! current) {
|
||||
n-- ;
|
||||
if (n < 0) return ;
|
||||
current = node[n] ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
current = current->data ;
|
||||
n++ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Writes data about elements */
|
||||
void eltreeout(M_NOPAR)
|
||||
{
|
||||
M_WCHAR *p ;
|
||||
int enameindex = 0 ;
|
||||
ELTSTRUCT *eltp ;
|
||||
LOGICAL first ;
|
||||
|
||||
m_openchk(&dtd, "dtd.h", "w") ;
|
||||
|
||||
fputs("#if defined(M_DTDDEF)\n", dtd) ;
|
||||
fputs("#define M_DTDEXTERN\n", dtd) ;
|
||||
fputs("#define M_DTDINIT(a) = a\n", dtd) ;
|
||||
fputs("#else\n", dtd) ;
|
||||
fputs("#define M_DTDEXTERN extern\n", dtd) ;
|
||||
fputs("#define M_DTDINIT(a)\n", dtd) ;
|
||||
fputs("#endif\n\n", dtd) ;
|
||||
|
||||
fputs("#include \"dtddef.h\"\n\n", dtd) ;
|
||||
|
||||
dumpptrie(&eltree, "m_entree", dtd, "M_DTDEXTERN", "M_DTDDEF",
|
||||
dumpentnode) ;
|
||||
|
||||
fprintf(dtd, "M_DTDEXTERN M_WCHAR m_ename[%d]\n", enamelen) ;
|
||||
fputs("#if defined(M_DTDDEF)\n = {\n", dtd) ;
|
||||
first = TRUE ;
|
||||
for (eltp = firstelt ; eltp ; eltp = eltp->next) {
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
for (p = eltp->enptr ; *p ; p++)
|
||||
fprintf(dtd, " %d,\n", *p) ;
|
||||
fputs(" 0", dtd) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
|
||||
|
||||
fprintf(dtd, "M_DTDEXTERN int m_elcount M_DTDINIT(%d) ;\n", ecount) ;
|
||||
fprintf(dtd,
|
||||
"M_DTDEXTERN M_ELTSTRUCT m_element[%d]\n#if defined(M_DTDDEF)\n = {\n",
|
||||
ecount) ;
|
||||
first = TRUE ;
|
||||
for (eltp = firstelt ; eltp ; eltp = eltp->next) {
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
if (! eltp->content)
|
||||
warning1("No content model for element %s", eltp->enptr) ;
|
||||
fprintf(dtd, " %d, %d, %s, ",
|
||||
enameindex, eltp->model ? eltp->model->count : 0,
|
||||
typecon(eltp->content)) ;
|
||||
fprintf(dtd, "%d, %d, ", eltp->inptr, eltp->exptr) ;
|
||||
fprintf(dtd, "%d, %d, %d",
|
||||
eltp->parindex, eltp->paramcount, eltp->srefptr) ;
|
||||
enameindex += w_strlen(eltp->enptr) + 1 ;
|
||||
fprintf(dtd, ", %s, %s, %s",
|
||||
boolean(eltp->stmin), boolean(eltp->etmin), boolean(eltp->useoradd)) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
|
||||
/* Enttype returns a string indicating the type of an entity */
|
||||
char *enttype(n)
|
||||
int n ;
|
||||
{
|
||||
switch(n) {
|
||||
case M_GENERAL: return(mgeneral) ;
|
||||
case M_SYSTEM: return(entsystem) ;
|
||||
case M_STARTTAG: return(entst) ;
|
||||
case M_ENDTAG: return(entet) ;
|
||||
case M_MD: return(entmd) ;
|
||||
case M_PI: return(entpi) ;
|
||||
case M_CDATAENT: return(cdata) ;
|
||||
case M_SDATA: return(entsdata) ;
|
||||
default:
|
||||
errexit = ERREXIT ;
|
||||
return(merror) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Outputs exception lists */
|
||||
void exout(M_NOPAR)
|
||||
{
|
||||
EXCEPTION *ex ;
|
||||
int exindex = 0 ;
|
||||
LOGICAL first = TRUE ;
|
||||
|
||||
fputs("M_DTDEXTERN M_EXCEPTION m_exception", dtd) ;
|
||||
if (excount) {
|
||||
fprintf(dtd,
|
||||
"[%d]\n#if defined(M_DTDDEF)\n = {\n",
|
||||
excount) ;
|
||||
for (ex = firstex ; ex ; ex = ex->nextptr) {
|
||||
if (! first) fputs(",\n", dtd) ;
|
||||
first = FALSE ;
|
||||
exindex++ ;
|
||||
fprintf(dtd, " %d, %d", ex->element, ex->next ? exindex + 1 : 0) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
}
|
||||
|
||||
/* Outputs FSA definitions */
|
||||
void fsa(M_NOPAR)
|
||||
{
|
||||
int arcount = 0 ;
|
||||
STATE *pstate ;
|
||||
FILE *farc ;
|
||||
LOGICAL first ;
|
||||
ANDGROUP *pand ;
|
||||
ARC *parc ;
|
||||
|
||||
m_openchk(&farc, "arc.h", "w") ;
|
||||
|
||||
fprintf(dtd,
|
||||
"M_DTDEXTERN M_STATESTRUCT m_state[%d]\n#if defined(M_DTDDEF)\n = {\n",
|
||||
stateused) ;
|
||||
|
||||
for (pstate = firststate ; pstate ; pstate = pstate->next)
|
||||
for (parc = pstate->first ; parc ; parc = parc->next)
|
||||
++arcount ;
|
||||
fprintf(farc,
|
||||
"M_DTDEXTERN M_ARCSTRUCT m_arc[%d]\n#if defined(M_DTDDEF)\n = {\n",
|
||||
arcount) ;
|
||||
|
||||
arcount = 0 ;
|
||||
first = TRUE ;
|
||||
for (pstate = firststate ; pstate ; pstate = pstate->next) {
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
fprintf(dtd, " %s, %s, %d",
|
||||
boolean(pstate->final), boolean(pstate->datacontent),
|
||||
pstate->first ? ++arcount : 0) ;
|
||||
for (parc = pstate->first ; parc ; parc = parc->next) {
|
||||
if (arcount > 1) fputs(",\n", farc) ;
|
||||
fprintf(farc, " %d, %s, %d, %d, %d, %d",
|
||||
parc->label ? parc->label->eltno : 0,
|
||||
boolean(parc->optional),
|
||||
parc->minim ? parc->id : 0,
|
||||
parc->group ? parc->group->count : 0,
|
||||
parc->to->count,
|
||||
parc->next ? ++arcount : 0
|
||||
) ;
|
||||
}
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
fputs(ndif, farc) ;
|
||||
|
||||
fputs("M_DTDEXTERN M_ANDSTRUCT m_andgroup", dtd) ;
|
||||
if (andused) {
|
||||
fprintf(dtd, "[%d]\n#if defined(M_DTDDEF)\n = {\n", andused) ;
|
||||
first = TRUE ;
|
||||
for (pand = firstand ; pand ; pand = pand->nextptr) {
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
fprintf(dtd, " %d, %d",
|
||||
pand->start->count,
|
||||
pand->next ? pand->next->count : M_NULLVAL) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
fclose(farc) ;
|
||||
}
|
||||
|
||||
/* Writes data about parameters */
|
||||
void parout(M_NOPAR)
|
||||
{
|
||||
PARAMETER *paramp ;
|
||||
LOGICAL first = TRUE ;
|
||||
int pnameindex = 0 ;
|
||||
M_WCHAR *p ;
|
||||
int kw ;
|
||||
int defindex = 0 ;
|
||||
PTYPE *ptypep ;
|
||||
|
||||
fputs("M_DTDEXTERN M_WCHAR m_keyword", dtd) ;
|
||||
if (kwlen)
|
||||
{
|
||||
fprintf(dtd,
|
||||
"[%d]\n#if defined(M_DTDDEF)\n = {\n", /* keep the "}" balanced */
|
||||
kwlen) ;
|
||||
first = TRUE ;
|
||||
for (ptypep = firstptype ; ptypep ; ptypep = ptypep->nextptr)
|
||||
{
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
for (p = ptypep->keyword ; *p ; p++)
|
||||
fprintf(dtd, " %d,\n", *p) ;
|
||||
fputs(" 0", dtd) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
|
||||
fputs("M_DTDEXTERN M_WCHAR m_defval", dtd) ;
|
||||
if (deflen)
|
||||
{
|
||||
fprintf(dtd,
|
||||
"[%d]\n#if defined(M_DTDDEF)\n = {\n", /* keep the "}" balanced */
|
||||
deflen) ;
|
||||
first = TRUE ;
|
||||
for (paramp = firstpar ; paramp ; paramp = paramp->nextptr)
|
||||
if (paramp->defstring)
|
||||
{
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
for (p = paramp->defstring ; *p ; p++)
|
||||
fprintf(dtd, " %d,\n", *p) ;
|
||||
fputs(" 0", dtd) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
|
||||
fputs(
|
||||
"M_DTDEXTERN struct {\n int keyword, next ;\n } m_ptype",
|
||||
dtd) ;
|
||||
if (ptypelen)
|
||||
{
|
||||
fprintf(dtd, "[%d]\n#if defined(M_DTDDEF)\n = {\n", ptypelen) ;
|
||||
/* keep the "}" balanced */
|
||||
kw = 0 ;
|
||||
first = TRUE ;
|
||||
for (ptypep = firstptype ; ptypep ; ptypep = ptypep->nextptr)
|
||||
{
|
||||
if (first) first = FALSE ;
|
||||
else fprintf(dtd, ",\n") ;
|
||||
fprintf(dtd, " %d, %d", kw, ptypep->next) ;
|
||||
kw += w_strlen(ptypep->keyword) + 1 ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
|
||||
fputs("M_DTDEXTERN M_PARAMETER m_parameter", dtd) ;
|
||||
if (parcount)
|
||||
{
|
||||
kw = 0 ;
|
||||
fprintf(dtd,
|
||||
"[%d]\n#if defined(M_DTDDEF)\n = {\n", /* keep the "}" balanced */
|
||||
parcount) ;
|
||||
first = TRUE ;
|
||||
for (paramp = firstpar ; paramp ; paramp = paramp->nextptr)
|
||||
{
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
fprintf(dtd,
|
||||
" %d, %s, %d, %s, ",
|
||||
pnameindex,
|
||||
partype(paramp->type),
|
||||
paramp->kwlist,
|
||||
deftype(paramp->deftype) );
|
||||
pnameindex += w_strlen(paramp->paramname) + 1 ;
|
||||
if (paramp->defval)
|
||||
fprintf(dtd, "&m_keyword[%d]", paramp->defval - 1) ;
|
||||
else if (paramp->defstring)
|
||||
{
|
||||
fprintf(dtd, "&m_defval[%d]", defindex) ;
|
||||
defindex += w_strlen(paramp->defstring) + 1 ;
|
||||
}
|
||||
else
|
||||
fputs("NULL", dtd) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
|
||||
fputs("M_DTDEXTERN M_WCHAR m_pname", dtd) ;
|
||||
if (pnamelen)
|
||||
{
|
||||
fprintf(dtd,
|
||||
"[%d]\n#if defined(M_DTDDEF)\n = {\n", /* keep the "}" balanced */
|
||||
pnamelen) ;
|
||||
first = TRUE ;
|
||||
for (paramp = firstpar ; paramp ; paramp = paramp->nextptr)
|
||||
{
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
for (p = paramp->paramname ; *p ; p++) fprintf(dtd, " %d,\n", *p) ;
|
||||
fputs(" 0", dtd) ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
|
||||
fprintf(dtd, "#define M_MAXPAR %d\n\n", maxpar) ;
|
||||
}
|
||||
|
||||
/* Partype returns a string indicating the type of the nth parameter. */
|
||||
char *partype(n)
|
||||
int n ;
|
||||
{
|
||||
switch(n) {
|
||||
case GRPO: return(mkeyword) ;
|
||||
case CDATA: return(mcdata_att) ;
|
||||
case ID: return(mid) ;
|
||||
case IDREF: return(midref) ;
|
||||
case IDREFS: return(midrefs) ;
|
||||
case NAMETYPE: return(mnamepar) ;
|
||||
case NAMES: return(mnames) ;
|
||||
case NMTOKEN: return(mnmtoken) ;
|
||||
case NMTOKENS: return(mnmtkns) ;
|
||||
case NUMBER: return(mnumber) ;
|
||||
case NUMBERS: return(mnumbers) ;
|
||||
case NUTOKEN: return(mnutoken) ;
|
||||
case NUTOKENS: return(mnutkns) ;
|
||||
case ENTATT: return(mentatt) ;
|
||||
default:
|
||||
errexit = ERREXIT ;
|
||||
return(merror) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write short reference information */
|
||||
void srefout(M_NOPAR)
|
||||
{
|
||||
LOGICAL first = TRUE ;
|
||||
int *mapbysref ;
|
||||
SREFSTRUCT *srefp ;
|
||||
SREFDATA *data ;
|
||||
int count = 0 ;
|
||||
int thisrow ;
|
||||
int i, j ;
|
||||
|
||||
fprintf(dtd, "#define M_MAXSR %d\n", maxsr) ;
|
||||
fprintf(dtd, "#define M_MAXSEQ %d\n", maxseq) ;
|
||||
fprintf(dtd, "#define M_SREFCNT %d\n", sreflen) ;
|
||||
dumpptrie(&maptree, "m_maptree", dtd, "M_DTDEXTERN", "M_DTDDEF",
|
||||
dumpmapnode) ;
|
||||
dumpptrie(&sreftree, "m_sreftree", dtd, "M_DTDEXTERN", "M_DTDDEF",
|
||||
dumpsrefnode) ;
|
||||
|
||||
fputs("M_DTDEXTERN int m_map", dtd) ;
|
||||
if (mapcnt) {
|
||||
mapbysref = (int *) calloc(mapcnt * sreflen, sizeof(int)) ;
|
||||
if (! mapbysref) {
|
||||
m_error("Unable to allocate workspace to process short references") ;
|
||||
exit(TRUE) ;
|
||||
}
|
||||
for (srefp = firstsref ; srefp ; srefp = srefp->next)
|
||||
for (data = srefp->data ; data ; data = data->next)
|
||||
if (data->entidx)
|
||||
mapbysref[sreflen * (data->map - 1) + srefp->srefcnt - 1] =
|
||||
data->entidx ;
|
||||
fprintf(dtd, "[%d]\n#if defined(M_DTDDEF)\n = {\n", mapcnt) ;
|
||||
for (i = 0 ; i < mapcnt ; i++) {
|
||||
if (i) fputs(",\n", dtd) ;
|
||||
thisrow = 0 ;
|
||||
for (j = 0 ; j < sreflen ; j++)
|
||||
if (mapbysref[sreflen * i + j]) thisrow++ ;
|
||||
fprintf(dtd, " %d", thisrow ? count + 1 : M_NULLVAL) ;
|
||||
count += thisrow ;
|
||||
}
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
|
||||
fputs(
|
||||
"M_DTDEXTERN M_SREF m_sref", dtd) ;
|
||||
if (count) {
|
||||
fprintf(dtd, "[%d]\n#if defined(M_DTDDEF)\n = {\n", count) ;
|
||||
first = TRUE ;
|
||||
count = 0 ;
|
||||
for (i = 0 ; i < mapcnt ; i++)
|
||||
for (j = 0 ; j < sreflen ; )
|
||||
if (mapbysref[sreflen * i + j]) {
|
||||
count++ ;
|
||||
if (first) first = FALSE ;
|
||||
else fputs(",\n", dtd) ;
|
||||
fprintf(dtd, " %d, %d, ", j + 1, mapbysref[sreflen * i + j]) ;
|
||||
for (j++ ; j < sreflen ; j++)
|
||||
if (mapbysref[sreflen * i + j]) break ;
|
||||
fprintf(dtd, "%d", j < sreflen ? count + 1 : 0) ;
|
||||
}
|
||||
else j++ ;
|
||||
fputs(ndif, dtd) ;
|
||||
}
|
||||
SUBONE
|
||||
}
|
||||
|
||||
/* Output one element block in a template */
|
||||
void tempelt(eltp, tempfile)
|
||||
ELTSTRUCT *eltp ;
|
||||
FILE *tempfile ;
|
||||
{
|
||||
PARAMETER *paramp ;
|
||||
PTYPE *ptypep ;
|
||||
M_WCHAR *p ;
|
||||
char *mb_paramname;
|
||||
int indent ;
|
||||
int i ;
|
||||
char *mb_enptr;
|
||||
|
||||
mb_enptr = MakeMByteString(eltp->enptr);
|
||||
fprintf(tempfile, "\n<ELEMENT %s>\n", mb_enptr) ;
|
||||
m_free(mb_enptr, "Multi-byte string");
|
||||
if (eltp->parptr)
|
||||
{
|
||||
fputs(" /*\n", tempfile) ;
|
||||
fputs(" <PARAM>\n", tempfile) ;
|
||||
for (paramp = eltp->parptr ; paramp ; paramp = paramp->next)
|
||||
{
|
||||
fputs(" ", tempfile) ;
|
||||
indent = 9 ;
|
||||
for (p = paramp->paramname ; *p ; p++, indent += 2)
|
||||
{
|
||||
int length;
|
||||
char mbyte[32]; /* larger than any multibyte character */
|
||||
char *pc, c;
|
||||
|
||||
length = wctomb(mbyte, *p);
|
||||
if (length < 0)
|
||||
m_error("Invalid multibyte character found in an element");
|
||||
else
|
||||
{
|
||||
pc = mbyte;
|
||||
if (length == 1)
|
||||
{
|
||||
c = *pc;
|
||||
putc(isupper(c) ? tolower(c) : c, tempfile) ;
|
||||
}
|
||||
else
|
||||
while (--length >= 0) putc(*pc++, tempfile) ;
|
||||
}
|
||||
}
|
||||
mb_paramname = MakeMByteString(paramp->paramname);
|
||||
fprintf(tempfile, " = %s ", mb_paramname) ;
|
||||
m_free(mb_paramname,"multi-byte string");
|
||||
if (paramp->type == GRPO)
|
||||
{
|
||||
putc('(', tempfile) ;
|
||||
for (ptypep = paramp->ptypep ; ptypep ; )
|
||||
{
|
||||
char *mb_keyword;
|
||||
|
||||
mb_keyword = MakeMByteString(ptypep->keyword);
|
||||
fprintf(tempfile,
|
||||
"%s = %s",
|
||||
mb_keyword,
|
||||
mb_keyword) ;
|
||||
m_free(mb_keyword,"multi-byte string");
|
||||
ptypep = ptypep->next ? ptypep->nextptr : (PTYPE *) NULL ;
|
||||
if (ptypep)
|
||||
{
|
||||
fputs(",\n", tempfile) ;
|
||||
for (i = 0 ; i < indent ; i++) putc(' ', tempfile) ;
|
||||
}
|
||||
}
|
||||
putc(')', tempfile) ;
|
||||
}
|
||||
fputs(" ;\n", tempfile) ;
|
||||
}
|
||||
fputs(" */\n", tempfile) ;
|
||||
}
|
||||
fputs(" /*<STRING-CODE>*/\n", tempfile) ;
|
||||
fputs(" <START-CODE>\n", tempfile) ;
|
||||
fputs(" <START-STRING><\\START-STRING>\n", tempfile) ;
|
||||
fputs(" /*<TEXT-CODE>*/\n", tempfile) ;
|
||||
fputs(" /*<PI-CODE>*/\n", tempfile) ;
|
||||
fputs(" <END-CODE>\n", tempfile) ;
|
||||
fputs(" <END-STRING><\\END-STRING>\n", tempfile) ;
|
||||
}
|
||||
|
||||
/* Write template */
|
||||
void template(M_NOPAR)
|
||||
{
|
||||
FILE *tempfile ;
|
||||
M_ENTITY *ent ;
|
||||
LOGICAL undefent = FALSE ;
|
||||
char *mb_name;
|
||||
|
||||
m_openchk(&tempfile, "template", "w") ;
|
||||
for (ent = firstent ; ent ; ent = ent->next) {
|
||||
if (! ent->wheredef) {
|
||||
if (! undefent) {
|
||||
fputs("/*\n", tempfile) ;
|
||||
undefent = TRUE ;
|
||||
}
|
||||
|
||||
mb_name = MakeMByteString(ent->name);
|
||||
fprintf(tempfile, "<!ENTITY %s %s \"\">\n", mb_name, ent->type) ;
|
||||
m_free(mb_name, "wide character ent->name");
|
||||
}
|
||||
}
|
||||
if (undefent) fputs("*/\n", tempfile) ;
|
||||
fputs("<SIGN-ON>\n", tempfile) ;
|
||||
fputs("<GLOBAL-DEFINE>\n<GLOBAL-DECLARE>\n\n", tempfile) ;
|
||||
eltblocks(tempfile) ;
|
||||
fclose(tempfile) ;
|
||||
}
|
||||
|
||||
/* Typecon returns a string indicating the content type of the nth element.*/
|
||||
char *typecon(n)
|
||||
int n ;
|
||||
{
|
||||
switch(n) {
|
||||
case GRPO: return(mregexp) ;
|
||||
case ANY: return(many) ;
|
||||
case NONE: return(mnone) ;
|
||||
case CDATA: return(mcdata) ;
|
||||
case RCDATA: return(mrcdata) ;
|
||||
default:
|
||||
errexit = ERREXIT ;
|
||||
return(merror) ;
|
||||
}
|
||||
}
|
||||
|
||||
#include "entout.c"
|
||||
322
cde/programs/dthelp/parser/pass2/build/param.c
Normal file
322
cde/programs/dthelp/parser/pass2/build/param.c
Normal file
@@ -0,0 +1,322 @@
|
||||
/* $XConsortium: param.c /main/3 1995/11/08 10:43:22 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Param.c contains procedures related to parameters for program BUILD */
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "build.h"
|
||||
#include "context.h"
|
||||
#include "delim.h"
|
||||
|
||||
/* Add a keyword to the list of possible values of a keyword parameter for
|
||||
the current element
|
||||
*/
|
||||
void addkeyword(M_NOPAR)
|
||||
{
|
||||
int length ;
|
||||
PARAMETER *par ;
|
||||
PTYPE *kw ;
|
||||
|
||||
/* Check if duplicate keyword for this parameter */
|
||||
for (kw = newpar->ptypep ; kw ; kw = kw->nextptr)
|
||||
if (w_strcmp(kw->keyword, name) == 0)
|
||||
{
|
||||
warning3("Warning: Repeated keyword %s in parameter %s of %s",
|
||||
name,
|
||||
newpar->paramname,
|
||||
thisrule) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Check if duplicate keyword within parameters of this element */
|
||||
for (par = plist ; par != newpar ; par = par->next)
|
||||
for (kw = par->ptypep ; kw ; kw = kw->nextptr)
|
||||
{
|
||||
if (w_strcmp(kw->keyword, name) == 0)
|
||||
warning4("Keyword %s used in parameters %s and %s of %s",
|
||||
name,
|
||||
par->paramname,
|
||||
newpar->paramname,
|
||||
thisrule) ;
|
||||
if (! kw->next) break ;
|
||||
}
|
||||
|
||||
*nextptype = (PTYPE *) m_malloc(sizeof(PTYPE), "ptype") ;
|
||||
if (newpar->kwlist) thisptype->next = ptypelen + 1 ;
|
||||
else
|
||||
{
|
||||
newpar->kwlist = ptypelen + 1 ;
|
||||
newpar->ptypep = *nextptype ;
|
||||
}
|
||||
thisptype = *nextptype ;
|
||||
thisptype->next = M_NULLVAL ;
|
||||
thisptype->nextptr = NULL ;
|
||||
nextptype = &(thisptype->nextptr) ;
|
||||
length = w_strlen(name) + 1 ;
|
||||
thisptype->keyword = (M_WCHAR *) m_malloc(length, "keyword") ;
|
||||
w_strcpy(thisptype->keyword, name) ;
|
||||
kwlen += length ;
|
||||
ptypelen++ ;
|
||||
}
|
||||
|
||||
/* Add a parameter to the current element */
|
||||
void addpar(M_NOPAR)
|
||||
{
|
||||
PARAMETER *paramp, *last ;
|
||||
int length ;
|
||||
|
||||
parcount++ ;
|
||||
pcount++ ;
|
||||
for (paramp = plist ; paramp ; paramp = paramp->next)
|
||||
{
|
||||
if (w_strcmp(name, paramp->paramname) == 0)
|
||||
warning2("Multiple definition of parameter %s for element %s",
|
||||
name,
|
||||
thisrule) ;
|
||||
last = paramp ;
|
||||
}
|
||||
newpar = (PARAMETER *) m_malloc(sizeof(PARAMETER), "parameter") ;
|
||||
if (! plist)
|
||||
plist = newpar ;
|
||||
else
|
||||
last->next = newpar ;
|
||||
*nextpar = newpar ;
|
||||
nextpar = &newpar->nextptr ;
|
||||
*nextpar = NULL ;
|
||||
newpar->next = NULL ;
|
||||
newpar->deftype = NULLDEF ;
|
||||
newpar->defval = M_NULLVAL ;
|
||||
newpar->defstring = NULL ;
|
||||
newpar->kwlist = M_NULLVAL ;
|
||||
length = w_strlen(name) + 1 ;
|
||||
pnamelen += length ;
|
||||
newpar->paramname = (M_WCHAR *) m_malloc(length, "parameter name") ;
|
||||
w_strcpy(newpar->paramname, name) ;
|
||||
newpar->ptypep = NULL ;
|
||||
}
|
||||
|
||||
|
||||
/* Check that specified default value is legal parameter value */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL checkdefault( const M_WCHAR *string )
|
||||
#else
|
||||
LOGICAL checkdefault(string)
|
||||
M_WCHAR *string ;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
const M_WCHAR *p ;
|
||||
int len ;
|
||||
LOGICAL first ;
|
||||
|
||||
if (newpar->type == CDATA) return(TRUE) ;
|
||||
if (m_allwhite(string)) return(FALSE) ;
|
||||
|
||||
first = TRUE ;
|
||||
switch (newpar->type)
|
||||
{
|
||||
case IDREF:
|
||||
case NAMETYPE:
|
||||
case ENTATT:
|
||||
case NMTOKEN:
|
||||
case NUMBER:
|
||||
case NUTOKEN:
|
||||
/* Check length of default */
|
||||
if (w_strlen(string) > M_NAMELEN) return(FALSE) ;
|
||||
|
||||
for (p = string ; *p ; p++)
|
||||
{
|
||||
if (m_cttype(*p) == M_NONNAME) return(FALSE) ;
|
||||
else if (first || newpar->type == NUMBER)
|
||||
switch (newpar->type)
|
||||
{
|
||||
case IDREF:
|
||||
case NAMETYPE:
|
||||
case ENTATT:
|
||||
if (m_cttype(*p) != M_NMSTART) return(FALSE) ;
|
||||
break ;
|
||||
case NUMBER:
|
||||
case NUTOKEN:
|
||||
if (m_cttype(*p) != M_DIGIT) return(FALSE) ;
|
||||
break ;
|
||||
}
|
||||
first = FALSE ;
|
||||
}
|
||||
return(TRUE) ;
|
||||
case IDREFS:
|
||||
case NAMES:
|
||||
case NMTOKENS:
|
||||
case NUMBERS:
|
||||
case NUTOKENS:
|
||||
len = 1 ;
|
||||
for (p = string ; *p ; p++)
|
||||
{
|
||||
if (m_cttype(*p) == M_NONNAME)
|
||||
{
|
||||
if (! m_whitespace(*p)) return(FALSE) ;
|
||||
len = 1 ;
|
||||
}
|
||||
else if (len == 1)
|
||||
switch (newpar->type)
|
||||
{
|
||||
case IDREFS:
|
||||
case NAMES:
|
||||
if (m_cttype(*p) != M_NMSTART) return(FALSE) ;
|
||||
break ;
|
||||
case NUMBERS:
|
||||
case NUTOKENS:
|
||||
if (m_cttype(*p) != M_DIGIT) return(FALSE) ;
|
||||
break ;
|
||||
}
|
||||
else if (newpar->type == NUMBERS &&
|
||||
m_cttype(*p) != M_DIGIT) return(FALSE) ;
|
||||
if (len++ > M_NAMELEN) return(FALSE) ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Normalize parameter default. Change tabs and RE's to spaces, capitalize
|
||||
all letters (unless type is CDATA), remove extra space in lists */
|
||||
#if defined(M_PROTO)
|
||||
void normdefault(M_WCHAR *string )
|
||||
#else
|
||||
void normdefault(string)
|
||||
M_WCHAR *string ;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
M_WCHAR *p, *q ;
|
||||
int i ;
|
||||
|
||||
switch (newpar->type)
|
||||
{
|
||||
case IDREF:
|
||||
case NAMETYPE:
|
||||
case NMTOKEN:
|
||||
case NUTOKEN:
|
||||
case ENTATT:
|
||||
for ( ; *string ; string++)
|
||||
*string = m_ctupper(*string) ;
|
||||
return ;
|
||||
case IDREFS:
|
||||
case NAMES:
|
||||
case NMTOKENS:
|
||||
case NUTOKENS:
|
||||
case NUMBERS:
|
||||
/* Remove leading spaces */
|
||||
for (p = string; *p ; p++)
|
||||
if (! m_whitespace(*p)) break ;
|
||||
w_strcpy(string, p) ;
|
||||
|
||||
/* Capitalize and normalize white space */
|
||||
for (p = string, i = 0 ; *p ; p++, i++)
|
||||
if (m_whitespace(*p))
|
||||
{
|
||||
mbtowc(p, " ", 1);
|
||||
for (q = p + 1 ; m_whitespace(*q); q++) ;
|
||||
w_strcpy(p + 1, q) ;
|
||||
}
|
||||
else
|
||||
*p = m_ctupper(*p) ;
|
||||
|
||||
if (i && m_whitespace(string[i - 1])) string[i - 1] = M_EOS ;
|
||||
return ;
|
||||
|
||||
default:
|
||||
for ( ; *string ; string++)
|
||||
{
|
||||
char mbyte[32]; /* bigger than the biggest multibyte char */
|
||||
int length;
|
||||
|
||||
length = wctomb(mbyte, *string);
|
||||
if (length < 0)
|
||||
{
|
||||
m_error("Invalid wide character seen");
|
||||
mbyte[0] = ' ';
|
||||
mbyte[1] = 0;
|
||||
}
|
||||
if ((length == 1) && (*mbyte == '\n' || *mbyte == '\t'))
|
||||
mbtowc(string, " ", 1);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Called at end of parameter attribute list rule */
|
||||
void prulend(M_NOPAR)
|
||||
{
|
||||
LHS *lhsp ;
|
||||
LHS *discard ;
|
||||
|
||||
if (pcount > maxpar) maxpar = pcount ;
|
||||
for (lhsp = lhs ; lhsp ; )
|
||||
{
|
||||
if (lhsp->elt->parptr)
|
||||
m_err1(
|
||||
"Program error: prulend for %s, element with predefined parameters",
|
||||
lhsp->elt->enptr) ;
|
||||
lhsp->elt->parptr = plist ;
|
||||
lhsp->elt->paramcount = pcount ;
|
||||
lhsp->elt->parindex = parcount - pcount + 1 ;
|
||||
discard = lhsp ;
|
||||
lhsp = lhsp->next ;
|
||||
m_free((M_POINTER) discard, "lhs") ;
|
||||
}
|
||||
ruleinit() ;
|
||||
}
|
||||
|
||||
/* Make string the default for the current parameter of the current element */
|
||||
#if defined(M_PROTO)
|
||||
void setdefault(const M_WCHAR *string)
|
||||
#else
|
||||
void setdefault()
|
||||
M_WCHAR *string;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
PTYPE *kw ;
|
||||
int keycount ;
|
||||
int length ;
|
||||
|
||||
/* Process default for non-keyword parameter*/
|
||||
if (newpar->type != GRPO)
|
||||
{
|
||||
/* First check it is a legitimate value */
|
||||
if (! checkdefault(string))
|
||||
{
|
||||
m_err2("\"%s\": Not a valid default value for parameter %s",
|
||||
string,
|
||||
newpar->paramname) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
length = w_strlen(string) + 1 ;
|
||||
newpar->defstring = (M_WCHAR *) m_malloc(length, "default") ;
|
||||
w_strcpy(newpar->defstring, string) ;
|
||||
deflen += length ;
|
||||
|
||||
/* Value is valid. Change tabs and RE's to spaces, if value is not
|
||||
CDATA, put it in all caps, remove extra white space. */
|
||||
normdefault(newpar->defstring) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It is a keyword parameter, store a pointer to the value */
|
||||
for (kw = newpar->ptypep ; kw ; kw = kw->nextptr)
|
||||
{
|
||||
if (! m_wcupstrcmp(string, kw->keyword))
|
||||
{
|
||||
for (keycount = 0 ; kw ; kw = kw->nextptr)
|
||||
keycount += w_strlen(kw->keyword) + 1 ;
|
||||
newpar->defval = kwlen - keycount + 1;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
m_err2("Invalid default: %s not a valid value for %s",
|
||||
string,
|
||||
newpar->paramname) ;
|
||||
}
|
||||
}
|
||||
592
cde/programs/dthelp/parser/pass2/build/proto.h
Normal file
592
cde/programs/dthelp/parser/pass2/build/proto.h
Normal file
@@ -0,0 +1,592 @@
|
||||
/* $XConsortium: proto.h /main/3 1995/11/08 10:43:37 rswiston $ */
|
||||
/*
|
||||
Copyright (c) 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Proto.h contains function prototypes for program BUILD. */
|
||||
|
||||
|
||||
int addarc(
|
||||
#if defined(M_PROTO)
|
||||
STATE *from, STATE *to, ELTSTRUCT *label, ANDGROUP *and, LOGICAL optional,
|
||||
int id, LOGICAL minim, ELTSTRUCT **errelt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void adddefent(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *mapname
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL addent(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *name
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void addex(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void addkeyword(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL addmapname(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p, LOGICAL define
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void addndent(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void addpar(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void addsref(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_allwhite(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void checkand(
|
||||
#if defined(M_PROTO)
|
||||
ANDGROUP *andstart, ANDGROUP *andptr, STATE *start, TREE *root,
|
||||
ELTSTRUCT **errelt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL checkdefault(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int checkdfsa(
|
||||
#if defined(M_PROTO)
|
||||
STATE *from, ELTSTRUCT *label, ANDGROUP *and, int id, ELTSTRUCT **errelt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int checkrepeat(
|
||||
#if defined(M_PROTO)
|
||||
STATE *from, ANDGROUP *and, ELTSTRUCT **errelt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void copyintolist(
|
||||
#if defined(M_PROTO)
|
||||
STATELIST *from, STATELIST **to
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void countdown(
|
||||
#if defined(M_PROTO)
|
||||
M_TRIE *parent, int *count
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void defmapname(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *deftype(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dellist(
|
||||
#if defined(M_PROTO)
|
||||
STATELIST **list
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void delstartarcs(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void done(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumpentnode(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, M_TRIE *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumpmapnode(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, M_TRIE *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumpsrefnode(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file,
|
||||
M_TRIE *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumpptrie(
|
||||
#if defined(M_PROTO)
|
||||
M_TRIE *intname, char *extname, FILE *file, char *externdef, char *defdef,
|
||||
void (*proc)( FILE *, M_TRIE *)
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_dumptrie(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file,
|
||||
M_TRIE *xtrie,
|
||||
char *extname,
|
||||
int *count,
|
||||
void (*proc)(M_ENTITY *)
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void eltblocks(
|
||||
#if defined(M_PROTO)
|
||||
FILE *tempfile
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void eltreeout(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void endmodel(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void entout(
|
||||
#if defined(M_PROTO)
|
||||
char *fname
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *enttype(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_error(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err1(
|
||||
#if defined(M_PROTO)
|
||||
const char *text, const M_WCHAR *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_mberr1(
|
||||
#if defined(M_PROTO)
|
||||
char *text, const char *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err2(
|
||||
#if defined(M_PROTO)
|
||||
const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void exout(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_free(
|
||||
#if defined(M_PROTO)
|
||||
void *block, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void freetree(
|
||||
#if defined(M_PROTO)
|
||||
TREE *ruletree
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void found(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *flag, char *delim
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void fsa(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int getachar(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
ANDGROUP *getand(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL getname(
|
||||
#if defined(M_PROTO)
|
||||
int first
|
||||
#endif
|
||||
) ;
|
||||
|
||||
STATE *getstate(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int gettoken(
|
||||
#if defined(M_PROTO)
|
||||
int *c, int context
|
||||
#endif
|
||||
) ;
|
||||
|
||||
TREE *gettreenode(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_initctype(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void initialize(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL litproc(
|
||||
#if defined(M_PROTO)
|
||||
int delim
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void main(
|
||||
#if defined(M_PROTO)
|
||||
int argc, char **argv
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void makeand(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *canbenull, TREE *root, int optional
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL makefsa(
|
||||
#if defined(M_PROTO)
|
||||
TREE *root, int optional
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void makeor(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *canbenull, TREE *root
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void makeseq(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *canbenull, TREE *root, int optional
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_malloc(
|
||||
#if defined(M_PROTO)
|
||||
int size, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void msgline(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void msg1line(
|
||||
#if defined(M_PROTO)
|
||||
char *text, char *arg1
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void nondeterm(
|
||||
#if defined(M_PROTO)
|
||||
TREE *root, int c, ELTSTRUCT *eltp
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void normdefault(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL notinlist(
|
||||
#if defined(M_PROTO)
|
||||
STATELIST *item, STATELIST *list
|
||||
#endif
|
||||
) ;
|
||||
|
||||
ELTSTRUCT *ntrelt(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_openchk(
|
||||
#if defined(M_PROTO)
|
||||
FILE **ptr, char *name, char *mode
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void parout(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *partype(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL permitspcd(
|
||||
#if defined(M_PROTO)
|
||||
ARC *a
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void pop(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void prulend(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void push(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL regenerate(
|
||||
#if defined(M_PROTO)
|
||||
TREE *start, TREE *stop
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void repeat(
|
||||
#if defined(M_PROTO)
|
||||
TREE *root
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void ruleinit(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void rulend(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL samelabelarc(
|
||||
#if defined(M_PROTO)
|
||||
ARC *a, STATE *s
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void savelhs(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL param
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void savestartarcs(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int scan(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void setdefault(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void simplebranch(
|
||||
#if defined(M_PROTO)
|
||||
TREE *root, ELTSTRUCT *value, ANDGROUP *group, int optional
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void skiptoend(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_sprscon(
|
||||
#if defined(M_PROTO)
|
||||
int i, int j
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void srefout(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
STATE *startfsa(
|
||||
#if defined(M_PROTO)
|
||||
TREE *root, LOGICAL *canbenull
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void tempelt(
|
||||
#if defined(M_PROTO)
|
||||
ELTSTRUCT *eltp, FILE *tempfile
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void template(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *typecon(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void undodelim(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *delim
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void ungetachar(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_wcupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *p, const M_WCHAR *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_wcmbupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *p, const char *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_mbmbupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const char *p, const char *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning1(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning2(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning3(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning4(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_whitespace(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
152
cde/programs/dthelp/parser/pass2/build/scan.c
Normal file
152
cde/programs/dthelp/parser/pass2/build/scan.c
Normal file
@@ -0,0 +1,152 @@
|
||||
/* $XConsortium: scan.c /main/3 1995/11/08 10:43:54 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Scan.c contains scanner procedures for program BUILD */
|
||||
|
||||
#include <string.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "build.h"
|
||||
#define M_CONDEF
|
||||
#include "context.h"
|
||||
#define M_DELIMDEF
|
||||
#include "delim.h"
|
||||
#include "sref.h"
|
||||
|
||||
/* Reads a name */
|
||||
LOGICAL getname(first)
|
||||
int first;
|
||||
{
|
||||
M_WCHAR *p;
|
||||
int c;
|
||||
|
||||
*(p = name) = first;
|
||||
if ((curcon != DEFAULT && curcon != DEFVAL &&
|
||||
curcon != DEFAULT2 && curcon != DEF2VAL) ||
|
||||
newpar->type != CDATA)
|
||||
*p = m_ctupper(*p);
|
||||
while (TRUE)
|
||||
{
|
||||
c = getachar();
|
||||
*++p = (M_WCHAR) c;
|
||||
if (m_cttype(*p) == M_NONNAME) break;
|
||||
if (p >= name + M_NAMELEN)
|
||||
{
|
||||
*(name + M_NAMELEN) = M_EOS;
|
||||
m_error("Name too long");
|
||||
return(FALSE);
|
||||
}
|
||||
if ((curcon != DEFAULT && curcon != DEFVAL &&
|
||||
curcon != DEFAULT2 && curcon != DEF2VAL) ||
|
||||
newpar->type != CDATA)
|
||||
*p = m_ctupper(*p);
|
||||
}
|
||||
ungetachar(c);
|
||||
*p = M_EOS;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* Returns the next token to the main procedure */
|
||||
int scan(M_NOPAR)
|
||||
{
|
||||
int c;
|
||||
int n;
|
||||
M_WCHAR wsp, wnl, wtb;
|
||||
|
||||
mbtowc(&wsp, " ", 1);
|
||||
mbtowc(&wnl, "\n", 1);
|
||||
mbtowc(&wtb, "\t", 1);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
if (! m_newcon(curcon - 1, TEXT - 1))
|
||||
{
|
||||
while ((n = gettoken(&c, COMCON)) == COMMENT)
|
||||
while ((n = gettoken(&c, COMCON)) != COMMENT)
|
||||
if (c == EOF)
|
||||
{
|
||||
m_error("EOF occurred within comment");
|
||||
exit(ERREXIT);
|
||||
}
|
||||
ungetachar(c);
|
||||
}
|
||||
n = gettoken(&c, curcon);
|
||||
if (n)
|
||||
{
|
||||
if (n != LIT && n != LITA) return(n);
|
||||
if (litproc(n))
|
||||
{
|
||||
if (scantrace)
|
||||
{
|
||||
char *mb_literal;
|
||||
|
||||
mb_literal = MakeMByteString(literal);
|
||||
printf("literal '%s'\n", mb_literal);
|
||||
m_free(mb_literal, "multibyte string");
|
||||
}
|
||||
return(LITERAL);
|
||||
}
|
||||
/* Litproc returns FALSE in case of error, when returned have
|
||||
scanned to the end of erroneous rule */
|
||||
else continue;
|
||||
}
|
||||
if (c == wsp || c == wnl || c == wtb)
|
||||
{
|
||||
if (m_newcon(curcon - 1, TEXT - 1))
|
||||
{
|
||||
scanval = (M_WCHAR) c;
|
||||
return(TEXT);
|
||||
}
|
||||
else continue;
|
||||
}
|
||||
if (m_newcon(curcon - 1, NAME - 1))
|
||||
if (m_cttype(c) == M_NMSTART ||
|
||||
(m_cttype(c) != M_NONNAME &&
|
||||
(curcon == DEFAULT || curcon == DEFVAL || curcon == NTNAME ||
|
||||
curcon == DEFAULT2 || curcon == DEF2VAL || curcon == NT2NAME
|
||||
))
|
||||
)
|
||||
{
|
||||
if (getname(c))
|
||||
{
|
||||
if (scantrace)
|
||||
{
|
||||
char *mb_name;
|
||||
|
||||
mb_name = MakeMByteString(name);
|
||||
printf("name '%s'\n", mb_name);
|
||||
m_free(mb_name, "multibyte string");
|
||||
}
|
||||
return(NAME);
|
||||
}
|
||||
else continue;
|
||||
}
|
||||
if (c == EOF) return(ENDFILE);
|
||||
if (m_newcon(curcon - 1, TEXT - 1))
|
||||
{
|
||||
scanval = (M_WCHAR) c;
|
||||
return(TEXT);
|
||||
}
|
||||
if (curcon != ERROR)
|
||||
{
|
||||
char mbyte[32]; /* bigger than the biggest multibyte char */
|
||||
|
||||
wctomb(mbyte, c);
|
||||
|
||||
fprintf(stderr, "\n'%s' (%d)", mbyte, c);
|
||||
fprintf(m_errfile, "\n'%s' (%d)", mbyte, c);
|
||||
m_error("Unexpected character");
|
||||
}
|
||||
} /* End while */
|
||||
} /* End scan */
|
||||
|
||||
#include "scanutil.c"
|
||||
|
||||
#if defined(sparse)
|
||||
#include "sparse.c"
|
||||
#endif
|
||||
188
cde/programs/dthelp/parser/pass2/build/sref.c
Normal file
188
cde/programs/dthelp/parser/pass2/build/sref.c
Normal file
@@ -0,0 +1,188 @@
|
||||
/* $XConsortium: sref.c /main/3 1995/11/08 10:44:07 rswiston $ */
|
||||
/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Sref.c contains procedures related to short reference map declarations */
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "build.h"
|
||||
#include "sref.h"
|
||||
#include "entdef.h"
|
||||
|
||||
static M_WCHAR *wc_prefix = NULL;
|
||||
|
||||
/* Add an entity with the default name constructed by adding a suffix
|
||||
to the name of the short reference map in which it is invoked, and
|
||||
a prefix m- */
|
||||
void adddefent(mapname)
|
||||
M_WCHAR *mapname;
|
||||
{
|
||||
M_WCHAR *p;
|
||||
int n, length;
|
||||
char c;
|
||||
|
||||
if (!wc_prefix)
|
||||
{
|
||||
wc_prefix = MakeWideCharString(M_PREFIX);
|
||||
w_strcpy(genname, wc_prefix);
|
||||
}
|
||||
|
||||
w_strcpy(&genname[w_strlen(wc_prefix)], mapname);
|
||||
p = &genname[w_strlen(genname)];
|
||||
for (n = egensuf ; n ; n /= 10)
|
||||
{
|
||||
if (p - genname > M_NAMELEN)
|
||||
{
|
||||
m_err1("Entity name based on %s too long", mapname);
|
||||
return;
|
||||
}
|
||||
c = ('0' + (n % 10));
|
||||
mbtowc(p, &c, 1);
|
||||
*p++;
|
||||
}
|
||||
*p = M_EOS;
|
||||
egensuf++;
|
||||
if (! addent(genname))
|
||||
{
|
||||
m_err1("Default entity name %s already in use", genname);
|
||||
return;
|
||||
}
|
||||
thissref->entidx = entity->index;
|
||||
}
|
||||
|
||||
/* Add an entity, return FALSE if already there, TRUE if adding it.
|
||||
Pointer to the entity structure is in global M_STRUCT *entity. */
|
||||
LOGICAL addent(name)
|
||||
M_WCHAR *name;
|
||||
{
|
||||
M_ENTITY *new;
|
||||
|
||||
new = (M_ENTITY *) m_malloc(sizeof(M_ENTITY), "entity");
|
||||
if (entity = (M_ENTITY *) m_ntrtrie(name, m_enttrie, (M_TRIE *) new))
|
||||
{
|
||||
m_free((M_POINTER) new, "entity");
|
||||
return(FALSE);
|
||||
}
|
||||
entity = new;
|
||||
if (lastent) lastent->next = entity;
|
||||
else firstent = entity;
|
||||
lastent = entity;
|
||||
entity->type = M_GENERAL;
|
||||
entity->wheredef = FALSE;
|
||||
entity->content = NULL;
|
||||
entity->name = (M_WCHAR *) m_malloc(w_strlen(name) + 1, "entity name");
|
||||
entity->index = ++m_entcnt;
|
||||
entity->next = NULL;
|
||||
w_strcpy(entity->name, name);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* Add a short reference map name */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL addmapname(M_WCHAR* p, LOGICAL define)
|
||||
#else
|
||||
LOGICAL addmapname(p, define)
|
||||
M_WCHAR *p;
|
||||
LOGICAL define;
|
||||
#endif
|
||||
{
|
||||
MAP *old;
|
||||
MAP *new;
|
||||
LOGICAL retval;
|
||||
|
||||
new = (MAP *) m_malloc(sizeof(MAP), "map");
|
||||
if (old = (MAP *) m_ntrtrie(p, &maptree, (M_TRIE *) new))
|
||||
{
|
||||
m_free(new, "map");
|
||||
curmap = old->map;
|
||||
retval = old->defined;
|
||||
if (define) old->defined = TRUE;
|
||||
return((LOGICAL) (retval ? FALSE : TRUE));
|
||||
}
|
||||
curmap = ++mapcnt;
|
||||
new->map = mapcnt;
|
||||
new->mapname = (M_WCHAR *) m_malloc(w_strlen(p) + 1, "map name");
|
||||
w_strcpy(new->mapname, p);
|
||||
new->defined = define;
|
||||
new->nextptr = NULL;
|
||||
*nextmap = new;
|
||||
nextmap = &new->nextptr;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* Add a named entity to a short reference map */
|
||||
void addndent(p)
|
||||
M_WCHAR *p;
|
||||
{
|
||||
addent(p);
|
||||
thissref->entidx = entity->index;
|
||||
}
|
||||
|
||||
/* Add a short reference delimiter */
|
||||
void addsref(p)
|
||||
M_WCHAR *p;
|
||||
{
|
||||
SREFSTRUCT *delim;
|
||||
SREFSTRUCT *prevsr;
|
||||
M_WCHAR *q;
|
||||
M_WCHAR c;
|
||||
int noseq = 0;
|
||||
|
||||
/* Define the delimiter */
|
||||
delim = (SREFSTRUCT *)
|
||||
m_malloc(sizeof(SREFSTRUCT), "short reference delimiter");
|
||||
if (prevsr = (SREFSTRUCT *) m_ntrtrie(p, &sreftree, (M_TRIE *) delim))
|
||||
{
|
||||
m_free(delim, "short reference delimiter");
|
||||
delim = prevsr;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (q = p ; *q ; q++)
|
||||
{
|
||||
c = m_ctupper(*q);
|
||||
if (m_cttype(c) == M_NMSTART)
|
||||
{
|
||||
if (c != BLANKSEQ && c != WSSEQ && c != RS)
|
||||
{
|
||||
m_free(delim, "short reference delimiter");
|
||||
m_err1(
|
||||
"Letters not permitted in short reference delimiters: %s",
|
||||
p);
|
||||
return;
|
||||
}
|
||||
if (c != RS) noseq++;
|
||||
}
|
||||
}
|
||||
if (w_strlen(p) > maxsr) maxsr = w_strlen(p);
|
||||
if (noseq > maxseq) maxseq = noseq;
|
||||
delim->srefcnt = ++sreflen;
|
||||
*nextsref = delim;
|
||||
nextsref = &delim->next;
|
||||
delim->next = NULL;
|
||||
delim->data = NULL;
|
||||
}
|
||||
|
||||
/* Add the delimiter to this map and prepare for the associated
|
||||
entity */
|
||||
thissref = (SREFDATA *)
|
||||
m_malloc(sizeof(SREFDATA), "short reference delimiter");
|
||||
thissref->map = curmap;
|
||||
thissref->entidx = M_NULLVAL;
|
||||
thissref->next = delim->data;
|
||||
delim->data = thissref;
|
||||
}
|
||||
|
||||
/* Prefix left-hand side with "M-" to create default short reference map
|
||||
name, truncating to M_NAMELEN characters if necessary */
|
||||
void defmapname(M_NOPAR)
|
||||
{
|
||||
if (!wc_prefix)
|
||||
{
|
||||
wc_prefix = MakeWideCharString(M_PREFIX);
|
||||
w_strcpy(genname, wc_prefix);
|
||||
}
|
||||
|
||||
w_strcpy(&genname[w_strlen(wc_prefix)], thisrule);
|
||||
genname[M_NAMELEN] = M_EOS;
|
||||
}
|
||||
52
cde/programs/dthelp/parser/pass2/build/tree.c
Normal file
52
cde/programs/dthelp/parser/pass2/build/tree.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/* $XConsortium: tree.c /main/3 1995/11/08 10:44:17 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Tree.c has procedures used by BUILD to construct the tree representation
|
||||
of a content model */
|
||||
|
||||
#include <malloc.h>
|
||||
#include "build.h"
|
||||
#include "context.h"
|
||||
|
||||
/* Called after a right parenthesis is read while scanning a content model.
|
||||
Resets curcon if it is the outermost submodel. */
|
||||
void endmodel(M_NOPAR)
|
||||
{
|
||||
curtree = curtree->parent ;
|
||||
if (! curtree->parent) curcon = LASTM ;
|
||||
else if (curtree == curtree->parent->first) curcon = OCCUR ;
|
||||
}
|
||||
|
||||
/* Release storage used for the tree representation of a rule */
|
||||
void freetree(treep)
|
||||
TREE *treep ;
|
||||
{
|
||||
TREE *child, *discard ;
|
||||
|
||||
for (child = treep->first ; child ; ) {
|
||||
discard = child->right ;
|
||||
freetree(child) ;
|
||||
child = discard ;
|
||||
}
|
||||
m_free((M_POINTER) treep, "tree node") ;
|
||||
}
|
||||
|
||||
/* Gettreenode obtains a node to use in the tree representation of a rule */
|
||||
TREE *gettreenode(M_NOPAR)
|
||||
{
|
||||
TREE *new ;
|
||||
|
||||
new = (TREE *) m_malloc(sizeof(TREE), "tree node") ;
|
||||
new->first = new->right = new->parent = NULL ;
|
||||
new->connector = new->occurrence = M_NULLVAL ;
|
||||
new->value = NULL ;
|
||||
new->terminal = FALSE ;
|
||||
new->minim = FALSE ;
|
||||
new->eltid = eltsinrule++ ;
|
||||
return(new) ;
|
||||
}
|
||||
|
||||
75
cde/programs/dthelp/parser/pass2/eltdef/Imakefile
Normal file
75
cde/programs/dthelp/parser/pass2/eltdef/Imakefile
Normal file
@@ -0,0 +1,75 @@
|
||||
XCOMM $XConsortium: Imakefile /main/3 1995/11/08 10:44:32 rswiston $
|
||||
/* eltdef Imakefile */
|
||||
|
||||
HTAG2 = ..
|
||||
HTAG2SRC = $(HTAG2)/htag2
|
||||
SDLPARSERSRC = $(HTAG2)/parser
|
||||
SDLELTDEFSRC = $(HTAG2)/eltdef
|
||||
SDLDTDFILE = $(HTAG2SRC)/sdl.dtd
|
||||
SDLUTILSRC = $(HTAG2)/util
|
||||
SDLBUILDSRC = $(HTAG2)/build
|
||||
SDLUTILLIB = $(HTAG2)/util/libutil.a
|
||||
SDLIFFILE = $(HTAG2SRC)/sdl.if
|
||||
|
||||
INCLUDES = -I. -I$(SDLUTILSRC) -I$(SDLBUILDSRC)
|
||||
|
||||
SRCS = eltdef.c eltutil.c entity.c scan.c
|
||||
|
||||
OBJS = eltdef.o eltutil.o entity.o scan.o
|
||||
|
||||
CCPRODS = case.c
|
||||
ECPRODS = efile.c entfile.c pfile.c sfile.c stfile.c tfile.c
|
||||
|
||||
CHPRODS = context.h delim.h
|
||||
EHPRODS = entity2.h globdec.h globdef.h if.h pval.h signon.h signonx.h
|
||||
|
||||
CPRODS = $(CCPRODS) $(CHPRODS)
|
||||
EPRODS = $(ECPRODS) $(EHPRODS)
|
||||
|
||||
CTRASH = delim.dat error
|
||||
ETRASH = estring.h error
|
||||
TRASH = delim.dat estring.h error
|
||||
|
||||
PRODUCTS = $(CPRODS) $(EPRODS)
|
||||
|
||||
LOCAL_LIBRARIES = $(SDLUTILLIB)
|
||||
LOCAL_INCLUDES = -I$(SDLUTILSRC)
|
||||
|
||||
/* Don't use shared libs for hp */
|
||||
#ifdef HPArchitecture
|
||||
#if OSMajorVersion > 7
|
||||
EXTRA_LOAD_FLAGS = -Wl,-a archive
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SunArchitecture
|
||||
.NO_PARALLEL:
|
||||
#endif
|
||||
|
||||
all:: $(PRODUCTS)
|
||||
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalProgramTarget(eltdef,$(OBJS),delim.h $(LOCAL_LIBRARIES),$(LOCAL_LIBRARIES),)
|
||||
|
||||
$(EPRODS): eltdef $(SDLIFFILE)
|
||||
$(RM) $(EPRODS) $(ETRASH)
|
||||
./eltdef $(SDLIFFILE)
|
||||
|
||||
$(CPRODS): $(SDLUTILSRC)/context $(HTAG2SRC)/delim.elt context.dat
|
||||
$(RM) $(CPRODS) $(CTRASH)
|
||||
/* get application-specific delim.dat */
|
||||
$(CP) $(HTAG2SRC)/delim.elt delim.dat
|
||||
$(SDLUTILSRC)/context
|
||||
|
||||
$(SDLUTILSRC)/context:
|
||||
cd $(SDLUTILSRC); make context
|
||||
|
||||
clean::
|
||||
$(RM) $(PRODUCTS) $(TRASH)
|
||||
|
||||
depend::
|
||||
|
||||
includes:: $(PRODUCTS)
|
||||
|
||||
DependTarget()
|
||||
722
cde/programs/dthelp/parser/pass2/eltdef/context.dat
Normal file
722
cde/programs/dthelp/parser/pass2/eltdef/context.dat
Normal file
@@ -0,0 +1,722 @@
|
||||
startcomment
|
||||
comcon:comcon {
|
||||
/* $XConsortium: context.dat /main/3 1995/07/17 19:52:49 lehors $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
|
||||
Context.dat defines the state transitions for program ELTDEF.
|
||||
*/
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
endcomment
|
||||
incom:incom
|
||||
;
|
||||
|
||||
entstart
|
||||
start:entdec
|
||||
error:entdec
|
||||
;
|
||||
|
||||
entsystem
|
||||
entval:typedec {enttype(M_SYSTEM) ;}
|
||||
;
|
||||
|
||||
entst
|
||||
entval:typedec {enttype(M_STARTTAG) ;}
|
||||
;
|
||||
|
||||
entet
|
||||
entval:typedec {enttype(M_ENDTAG) ;}
|
||||
;
|
||||
|
||||
entmd
|
||||
entval:typedec {enttype(M_MD) ;}
|
||||
;
|
||||
|
||||
entpi
|
||||
entval:piorsdata {enttype(M_PI) ;}
|
||||
;
|
||||
|
||||
entsdata
|
||||
entval:piorsdata {enttype(M_SDATA) ;}
|
||||
;
|
||||
|
||||
entcdata
|
||||
entval:typedec {enttype(M_CDATAENT) ;}
|
||||
;
|
||||
|
||||
typecode
|
||||
piorsdata:codetagc {
|
||||
entity->wheredef = M_DELTDEF ;
|
||||
enttype(entity->type == M_PI ? M_CODEPI : M_CODESDATA) ;
|
||||
entity->codeindex = ++codeent ;
|
||||
}
|
||||
;
|
||||
|
||||
endofcode
|
||||
inentc:start
|
||||
;
|
||||
|
||||
lit
|
||||
value:value,
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
lita
|
||||
value:value,
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
entlit
|
||||
entval:declitent,
|
||||
piorsdata:declitent,
|
||||
typedec:declitent {entclen = 0 ;}
|
||||
|
||||
declitent:postent,
|
||||
edeclitent:postent {
|
||||
entcontent[entclen] = M_EOS ;
|
||||
entity->content =
|
||||
(M_WCHAR *) m_malloc(entclen + 1, "entity content") ;
|
||||
w_strcpy(entity->content, entcontent) ;
|
||||
entity->wheredef = M_DELTDEF ;
|
||||
}
|
||||
;
|
||||
|
||||
entlita
|
||||
entval:declitaent,
|
||||
piorsdata:declitaent,
|
||||
typedec:declitaent {entclen = 0 ;}
|
||||
|
||||
declitaent:postent,
|
||||
edclitaent:postent {
|
||||
entcontent[entclen] = M_EOS ;
|
||||
entity->content =
|
||||
(M_WCHAR *) m_malloc(entclen + 1, "entity content") ;
|
||||
w_strcpy(entity->content, entcontent) ;
|
||||
entity->wheredef = M_DELTDEF ;
|
||||
}
|
||||
;
|
||||
|
||||
cro
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litrs
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litrsc
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litre
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litrec
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
littab
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
littabc
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litspace
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
litcspace
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
refc
|
||||
charent:charent
|
||||
;
|
||||
|
||||
signon
|
||||
start:insignon {restart = RSIGNON ;}
|
||||
error:insignon
|
||||
;
|
||||
|
||||
gdef
|
||||
start:globdef,
|
||||
insignon:globdef {
|
||||
endsignon() ;
|
||||
restart = RGLOBDEF ;
|
||||
/* fprintf(globdef, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
|
||||
error:globdef {
|
||||
endsignon() ;
|
||||
/* fprintf(globdef, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
gdec
|
||||
start:globdec,
|
||||
insignon:globdec {
|
||||
endsignon() ;
|
||||
restart = RGLOBDEC ;
|
||||
/* fprintf(globdec, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
globdef:globdec {
|
||||
restart = RGLOBDEC ;
|
||||
/* fprintf(globdec, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
|
||||
error:globdec {
|
||||
if (! signonend) endsignon() ;
|
||||
restart = RGLOBDEC ;
|
||||
/* fprintf(globdec, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
;
|
||||
|
||||
inisstring
|
||||
start:iniss,
|
||||
insignon:iniss {
|
||||
endsignon() ;
|
||||
gss = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
|
||||
inies:iniss {
|
||||
endstring() ;
|
||||
gss = stringcnt ;
|
||||
if (gss)
|
||||
m_error("Multiple specification of global start string") ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
|
||||
inisc:iniss,
|
||||
iniec:iniss,
|
||||
initc:iniss,
|
||||
inipc:iniss,
|
||||
inistc:iniss {
|
||||
if (gss)
|
||||
m_error("Multiple specification of global start string") ;
|
||||
gss = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
|
||||
globdef:iniss,
|
||||
globdec:iniss {
|
||||
gss = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
;
|
||||
|
||||
iniestring
|
||||
start:inies,
|
||||
insignon:inies {
|
||||
endsignon() ;
|
||||
ges = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
|
||||
iniss:inies {
|
||||
if (ges)
|
||||
m_error("Multiple specification of global end string") ;
|
||||
endstring() ;
|
||||
ges = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
|
||||
inisc:inies,
|
||||
iniec:inies,
|
||||
initc:inies,
|
||||
inipc:inies,
|
||||
inistc:inies {
|
||||
if (ges)
|
||||
m_error("Multiple specification of global end string") ;
|
||||
ges = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
|
||||
globdef:inies,
|
||||
globdec:inies {
|
||||
ges = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
;
|
||||
|
||||
inistring
|
||||
start:inistc,
|
||||
insignon:inistc {
|
||||
endsignon() ;
|
||||
/* fprintf(stfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
finistc = FALSE ;
|
||||
}
|
||||
|
||||
iniss:inistc,
|
||||
inies:inistc {
|
||||
finistc = FALSE ;
|
||||
endstring() ;
|
||||
if (! finistc)
|
||||
m_error("Multiple specification of global string code") ;
|
||||
}
|
||||
|
||||
iniec:inistc,
|
||||
initc:inistc,
|
||||
inipc:inistc,
|
||||
inisc:inistc {
|
||||
if (! finistc)
|
||||
m_error("Multiple specification of global string code") ;
|
||||
/* fprintf(stfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
finistc = FALSE ;
|
||||
}
|
||||
|
||||
globdef:inistc,
|
||||
globdec:inistc {
|
||||
finistc = FALSE ;
|
||||
/* fprintf(stfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
;
|
||||
|
||||
inistart
|
||||
start:inisc,
|
||||
insignon:inisc {
|
||||
endsignon() ;
|
||||
/* fprintf(sfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
|
||||
iniss:inisc,
|
||||
inies:inisc {endstring() ;}
|
||||
|
||||
iniec:inisc,
|
||||
initc:inisc,
|
||||
inipc:inisc,
|
||||
inistc:inisc,
|
||||
globdef:inisc,
|
||||
globdec:inisc {
|
||||
/* fprintf(sfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
;
|
||||
|
||||
iniend
|
||||
start:iniec,
|
||||
insignon:iniec {
|
||||
endsignon() ;
|
||||
/* fprintf(efile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
|
||||
iniss:iniec,
|
||||
inies:iniec {endstring() ;}
|
||||
|
||||
inisc:iniec,
|
||||
initc:iniec,
|
||||
inipc:iniec,
|
||||
inistc:iniec,
|
||||
globdef:iniec,
|
||||
globdec:iniec {
|
||||
/* fprintf(efile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
}
|
||||
;
|
||||
|
||||
initext
|
||||
start:initc,
|
||||
insignon:initc {
|
||||
endsignon() ;
|
||||
/* fprintf(tfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
finitext = FALSE ;
|
||||
}
|
||||
|
||||
iniss:initc,
|
||||
inies:initc {endstring() ;}
|
||||
|
||||
inisc:initc,
|
||||
iniec:initc,
|
||||
inipc:initc,
|
||||
inistc:initc,
|
||||
globdef:initc,
|
||||
globdec:initc {
|
||||
/* fprintf(tfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
finitext = FALSE ;
|
||||
}
|
||||
;
|
||||
|
||||
initpi
|
||||
start:inipc,
|
||||
insignon:inipc {
|
||||
endsignon() ;
|
||||
/* fprintf(pfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
finipi = FALSE ;
|
||||
}
|
||||
|
||||
iniss:inipc,
|
||||
inies:inipc {endstring() ;}
|
||||
|
||||
inisc:inipc,
|
||||
iniec:inipc,
|
||||
initc:inipc,
|
||||
inistc:inipc,
|
||||
globdef:inipc,
|
||||
globdec:inipc {
|
||||
/* fprintf(pfile, "#line %d \"%s\"\n", m_line, iffile) ; */
|
||||
finipi = FALSE ;
|
||||
}
|
||||
;
|
||||
|
||||
elt
|
||||
start:needn,
|
||||
insignon:needn {
|
||||
endsignon() ;
|
||||
endini() ;
|
||||
}
|
||||
|
||||
inelt:needn
|
||||
|
||||
globdef:needn,
|
||||
globdec:needn,
|
||||
inisc:needn,
|
||||
iniec:needn,
|
||||
initc:needn,
|
||||
inipc:needn {endini() ;}
|
||||
|
||||
inss:needn,
|
||||
ines:needn {endstring() ;}
|
||||
|
||||
insc:needn
|
||||
inec:needn
|
||||
intc:needn
|
||||
inpc:needn
|
||||
instc:needn
|
||||
inparam:needn
|
||||
preparam:needn
|
||||
error:needn
|
||||
;
|
||||
|
||||
tagc
|
||||
postent:start
|
||||
codetagc:inentc {
|
||||
startcode(entity->codeindex, &inent, entfile,
|
||||
"c", nopar, nopar, "") ;
|
||||
}
|
||||
close:preparam
|
||||
sschain:inss {
|
||||
*getaction(starray) = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
eschain:ines {
|
||||
*getaction(etarray) = stringcnt ;
|
||||
instring = TRUE ;
|
||||
}
|
||||
pcchain:inpc {
|
||||
*getaction(pcarray) = ++pactions ;
|
||||
startcode(pactions, &inpc, pfile, "p", pproto, pformal, pftype) ;
|
||||
}
|
||||
tcchain:intc {
|
||||
*getaction(tcarray) = ++tactions ;
|
||||
startcode(tactions, &intext, tfile, "t", tproto, tformal,
|
||||
tftype) ;
|
||||
}
|
||||
scchain:insc {
|
||||
*getaction(scarray) = ++sactions ;
|
||||
startcode(sactions, &insc, sfile, "s", nopar, nopar, "") ;
|
||||
}
|
||||
ecchain:inec {
|
||||
*getaction(ecarray) = ++eactions ;
|
||||
startcode(eactions, &inec, efile, "e", nopar, nopar, "") ;
|
||||
}
|
||||
stcchain:instc {
|
||||
*getaction(stcarray) = ++stactions ;
|
||||
startcode(stactions, &instc, stfile, "st", stproto, stformal,
|
||||
stft) ;
|
||||
}
|
||||
;
|
||||
|
||||
sep
|
||||
sschain:sschain {*getaction(starray) = stringcnt ;}
|
||||
eschain:eschain {*getaction(etarray) = stringcnt ;}
|
||||
pcchain:pcchain {*getaction(pcarray) = pactions + 1 ;}
|
||||
tcchain:tcchain {*getaction(tcarray) = tactions + 1 ;}
|
||||
scchain:scchain {*getaction(scarray) = sactions + 1 ;}
|
||||
ecchain:ecchain {*getaction(ecarray) = eactions + 1 ;}
|
||||
stcchain:stcchain {*getaction(stcarray) = stactions + 1 ;}
|
||||
postvalue:invalue
|
||||
;
|
||||
|
||||
param
|
||||
preparam:inparam
|
||||
;
|
||||
|
||||
vi
|
||||
cvar:pname
|
||||
cvalue:value
|
||||
;
|
||||
|
||||
rend
|
||||
postpname:inparam
|
||||
;
|
||||
|
||||
grpo
|
||||
postpname:invalue
|
||||
;
|
||||
|
||||
grpc
|
||||
invalue:postpname
|
||||
postvalue:postpname
|
||||
;
|
||||
|
||||
|
||||
sss
|
||||
inelt:sschain
|
||||
inss:sschain,
|
||||
ines:sschain {endstring() ;}
|
||||
|
||||
inpc:sschain
|
||||
intc:sschain
|
||||
insc:sschain
|
||||
inec:sschain
|
||||
instc:sschain
|
||||
inparam:sschain
|
||||
preparam:sschain
|
||||
;
|
||||
|
||||
ess
|
||||
iniss:inisc,
|
||||
inss:inelt {endstring() ;}
|
||||
;
|
||||
|
||||
ses
|
||||
inelt:eschain
|
||||
inss:eschain,
|
||||
ines:eschain {endstring() ;}
|
||||
|
||||
inpc:eschain
|
||||
intc:eschain
|
||||
insc:eschain
|
||||
inec:eschain
|
||||
instc:eschain
|
||||
inparam:eschain
|
||||
preparam:eschain
|
||||
;
|
||||
|
||||
ees
|
||||
inies:inisc,
|
||||
ines:inelt {endstring() ;}
|
||||
;
|
||||
|
||||
scode
|
||||
inss:scchain,
|
||||
ines:scchain {endstring() ;}
|
||||
|
||||
inparam:scchain
|
||||
inelt:scchain
|
||||
inpc:scchain
|
||||
intc:scchain
|
||||
insc:scchain
|
||||
inec:scchain
|
||||
instc:scchain
|
||||
preparam:scchain
|
||||
;
|
||||
|
||||
ecode
|
||||
inss:ecchain,
|
||||
ines:ecchain {endstring() ;}
|
||||
|
||||
insc:ecchain
|
||||
inparam:ecchain
|
||||
inelt:ecchain
|
||||
inec:ecchain
|
||||
intc:ecchain
|
||||
inpc:ecchain
|
||||
instc:eschain
|
||||
preparam:ecchain
|
||||
;
|
||||
|
||||
tcode
|
||||
inss:tcchain,
|
||||
ines:tcchain {endstring() ;}
|
||||
|
||||
insc:tcchain
|
||||
inec:tcchain
|
||||
inparam:tcchain
|
||||
inelt:tcchain
|
||||
preparam:tcchain
|
||||
inpc:tcchain
|
||||
intc:tcchain
|
||||
instc:tcchain
|
||||
;
|
||||
|
||||
pcode
|
||||
inelt:pcchain
|
||||
preparam:pcchain
|
||||
inparam:pcchain
|
||||
inss:pcchain,
|
||||
ines:pcchain {endstring() ;}
|
||||
inpc:pcchain
|
||||
intc:pcchain
|
||||
insc:pcchain
|
||||
inec:pcchain
|
||||
instc:pcchain
|
||||
;
|
||||
|
||||
stcode
|
||||
inelt:stcchain
|
||||
preparam:stcchain
|
||||
inparam:stcchain
|
||||
inss:stcchain,
|
||||
ines:stcchain {endstring() ;}
|
||||
|
||||
inpc:stcchain
|
||||
intc:stcchain
|
||||
insc:stcchain
|
||||
inec:stcchain
|
||||
instc:stcchain
|
||||
;
|
||||
|
||||
endfile
|
||||
start:finish,
|
||||
insignon:finish {
|
||||
endsignon() ;
|
||||
endini() ;
|
||||
}
|
||||
|
||||
globdef:finish,
|
||||
globdec:finish,
|
||||
inistc:finish,
|
||||
inisc:finish,
|
||||
iniec:finish,
|
||||
initc:finish,
|
||||
inipc:finish {endini() ;}
|
||||
;
|
||||
|
||||
wildcard
|
||||
stcchain:stcchain,
|
||||
sschain:sschain,
|
||||
eschain:eschain,
|
||||
scchain:scchain,
|
||||
ecchain:ecchain,
|
||||
tcchain:tcchain,
|
||||
pcchain:pcchain {
|
||||
*nextchain = (CHAIN *) m_malloc(sizeof(CHAIN), "chain") ;
|
||||
(*nextchain)->elt = 1 ;
|
||||
(*nextchain)->next = NULL ;
|
||||
nextchain = &(*nextchain)->next ;
|
||||
}
|
||||
;
|
||||
|
||||
literal
|
||||
value:postvalue {value(literal) ;}
|
||||
;
|
||||
|
||||
name
|
||||
needn:close {startelement() ;}
|
||||
inparam:cvar {storecvar() ;}
|
||||
pname:postpname {storepname() ;}
|
||||
invalue:cvalue {cvalue() ;}
|
||||
value:postvalue {value(name) ;}
|
||||
entdec:entval {addent() ;}
|
||||
|
||||
stcchain:stcchain,
|
||||
sschain:sschain,
|
||||
eschain:eschain,
|
||||
scchain:scchain,
|
||||
ecchain:ecchain,
|
||||
tcchain:tcchain,
|
||||
pcchain:pcchain {
|
||||
*nextchain = (CHAIN *) m_malloc(sizeof(CHAIN), "chain") ;
|
||||
(*nextchain)->next = NULL ;
|
||||
if ((*nextchain)->elt = m_packedlook(m_entree, name))
|
||||
(*nextchain)->elt++ ;
|
||||
else
|
||||
m_err1("Undefined element: %s", name) ;
|
||||
nextchain = &(*nextchain)->next ;
|
||||
}
|
||||
;
|
||||
|
||||
text
|
||||
declitent:declitent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = EDECLITENT ;
|
||||
m_error("Entity content too long") ;
|
||||
}
|
||||
else entcontent[entclen++] = textchar ;
|
||||
}
|
||||
declitaent:declitaent {
|
||||
if (entclen >= M_LITLEN) {
|
||||
curcon = EDCLITAENT ;
|
||||
m_error("Entity content too long") ;
|
||||
}
|
||||
else entcontent[entclen++] = textchar ;
|
||||
}
|
||||
edeclitent:edeclitent
|
||||
edclitaent:edclitaent
|
||||
insignon:insignon {
|
||||
socr = (LOGICAL) (textchar == '\n') ;
|
||||
signonmsg[sochar++] = textchar ;
|
||||
if (sochar >= SOCHAR) {
|
||||
m_error("Exceeded buffer for sign-on message") ;
|
||||
exit(TRUE) ;
|
||||
}
|
||||
}
|
||||
globdef:globdef {
|
||||
fprintf(globdef, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(globdef, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
globdec:globdec {
|
||||
fprintf(globdec, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(globdec, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
iniss:iniss,
|
||||
inss:inss {
|
||||
if (! stringstart) fprintf(string, ",\n") ;
|
||||
fprintf(string, " %d", textchar) ;
|
||||
stringstart = FALSE ;
|
||||
stringcnt++ ;
|
||||
}
|
||||
inies:inies,
|
||||
ines:ines {
|
||||
if (! stringstart) fprintf(string, ",\n") ;
|
||||
fprintf(string, " %d", textchar) ;
|
||||
stringstart = FALSE ;
|
||||
stringcnt++ ;
|
||||
}
|
||||
inisc:inisc,
|
||||
insc:insc {
|
||||
fprintf(sfile, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(sfile, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
iniec:iniec,
|
||||
inec:inec {
|
||||
fprintf(efile, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(efile, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
initc:initc,
|
||||
intc:intc {
|
||||
fprintf(tfile, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(tfile, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
inipc:inipc,
|
||||
inpc:inpc {
|
||||
fprintf(pfile, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(pfile, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
inistc:inistc,
|
||||
instc:instc {
|
||||
fprintf(stfile, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(stfile, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
inentc:inentc {
|
||||
fprintf(entfile, "%c", textchar) ;
|
||||
/* if (textchar == '\n') fprintf(entfile, "#line %d \"%s\"\n",
|
||||
m_line, iffile) ; */
|
||||
}
|
||||
;
|
||||
|
||||
74
cde/programs/dthelp/parser/pass2/eltdef/eltdef.c
Normal file
74
cde/programs/dthelp/parser/pass2/eltdef/eltdef.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/* $XConsortium: eltdef.c /main/3 1995/11/08 10:44:41 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Eltdef.c contains the main program for ELTDEF */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
|
||||
#define M_DTDDEF
|
||||
#include "dtd.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "delim.h"
|
||||
#define ELTDEF
|
||||
#include "eltdef.h"
|
||||
#define M_ENTDEF
|
||||
#include "entity.h"
|
||||
|
||||
/* Main program */
|
||||
void main(argc, argv)
|
||||
int argc ;
|
||||
char **argv ;
|
||||
{
|
||||
int m_token ;
|
||||
|
||||
if (argc > 2)
|
||||
if (*argv[2] == '-') {
|
||||
if (strchr(argv[2], 'a')) m_malftrace = TRUE ;
|
||||
if (strchr(argv[2], 'A')) m_malftrace = TRUE ;
|
||||
if (strchr(argv[2], 'd')) debug = TRUE ;
|
||||
if (strchr(argv[2], 'D')) debug = TRUE ;
|
||||
if (strchr(argv[2], 'h')) m_heapchk = TRUE ;
|
||||
if (strchr(argv[2], 'H')) m_heapchk = TRUE ;
|
||||
if (strchr(argv[2], 's')) scantrace = TRUE ;
|
||||
if (strchr(argv[2], 'S')) scantrace = TRUE ;
|
||||
}
|
||||
else
|
||||
fprintf(stderr,
|
||||
"****Starting with MARKUP 2.0, ELTDEF no longer writes a statistics file"
|
||||
) ;
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "**** Specify interface file ****\n") ;
|
||||
exit(TRUE) ;
|
||||
}
|
||||
strncpy(iffile, argv[1], IFLEN) ;
|
||||
initialize() ;
|
||||
while (TRUE) {
|
||||
m_token = scan() ;
|
||||
if (m_token == ELT) restart = RELEMENT ;
|
||||
m_prevcon = curcon ;
|
||||
curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
|
||||
if (scantrace)
|
||||
printf(
|
||||
"Main: m_prevcon=%d,m_token=%d,curcon=%d,textchar='%c'(%d), line=%d\n",
|
||||
m_prevcon, m_token, curcon, textchar, textchar, m_line) ;
|
||||
#include "case.c"
|
||||
if (m_token == ENDFILE) break ;
|
||||
if (! curcon) {
|
||||
m_error("Parsing table error") ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
done() ;
|
||||
}
|
||||
219
cde/programs/dthelp/parser/pass2/eltdef/eltdef.h
Normal file
219
cde/programs/dthelp/parser/pass2/eltdef/eltdef.h
Normal file
@@ -0,0 +1,219 @@
|
||||
/* $XConsortium: eltdef.h /main/3 1995/11/08 10:44:51 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Eltdef.h is the include file for allocating global variables in ELTDEF */
|
||||
|
||||
#if defined(ELTDEF)
|
||||
#define ELTEXTERN
|
||||
#define ELTINIT(a) = a
|
||||
#else
|
||||
#define ELTEXTERN extern
|
||||
#define ELTINIT(a)
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* Error recovery status */
|
||||
#define RENTITY 0
|
||||
#define RSIGNON 1
|
||||
#define RGLOBDEC 2
|
||||
#define RGLOBDEF 3
|
||||
#define RELEMENT 4
|
||||
|
||||
/* State transition network generated by CONTEXT */
|
||||
#include "sparse.h"
|
||||
|
||||
/* Indicates whether, and if so where, each character can appear in
|
||||
a name */
|
||||
#if defined(ELTDEF)
|
||||
#include "chartype.h"
|
||||
#else
|
||||
extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
|
||||
#endif
|
||||
|
||||
/* Scanned name or literal */
|
||||
ELTEXTERN M_WCHAR name[M_NAMELEN + 1] ;
|
||||
ELTEXTERN M_WCHAR literal[M_LITLEN + 1] ;
|
||||
|
||||
/* Associates a C variable with a particular parameter */
|
||||
typedef struct cvarstruct CVARSTRUCT ;
|
||||
struct cvarstruct {
|
||||
int param ;
|
||||
M_WCHAR *cvarptr ;
|
||||
CVARSTRUCT *next ;
|
||||
} ;
|
||||
ELTEXTERN CVARSTRUCT *cvarlist ;
|
||||
/* Current and previous context (state) of transition system
|
||||
controlling ELTDEF */
|
||||
ELTEXTERN int curcon ELTINIT(START) ;
|
||||
ELTEXTERN int m_prevcon ;
|
||||
|
||||
/* Character read-ahead buffer */
|
||||
ELTEXTERN int toundo ELTINIT(0) ;
|
||||
ELTEXTERN int maxundo ELTINIT(0) ;
|
||||
#define SAVECHAR 50
|
||||
ELTEXTERN int savechar[SAVECHAR] ;
|
||||
|
||||
/* Chain of elements named in pseudo-tag */
|
||||
typedef struct chain CHAIN ;
|
||||
struct chain {
|
||||
M_ELEMENT elt ;
|
||||
CHAIN *next ;
|
||||
} ;
|
||||
ELTEXTERN CHAIN *firstchain ELTINIT(NULL) ;
|
||||
ELTEXTERN CHAIN **nextchain ELTINIT(&firstchain) ;
|
||||
|
||||
/* Text character returned from scanner */
|
||||
ELTEXTERN M_WCHAR textchar ;
|
||||
|
||||
/* Identifying index of element currently being processed */
|
||||
ELTEXTERN M_ELEMENT openelt ELTINIT(M_NULLVAL) ;
|
||||
|
||||
/* Output files */
|
||||
ELTEXTERN FILE *globdec, *globdef, *string,
|
||||
*pfile, *tfile, *sfile, *efile, *entfile, *ifile, *stfile, *ifh, *pvalh ;
|
||||
|
||||
/* Flags indicating whether currently in the middle of processing
|
||||
an action */
|
||||
ELTEXTERN LOGICAL intext ELTINIT(FALSE),
|
||||
inent ELTINIT(FALSE),
|
||||
inpc ELTINIT(FALSE),
|
||||
insc ELTINIT(FALSE),
|
||||
inec ELTINIT(FALSE),
|
||||
instc ELTINIT(FALSE),
|
||||
instring ELTINIT(FALSE) ;
|
||||
|
||||
/* Location of global start-string and end-string, if any */
|
||||
ELTEXTERN int gss ELTINIT(0),
|
||||
ges ELTINIT(0) ;
|
||||
|
||||
/* Flags indicating whether default code setments are to be used */
|
||||
ELTEXTERN LOGICAL finitext ELTINIT(TRUE),
|
||||
finipi ELTINIT(TRUE),
|
||||
finistc ELTINIT(TRUE) ;
|
||||
|
||||
/* Whether have finished the sign-on message */
|
||||
ELTEXTERN LOGICAL signonend ELTINIT(FALSE) ;
|
||||
|
||||
/* Whether errors have occurred */
|
||||
ELTEXTERN LOGICAL errexit ELTINIT(FALSE) ;
|
||||
|
||||
/* Number of characters currently written to stext.h and etext.h */
|
||||
ELTEXTERN int stringcnt ELTINIT(1) ;
|
||||
|
||||
/* Number of actions so far written to code files */
|
||||
ELTEXTERN int sactions ELTINIT(1),
|
||||
eactions ELTINIT(1),
|
||||
tactions ELTINIT(1),
|
||||
pactions ELTINIT(1),
|
||||
stactions ELTINIT(1) ;
|
||||
|
||||
/* Pool of ponters for associating a chain of elements with an action string
|
||||
or code */
|
||||
typedef struct action ACTION ;
|
||||
struct action {
|
||||
int data ;
|
||||
M_ELEMENT element ;
|
||||
int count ;
|
||||
ACTION *son ;
|
||||
ACTION *next ;
|
||||
ACTION *nextact ;
|
||||
} ;
|
||||
ELTEXTERN int actlen ELTINIT(0) ;
|
||||
ELTEXTERN ACTION *firstact ELTINIT(NULL) ;
|
||||
ELTEXTERN ACTION **nextact ELTINIT(&firstact) ;
|
||||
|
||||
/* Number of elements defined in the document type */
|
||||
#if defined(M_DTDDEF)
|
||||
#define ELCOUNT sizeof(m_element)/sizeof(m_element[0])
|
||||
#else
|
||||
#define ELCOUNT
|
||||
#endif
|
||||
|
||||
/* Action arrays, indexed by the element in which they occur. Each element
|
||||
is a linked list for actions qualified by the context in which they
|
||||
occur. */
|
||||
ELTEXTERN ACTION *starray[ELCOUNT],
|
||||
*etarray[ELCOUNT],
|
||||
*scarray[ELCOUNT],
|
||||
*ecarray[ELCOUNT],
|
||||
*tcarray[ELCOUNT],
|
||||
*pcarray[ELCOUNT],
|
||||
*stcarray[ELCOUNT] ;
|
||||
|
||||
/* Store the sign-on message */
|
||||
#define SOCHAR 512
|
||||
ELTEXTERN char signonmsg[SOCHAR] ;
|
||||
ELTEXTERN int sochar ELTINIT(0) ;
|
||||
|
||||
/* Indicates which elements have been processed at a particular time */
|
||||
ELTEXTERN LOGICAL processed[ELCOUNT] ;
|
||||
|
||||
/* Flags to indicate whether data has yet been written to various files */
|
||||
ELTEXTERN LOGICAL stringstart ELTINIT(TRUE) ;
|
||||
|
||||
/* Flag indicating whether a carriage return was the last character of
|
||||
the signon message */
|
||||
ELTEXTERN LOGICAL socr ELTINIT(FALSE) ;
|
||||
|
||||
/* Number of current input line */
|
||||
ELTEXTERN int m_line ELTINIT(1) ;
|
||||
|
||||
/* Pointer to file error for error messages */
|
||||
ELTEXTERN FILE *m_errfile ;
|
||||
|
||||
/* Name of interface file */
|
||||
#define IFLEN 512
|
||||
ELTEXTERN char iffile[IFLEN] ;
|
||||
|
||||
/* Pointer to current entity */
|
||||
ELTEXTERN M_ENTITY *entity ;
|
||||
|
||||
/* Count of code entities defined */
|
||||
ELTEXTERN int codeent ELTINIT(0) ;
|
||||
|
||||
/* Content of entity being defined */
|
||||
ELTEXTERN int entclen ;
|
||||
ELTEXTERN M_WCHAR entcontent[M_LITLEN + 1] ;
|
||||
|
||||
/* Error recovery status */
|
||||
ELTEXTERN int restart ELTINIT(RENTITY) ;
|
||||
|
||||
/* Strings to write to generated files */
|
||||
#define pproto "M_WCHAR *m_pi, M_WCHAR *m_entname, int m_enttype"
|
||||
#define pformal "m_pi, m_entname, m_enttype"
|
||||
#define pftype " M_WCHAR *m_pi ;\n M_WCHAR *m_entname ;\n int m_enttype ;"
|
||||
#define tproto "M_WCHAR m_textchar"
|
||||
#define tformal "m_textchar"
|
||||
#define tftype " M_WCHAR m_textchar ;\n"
|
||||
#define stproto "M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END"
|
||||
#define stformal "m_string, M_START, M_END"
|
||||
#define stft " M_WCHAR *m_string ;\n LOGICAL M_START ;\n LOGICAL M_END ;\n"
|
||||
#define nopar "M_NOPAR"
|
||||
|
||||
/* Structures for generating defines for parameter values */
|
||||
ELTEXTERN M_TRIE parval ;
|
||||
typedef struct {
|
||||
M_WCHAR *cname ;
|
||||
M_WCHAR *value ;
|
||||
int line ;
|
||||
} PARVAL ;
|
||||
ELTEXTERN PARVAL *pval ;
|
||||
|
||||
/* Function prototypes */
|
||||
#include "proto.h"
|
||||
|
||||
/* Flag to open fewer files for convenience of debugging with
|
||||
CodeView */
|
||||
ELTEXTERN LOGICAL debug ELTINIT(FALSE) ;
|
||||
/* Scanner trace for debugging */
|
||||
ELTEXTERN LOGICAL scantrace ELTINIT(FALSE) ;
|
||||
/* Test validity of heap in calls to malloc/free */
|
||||
ELTEXTERN LOGICAL m_heapchk ELTINIT(FALSE) ;
|
||||
/* Trace calls to malloc/free */
|
||||
ELTEXTERN LOGICAL m_malftrace ELTINIT(FALSE) ;
|
||||
|
||||
675
cde/programs/dthelp/parser/pass2/eltdef/eltutil.c
Normal file
675
cde/programs/dthelp/parser/pass2/eltdef/eltutil.c
Normal file
@@ -0,0 +1,675 @@
|
||||
/* $XConsortium: eltutil.c /main/3 1995/11/08 10:45:02 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Eltutil.c contains procedures for program ELTDEF */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
|
||||
#include "dtdext.h"
|
||||
|
||||
#include "eltdef.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
|
||||
#include "entext.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
/* Output indicated action pointer array to if.h */
|
||||
void actptrout(array, name)
|
||||
ACTION **array;
|
||||
char *name;
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(ifh, "M_IFEXTERN int %s[%d]\n#if defined(M_IFDEF)\n = {\n",
|
||||
name, m_elcount);
|
||||
for (i = 0 ; i < m_elcount ; i++) {
|
||||
if (i > 0) fprintf(ifh, ",\n");
|
||||
fprintf(ifh, " %d", array[i] ? array[i]->count : M_NULLVAL);
|
||||
}
|
||||
fprintf(ifh, "}\n#endif\n ;\n");
|
||||
}
|
||||
|
||||
|
||||
/* Close a code file and write jump table at the end */
|
||||
#if defined(M_PROTO)
|
||||
void closeiffile(LOGICAL flag, FILE *file, int count, char *table, char *proto)
|
||||
#else
|
||||
void closeiffile(flag, file, count, table, proto)
|
||||
LOGICAL flag;
|
||||
FILE *file;
|
||||
int count;
|
||||
char *table;
|
||||
char *proto;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
endcode(flag, file);
|
||||
if (count) {
|
||||
fprintf(file,
|
||||
"void (*m_%stable[])(\n#if defined(M_PROTO)\n %s\n#endif\n ) = {\n",
|
||||
table, proto);
|
||||
fprintf(file, " m_%s1, /* Place holder for 1-based indexing */\n",
|
||||
table);
|
||||
for (i = 1 ; i <= count ; i++) {
|
||||
fprintf(file, " m_%s%d", table, i);
|
||||
if (i != count) fputs(",\n", file);
|
||||
}
|
||||
fputs("} ;\n", file);
|
||||
}
|
||||
else
|
||||
fprintf(file,
|
||||
"void (*m_%stable[1])(\n#if defined(M_PROTO)\n %s\n#endif\n ) ;\n",
|
||||
table, proto);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
/* Called when the C identifier to be #define'd to a parameter value is
|
||||
scanned */
|
||||
void cvalue(M_NOPAR)
|
||||
{
|
||||
PARVAL *new;
|
||||
|
||||
new = (PARVAL *) m_malloc(sizeof(PARVAL), "parameter value");
|
||||
if (pval = (PARVAL *) m_ntrtrie(name, &parval, (M_TRIE *) new))
|
||||
m_free(new, "parameter value");
|
||||
else {
|
||||
new->line = 0;
|
||||
new->value = NULL;
|
||||
new->cname = (M_WCHAR *) m_malloc(w_strlen(name) + 1, "C name");
|
||||
w_strcpy(new->cname, name);
|
||||
pval = new;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Called after last input character is read to place closing punctuation
|
||||
at end of output files and close them */
|
||||
void done(M_NOPAR)
|
||||
{
|
||||
M_ENTITY *ent;
|
||||
ACTION *actp;
|
||||
LOGICAL first;
|
||||
int i;
|
||||
|
||||
closeiffile(inent, entfile, codeent, "c", nopar);
|
||||
closeiffile(intext, tfile, tactions, "t", tproto);
|
||||
closeiffile(inpc, pfile, pactions, "p", pproto);
|
||||
closeiffile(insc, sfile, sactions, "s", nopar);
|
||||
closeiffile(inec, efile, eactions, "e", nopar);
|
||||
closeiffile(instc, stfile, stactions, "st", stproto);
|
||||
|
||||
endstring();
|
||||
fclose(string);
|
||||
|
||||
/* Write if.h (which was opened for sign-on message) */
|
||||
fprintf(ifh, "M_IFEXTERN int m_gss M_IFINIT(%d) ;\n", gss);
|
||||
fprintf(ifh, "M_IFEXTERN int m_ges M_IFINIT(%d) ;\n", ges);
|
||||
fputs("M_IFEXTERN struct {\n", ifh);
|
||||
fputs(" int data ;\n", ifh);
|
||||
fputs(" M_ELEMENT element ;\n", ifh);
|
||||
fputs(" int son ;\n", ifh);
|
||||
fputs(" int next ;\n", ifh);
|
||||
if (actlen) {
|
||||
fprintf(ifh,
|
||||
" } m_action[%d]\n#if defined(M_IFDEF)\n = {\n",
|
||||
actlen);
|
||||
|
||||
first = TRUE;
|
||||
for (actp = firstact ; actp ; actp = actp->nextact) {
|
||||
if (first) first = FALSE;
|
||||
else fprintf(ifh, ",\n");
|
||||
fprintf(ifh, " %d, %d, %d, %d",
|
||||
actp->data, actp->element,
|
||||
actp->son ? actp->son->count : M_NULLVAL,
|
||||
actp->next ? actp->next->count : M_NULLVAL);
|
||||
}
|
||||
fprintf(ifh, "}\n#endif\n ;\n");
|
||||
}
|
||||
else fputs(" } m_action[1] ;\n", ifh);
|
||||
|
||||
actptrout(starray, "m_starray");
|
||||
actptrout(etarray, "m_etarray");
|
||||
actptrout(scarray, "m_scarray");
|
||||
actptrout(ecarray, "m_ecarray");
|
||||
actptrout(tcarray, "m_tcarray");
|
||||
actptrout(pcarray, "m_pcarray");
|
||||
actptrout(stcarray, "m_stcarray");
|
||||
|
||||
outstring();
|
||||
m_openchk(&pvalh, "pval.h", "w");
|
||||
fputs("/* Parameter values specified in the interface */\n", pvalh);
|
||||
if (parval.data) outpval(parval.data);
|
||||
|
||||
fclose(ifh);
|
||||
|
||||
/* Report any elements and entities left undefined */
|
||||
for (i = 0 ; i < m_elcount ; i++)
|
||||
if (! processed[i])
|
||||
warning1("Warning: No specification for element %s",
|
||||
&m_ename[m_element[i].enptr]);
|
||||
|
||||
for (ent = firstent ; ent ; ent = ent->next)
|
||||
if (! ent->wheredef)
|
||||
warning1("Warning: Entity %s undefined", ent->name);
|
||||
entout("entity2");
|
||||
|
||||
exit(errexit);
|
||||
}
|
||||
|
||||
/* Called when finished reading a section of code from the input file */
|
||||
#if defined(M_PROTO)
|
||||
void endcode(LOGICAL flag, FILE *file)
|
||||
#else
|
||||
void endcode(flag, file)
|
||||
LOGICAL flag;
|
||||
FILE *file;
|
||||
#endif
|
||||
{
|
||||
if (flag) fprintf(file, "}}\n\n");
|
||||
}
|
||||
|
||||
/* Called at the end of all initial fields in the interface definition */
|
||||
void endini(M_NOPAR)
|
||||
{
|
||||
if (finitext)
|
||||
fputs(" putc(m_textchar, m_outfile);\n", tfile);
|
||||
if (finipi)
|
||||
fputs(" fputs(m_pi, m_outfile) ;\n", pfile);
|
||||
if (finistc)
|
||||
{
|
||||
fputs(" {\n", stfile);
|
||||
fputs(" char *mb_string;\n", stfile);
|
||||
fputs(" mb_string = MakeMByteString(m_string);\n", stfile);
|
||||
fputs(" fputs(mb_string, m_outfile) ;\n", stfile);
|
||||
fputs(" m_free(mb_string,\"multi-byte string\");;\n", stfile);
|
||||
fputs(" }\n", stfile);
|
||||
}
|
||||
}
|
||||
|
||||
/* End the sign-on message */
|
||||
#include <time.h>
|
||||
void endsignon(M_NOPAR)
|
||||
{
|
||||
time_t storetime;
|
||||
char *p;
|
||||
char *timeofday;
|
||||
static char signon1[] = "Interface generated from ";
|
||||
static char signon2[] = " on ";
|
||||
int i;
|
||||
int len;
|
||||
FILE *sgfile;
|
||||
|
||||
signonend = TRUE;
|
||||
/* Discard a trailing carriage return in the sign-on message */
|
||||
if (socr) sochar--;
|
||||
|
||||
time(&storetime);
|
||||
timeofday = ctime(&storetime);
|
||||
|
||||
len =
|
||||
sochar+strlen(signon1)+strlen(signon2)+strlen(iffile)+strlen(timeofday)
|
||||
/* a byte for end of string marker */
|
||||
+ 1
|
||||
/* a byte for a carriage return after any user-supplied message */
|
||||
+ (sochar ? 1 : 0);
|
||||
m_openchk(&sgfile, "signonx.h", "w");
|
||||
fprintf(sgfile, "extern char m_signon[%d] ;\n", len);
|
||||
fclose(sgfile);
|
||||
m_openchk(&sgfile, "signon.h", "w");
|
||||
fprintf(sgfile, "char m_signon[%d] = {\n", len);
|
||||
|
||||
for (i = 0 ; i <sochar ; i++)
|
||||
fprintf(sgfile, " %d,\n", signonmsg[i]);
|
||||
if (sochar) fputs(" 10,\n", sgfile);
|
||||
for (p = signon1 ; *p ; p++)
|
||||
fprintf(sgfile, " %d,\n", *p);
|
||||
for (p = iffile ; *p ; p++)
|
||||
fprintf(sgfile, " %d,\n", *p);
|
||||
for (p = signon2 ; *p ; p++)
|
||||
fprintf(sgfile, " %d,\n", *p);
|
||||
for (p = timeofday ; *p ; p++)
|
||||
fprintf(sgfile, " %d,\n", *p);
|
||||
fputs(" 0} ;\n", sgfile);
|
||||
fclose(sgfile);
|
||||
}
|
||||
|
||||
/* Closes a start-string or end-string */
|
||||
void endstring(M_NOPAR)
|
||||
{
|
||||
if (instring) {
|
||||
if (stringstart) stringstart = FALSE;
|
||||
else fprintf(string, ",\n");
|
||||
stringcnt++;
|
||||
instring = FALSE;
|
||||
fprintf(string, " 0");
|
||||
}
|
||||
/* If called after ENDFILE, ensure at least one character in output file*/
|
||||
else if (stringstart) fprintf(string, " 0");
|
||||
}
|
||||
|
||||
/* Set the type of an entity and check if different than declaration in
|
||||
BUILD */
|
||||
void enttype(type)
|
||||
int type;
|
||||
{
|
||||
if ((entity->type == M_PI && type == M_CODEPI) ||
|
||||
(entity->type == M_SDATA && type == M_CODESDATA));
|
||||
else if (entity->type != M_GENERAL &&
|
||||
entity->type != (unsigned char) type)
|
||||
warning1("Redefining type of entity %s", name);
|
||||
entity->type = (unsigned char) type;
|
||||
}
|
||||
|
||||
/* Free storage used for a context-specification chain */
|
||||
void freechain(M_NOPAR)
|
||||
{
|
||||
CHAIN *chainp, *dchainp;
|
||||
|
||||
for (chainp = firstchain ; chainp ;) {
|
||||
dchainp = chainp;
|
||||
chainp = chainp->next;
|
||||
m_free(dchainp, "chain");
|
||||
}
|
||||
firstchain = NULL;
|
||||
nextchain = &firstchain;
|
||||
}
|
||||
|
||||
/* Returns pointer to data field in action node for current chain of
|
||||
elements */
|
||||
int *getaction(array)
|
||||
ACTION **array;
|
||||
{
|
||||
ACTION *start, *node;
|
||||
CHAIN *chainp;
|
||||
|
||||
if (! array[openelt - 1]) {
|
||||
array[openelt - 1] = getactstruct();
|
||||
array[openelt - 1]->element = openelt + 1;
|
||||
}
|
||||
start = array[openelt - 1];
|
||||
for (chainp = firstchain ; chainp ; chainp = chainp->next) {
|
||||
if (! start->son) {
|
||||
for ( ; chainp ; chainp = chainp->next) {
|
||||
start->son = getactstruct();
|
||||
start->son->element = chainp->elt;
|
||||
start = start->son;
|
||||
}
|
||||
freechain();
|
||||
return(&start->data);
|
||||
}
|
||||
for (node = start->son ; node ; start = node, node = node->next)
|
||||
if (node->element == chainp->elt) break;
|
||||
if (! node) {
|
||||
start->next = getactstruct();
|
||||
start->next->element = chainp->elt;
|
||||
start = start->next;
|
||||
}
|
||||
else start = node;
|
||||
}
|
||||
if (start->data) m_error("Duplicate specification");
|
||||
freechain();
|
||||
return(&start->data);
|
||||
}
|
||||
|
||||
/* Allocate new action structure */
|
||||
ACTION *getactstruct(M_NOPAR)
|
||||
{
|
||||
ACTION *new;
|
||||
|
||||
new = (ACTION *) m_malloc(sizeof(ACTION), "action");
|
||||
new->count = ++actlen;
|
||||
new->data = M_NULLVAL;
|
||||
new->son = new->next = new->nextact = NULL;
|
||||
*nextact = new;
|
||||
nextact = &new->nextact;
|
||||
return(new);
|
||||
}
|
||||
|
||||
/* Program initialization */
|
||||
void initialize(M_NOPAR)
|
||||
{
|
||||
char **mb_delims;
|
||||
M_WCHAR **wc_delims;
|
||||
|
||||
fprintf(stderr, "MARKUP System - ELTDEF %s\n", M_VERSION);
|
||||
fprintf(stderr, "Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.\n");
|
||||
|
||||
m_openchk(&ifh, "if.h", "w");
|
||||
m_openchk(&globdef, "globdef.h", "w");
|
||||
m_openchk(&globdec, "globdec.h", "w");
|
||||
m_openchk(&pfile, "pfile.c", "w");
|
||||
/* ELTDEF opens too many files for use with CodeView debugger. If
|
||||
this option is set, all code segments are written to one file */
|
||||
if (debug)
|
||||
{
|
||||
tfile =
|
||||
sfile =
|
||||
efile =
|
||||
stfile =
|
||||
entfile =
|
||||
pfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_openchk(&tfile, "tfile.c", "w");
|
||||
m_openchk(&sfile, "sfile.c", "w");
|
||||
m_openchk(&efile, "efile.c", "w");
|
||||
m_openchk(&stfile, "stfile.c", "w");
|
||||
m_openchk(&entfile, "entfile.c", "w");
|
||||
}
|
||||
m_openchk(&string, "estring.h", "w");
|
||||
m_openchk(&m_errfile, "error", "w");
|
||||
m_openchk(&ifile, iffile, "r");
|
||||
|
||||
mb_delims = mb_dlmptr;
|
||||
wc_delims = m_dlmptr;
|
||||
|
||||
while (*mb_delims)
|
||||
{
|
||||
*wc_delims++ = MakeWideCharString(*mb_delims);
|
||||
mb_delims++;
|
||||
}
|
||||
*wc_delims = 0;
|
||||
|
||||
/* Start array for sign-on message on globals.h. Also,
|
||||
make sure there is at least one line in globals.h, because
|
||||
DOS copy does not copy an empty file */
|
||||
|
||||
fputs("/* Global definitions specified by interface designer*/\n",
|
||||
globdef);
|
||||
fputs("/* Global declarations specified by interface designer*/\n",
|
||||
globdec);
|
||||
|
||||
fputs("#if defined(M_IFDEF)\n", ifh);
|
||||
fputs("#define M_IFEXTERN\n", ifh);
|
||||
fputs("#define M_IFINIT(a) = a\n", ifh);
|
||||
fputs("#else\n", ifh);
|
||||
fputs("#define M_IFEXTERN extern\n", ifh);
|
||||
fputs("#define M_IFINIT(a)\n", ifh);
|
||||
fputs("#endif\n", ifh);
|
||||
|
||||
startcode(pactions, &inpc, pfile, "p", pproto, pformal, pftype);
|
||||
startcode(tactions, &intext, tfile, "t", tproto, tformal, tftype);
|
||||
startcode(sactions, &insc, sfile, "s", nopar, nopar, "");
|
||||
startcode(eactions, &inec, efile, "e", nopar, nopar, "");
|
||||
startcode(stactions, &instc, stfile, "st", stproto, stformal, stft);
|
||||
}
|
||||
|
||||
/* Output definitions for strings */
|
||||
void outstring(M_NOPAR)
|
||||
{
|
||||
int c;
|
||||
|
||||
m_openchk(&string, "estring.h", "r");
|
||||
fprintf(ifh, "M_IFEXTERN char m_string[%d]\n",
|
||||
stringcnt > 1 ? stringcnt - 1 : 1);
|
||||
if (stringcnt - 1) {
|
||||
fputs("#if defined(M_IFDEF)\n = {\n", ifh);
|
||||
while ((c = getc(string)) != EOF) putc(c, ifh);
|
||||
fputs("}\n#endif\n", ifh);
|
||||
}
|
||||
fputs(" ;\n", ifh);
|
||||
fclose(string);
|
||||
}
|
||||
|
||||
/* Output #define's for parameter values */
|
||||
void outpval(p)
|
||||
M_TRIE *p;
|
||||
{
|
||||
M_WCHAR *q;
|
||||
|
||||
for ( ; p ; p = p->next)
|
||||
if (p->symbol) outpval(p->data);
|
||||
else
|
||||
{
|
||||
char *mb_cname;
|
||||
|
||||
mb_cname = MakeMByteString(((PARVAL *) p->data)->cname);
|
||||
fprintf(pvalh,
|
||||
"/* line %d \"%s\" */\n",
|
||||
((PARVAL *) p->data)->line,
|
||||
iffile);
|
||||
fprintf(pvalh, "#define %s \"", mb_cname);
|
||||
m_free(mb_cname,"multi-byte string");
|
||||
if (q = ((PARVAL *) p->data)->value)
|
||||
for ( ; *q ; q++)
|
||||
{
|
||||
char mbq[32]; /* larger than largest possible mbyte char */
|
||||
int length;
|
||||
|
||||
length = wctomb(mbq, *q);
|
||||
if (length == 1)
|
||||
switch (*mbq)
|
||||
{
|
||||
case '\n':
|
||||
fputs("\\n", pvalh);
|
||||
break;
|
||||
case '"':
|
||||
fputs("\\\"", pvalh);
|
||||
break;
|
||||
default:
|
||||
putc(*mbq, pvalh);
|
||||
break;
|
||||
}
|
||||
else
|
||||
fputs(mbq, pvalh);
|
||||
}
|
||||
fputs("\"\n", pvalh);
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip rest of statement after an error */
|
||||
void skiptoend(M_NOPAR)
|
||||
{
|
||||
int i;
|
||||
static errlev = 0;
|
||||
CVARSTRUCT *cvarp, *dvarp;
|
||||
|
||||
for (cvarp = cvarlist ; cvarp ;) {
|
||||
dvarp = cvarp;
|
||||
m_free(cvarp->cvarptr, "C variable name");
|
||||
cvarp = cvarp->next;
|
||||
m_free(dvarp, "C variable");
|
||||
}
|
||||
cvarlist = NULL;
|
||||
freechain();
|
||||
if (! errlev++) {
|
||||
curcon = ERROR;
|
||||
while (TRUE) {
|
||||
i = scan();
|
||||
if (i == ENDFILE) break;
|
||||
else if (i == ELT) {
|
||||
if (restart <= RSIGNON) endsignon();
|
||||
restart = RELEMENT;
|
||||
curcon = NEEDN;
|
||||
break;
|
||||
}
|
||||
else if (i == GDEF && restart < RGLOBDEF) {
|
||||
if (restart <= RSIGNON) endsignon();
|
||||
restart = RGLOBDEF;
|
||||
curcon = GLOBDEF;
|
||||
break;
|
||||
}
|
||||
else if (i == GDEC && restart < RGLOBDEC) {
|
||||
if (restart <= RSIGNON) endsignon();
|
||||
restart = RGLOBDEC;
|
||||
curcon = GLOBDEC;
|
||||
break;
|
||||
}
|
||||
else if (i == SIGNON && restart < RSIGNON) {
|
||||
curcon = INSIGNON;
|
||||
restart = RSIGNON;
|
||||
break;
|
||||
}
|
||||
else if (i == ENTSTART && restart == RENTITY) {
|
||||
curcon = ENTDEC;
|
||||
break;
|
||||
}
|
||||
curcon = ERROR;
|
||||
} /* end while */
|
||||
} /* end if ! errlev */
|
||||
errlev--;
|
||||
}
|
||||
|
||||
/* Starts processing a code segment from the input file */
|
||||
void startcode(caseno, flag, file, prefix, proto, formal, formtype)
|
||||
int caseno;
|
||||
LOGICAL *flag;
|
||||
FILE *file;
|
||||
char *prefix;
|
||||
char *proto;
|
||||
char *formal;
|
||||
char *formtype;
|
||||
{
|
||||
CVARSTRUCT *cvarp;
|
||||
|
||||
endcode(*flag, file);
|
||||
*flag = TRUE;
|
||||
/* protoype */
|
||||
fprintf(file,
|
||||
"void m_%s%d(\n#if defined(M_PROTO)\n %s\n#endif\n ) ;\n",
|
||||
prefix,
|
||||
caseno,
|
||||
proto);
|
||||
|
||||
/* ANSI defines */
|
||||
fputs("#if defined(M_PROTO)\n", file);
|
||||
fprintf(file, "void m_%s%d(%s)\n", prefix, caseno, proto);
|
||||
fputs("#else\n", file);
|
||||
fprintf(file,
|
||||
"void m_%s%d(%s)\n%s\n#endif\n {\n", /* balance the "}" */
|
||||
prefix,
|
||||
caseno,
|
||||
formal,
|
||||
formtype);
|
||||
|
||||
for (cvarp = cvarlist ; cvarp ; cvarp = cvarp->next)
|
||||
{
|
||||
char *mb_cvarptr;
|
||||
|
||||
mb_cvarptr = MakeMByteString(cvarp->cvarptr);
|
||||
fprintf(file, " M_WCHAR *%s ;\n", mb_cvarptr);
|
||||
m_free(mb_cvarptr,"multi-byte string");
|
||||
}
|
||||
|
||||
for (cvarp = cvarlist ; cvarp ; cvarp = cvarp->next)
|
||||
{
|
||||
char *mb_cvarptr;
|
||||
|
||||
mb_cvarptr = MakeMByteString(cvarp->cvarptr);
|
||||
fprintf(file,
|
||||
" m_setparam(&%s, %d) ;\n",
|
||||
mb_cvarptr,
|
||||
cvarp->param);
|
||||
m_free(mb_cvarptr,"multi-byte string");
|
||||
}
|
||||
fprintf(file, "{\n/* line %d \"%s\" */\n", m_line, iffile); /* balance "}" */
|
||||
}
|
||||
|
||||
/* Begins processing a new element */
|
||||
void startelement(M_NOPAR)
|
||||
{
|
||||
CVARSTRUCT *cvarp;
|
||||
CVARSTRUCT *discard;
|
||||
|
||||
for (cvarp = cvarlist ; cvarp ; ) {
|
||||
discard = cvarp;
|
||||
m_free(cvarp->cvarptr, "C variable name");
|
||||
cvarp = cvarp->next;
|
||||
m_free(discard, "C variable");
|
||||
}
|
||||
cvarlist = NULL;
|
||||
if (openelt = m_packedlook(m_entree, name)) {
|
||||
if (processed[openelt - 1])
|
||||
warning1("Warning: Element %s already processed", name);
|
||||
processed[openelt - 1] = TRUE;
|
||||
}
|
||||
else m_err1("Undefined element: %s", name);
|
||||
}
|
||||
|
||||
/* Stores the name of a C variable read from the input file */
|
||||
void storecvar(M_NOPAR)
|
||||
{
|
||||
CVARSTRUCT *new;
|
||||
|
||||
new = (CVARSTRUCT *) m_malloc(sizeof(CVARSTRUCT), "C variable");
|
||||
new->cvarptr = (M_WCHAR *) m_malloc(w_strlen(name) + 1,
|
||||
"C variable name");
|
||||
w_strcpy(new->cvarptr, name);
|
||||
new->next = cvarlist;
|
||||
cvarlist = new;
|
||||
}
|
||||
|
||||
/* Compares the parameter name associated with a C variable in the input
|
||||
file with the names of all parameters of the current element. Stores
|
||||
result for later output with code segments */
|
||||
void storepname(M_NOPAR)
|
||||
{
|
||||
int i, par;
|
||||
|
||||
for (i = 0, par = m_element[openelt - 1].parptr;
|
||||
i < m_element[openelt - 1].parcount;
|
||||
i++, par++)
|
||||
if (! w_strcmp(&m_pname[m_parameter[par - 1].paramname], name))
|
||||
break;
|
||||
if (i >= m_element[openelt - 1].parcount) {
|
||||
m_err2("%s: No such parameter for element %s", name,
|
||||
&m_ename[m_element[openelt - 1].enptr]);
|
||||
return;
|
||||
}
|
||||
cvarlist->param = i;
|
||||
}
|
||||
|
||||
/* Called when a possible parameter value to be defined is encountered */
|
||||
void value(p)
|
||||
M_WCHAR *p;
|
||||
{
|
||||
char buffer[5];
|
||||
|
||||
if (m_partype(cvarlist->param + m_element[openelt - 1].parptr, p))
|
||||
{
|
||||
if (pval->line)
|
||||
{
|
||||
if (w_strcmp(pval->value, p))
|
||||
{
|
||||
M_WCHAR *w_buffer;
|
||||
|
||||
sprintf(buffer, "%d", pval->line);
|
||||
w_buffer = MakeWideCharString(buffer);
|
||||
m_err5("Can't #define %s to %s. %s #define'd to %s on line %s",
|
||||
pval->cname,
|
||||
p,
|
||||
pval->cname,
|
||||
pval->value,
|
||||
w_buffer);
|
||||
m_free(w_buffer, "wide character string");
|
||||
}
|
||||
}
|
||||
else {
|
||||
pval->value = (M_WCHAR *) m_malloc(w_strlen(p) + 1, "pval value");
|
||||
w_strcpy(pval->value, p);
|
||||
pval->line = m_line;
|
||||
}
|
||||
}
|
||||
else m_err3("\"%s\" illegal value for parameter %s of %s",
|
||||
p,
|
||||
&m_pname[m_parameter[cvarlist->param +
|
||||
m_element[openelt - 1].parptr - 1].paramname],
|
||||
&m_ename[m_element[openelt-1].enptr]);
|
||||
}
|
||||
|
||||
#include "paramu.c"
|
||||
51
cde/programs/dthelp/parser/pass2/eltdef/entity.c
Normal file
51
cde/programs/dthelp/parser/pass2/eltdef/entity.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* $XConsortium: entity.c /main/3 1995/11/08 10:45:15 rswiston $ */
|
||||
/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Entity.c has ELTDEF procedures relevant to entities */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "eltdef.h"
|
||||
#include "entext.h"
|
||||
|
||||
/* Add an entity */
|
||||
void addent(M_NOPAR)
|
||||
{
|
||||
M_ENTITY *new ;
|
||||
|
||||
new = (M_ENTITY *) m_malloc(sizeof(M_ENTITY), "entity") ;
|
||||
if (entity = (M_ENTITY *) m_ntrtrie(name, m_enttrie, (M_TRIE *) new)) {
|
||||
m_free(new, "entity") ;
|
||||
if (! entity->wheredef) return ;
|
||||
if (entity->wheredef == M_DBUILD) {
|
||||
warning1("Redefining %s: entity defined in BUILD", entity->name) ;
|
||||
entity->type = M_GENERAL ;
|
||||
entity->wheredef = FALSE ;
|
||||
entity->content = NULL ;
|
||||
return ;
|
||||
}
|
||||
else
|
||||
m_err1("Attempt to redefine %s", entity->name) ;
|
||||
return ;
|
||||
}
|
||||
entity = new ;
|
||||
if (lastent) lastent->next = entity ;
|
||||
else firstent = entity ;
|
||||
lastent = entity ;
|
||||
entity->type = M_GENERAL ;
|
||||
entity->wheredef = FALSE ;
|
||||
entity->content = NULL ;
|
||||
entity->name =
|
||||
(M_WCHAR *) m_malloc(w_strlen(name) + 1, "entity name") ;
|
||||
entity->index = ++m_entcnt ;
|
||||
entity->codeindex = M_NULLVAL ;
|
||||
entity->next = NULL ;
|
||||
w_strcpy(entity->name, name) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
#include "entout.c"
|
||||
339
cde/programs/dthelp/parser/pass2/eltdef/proto.h
Normal file
339
cde/programs/dthelp/parser/pass2/eltdef/proto.h
Normal file
@@ -0,0 +1,339 @@
|
||||
/* $XConsortium: proto.h /main/3 1995/11/08 10:45:25 rswiston $ */
|
||||
/*
|
||||
Copyright (c) 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Proto.h contains function prototypes for program ELTDEF. */
|
||||
|
||||
|
||||
void actptrout(
|
||||
#if defined(M_PROTO)
|
||||
ACTION **array, char *name
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void addent(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_allwhite(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void closeiffile(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL flag, FILE *file, int count, char *table, char *proto
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void countdown(
|
||||
#if defined(M_PROTO)
|
||||
M_TRIE *parent, int *count
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void cvalue(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
|
||||
void done(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_dumptrie(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file,
|
||||
M_TRIE *xtrie,
|
||||
char *extname,
|
||||
int *count,
|
||||
void (*proc)(M_ENTITY *)
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void endcode(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL flag, FILE *file
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void endini(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void endsignon(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void endstring(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void entout(
|
||||
#if defined(M_PROTO)
|
||||
char *fname
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void enttype(
|
||||
#if defined(M_PROTO)
|
||||
int type
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_error(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err1(
|
||||
#if defined(M_PROTO)
|
||||
const char *text, const M_WCHAR *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_mberr1(
|
||||
#if defined(M_PROTO)
|
||||
char *text, const char *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err2(
|
||||
#if defined(M_PROTO)
|
||||
const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err3(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err5(
|
||||
#if defined(M_PROTO)
|
||||
char *text,
|
||||
M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4, M_WCHAR *arg5
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_exit(
|
||||
#if defined(M_PROTO)
|
||||
int status
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_free(
|
||||
#if defined(M_PROTO)
|
||||
void *block, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void freechain(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int getachar(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int *getaction(
|
||||
#if defined(M_PROTO)
|
||||
ACTION **array
|
||||
#endif
|
||||
) ;
|
||||
|
||||
ACTION *getactstruct(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void getname(
|
||||
#if defined(M_PROTO)
|
||||
int first
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int gettoken(
|
||||
#if defined(M_PROTO)
|
||||
int *c, int context
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_initctype(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void initialize(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_letter(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL litproc(
|
||||
#if defined(M_PROTO)
|
||||
int delim
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void main(
|
||||
#if defined(M_PROTO)
|
||||
int argc, char **argv
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_malloc(
|
||||
#if defined(M_PROTO)
|
||||
int size, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_openchk(
|
||||
#if defined(M_PROTO)
|
||||
FILE **ptr, char *name, char *mode
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void outpval(
|
||||
#if defined(M_PROTO)
|
||||
M_TRIE *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void outstring(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_packedlook(
|
||||
#if defined(M_PROTO)
|
||||
M_PTRIE *xptrie, M_WCHAR *name
|
||||
#endif
|
||||
) ;
|
||||
|
||||
const M_WCHAR *m_partype(
|
||||
#if defined(M_PROTO)
|
||||
const int par, const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int scan(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void skiptoend(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void startcode(
|
||||
#if defined(M_PROTO)
|
||||
int caseno, LOGICAL *flag, FILE *file, char *prefix, char *proto,
|
||||
char *formal, char *formtype
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void startelement(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void storecvar(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void storepname(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void undodelim(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *delim
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void ungetachar(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_wcupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *p, const M_WCHAR *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_wcmbupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *p, const char *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_mbmbupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const char *p, const char *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void value(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning1(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_whitespace(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
143
cde/programs/dthelp/parser/pass2/eltdef/scan.c
Normal file
143
cde/programs/dthelp/parser/pass2/eltdef/scan.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/* $XConsortium: scan.c /main/3 1995/11/08 10:45:35 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Scan.c contains scanner procedures for program ELTDEF */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
|
||||
#include "dtdext.h"
|
||||
|
||||
#include "eltdef.h"
|
||||
#define M_CONDEF
|
||||
#include "context.h"
|
||||
#define M_DELIMDEF
|
||||
#include "delim.h"
|
||||
|
||||
/* Reads a name token */
|
||||
void getname(first)
|
||||
int first;
|
||||
{
|
||||
M_WCHAR *p, wus;
|
||||
int c, cttype;
|
||||
LOGICAL cname;
|
||||
|
||||
mbtowc(&wus, "_", 1);
|
||||
|
||||
cname = (LOGICAL) (curcon == INPARAM || curcon == INVALUE);
|
||||
*(p = name) = (M_WCHAR) first;
|
||||
if (! cname) *p = m_ctupper(*p);
|
||||
while (TRUE)
|
||||
{
|
||||
c = getachar();
|
||||
if (c == EOF) break;
|
||||
*++p = (M_WCHAR) c;
|
||||
cttype = m_cttype(*p);
|
||||
if (! cname)
|
||||
{
|
||||
if (cttype == M_NONNAME) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((cttype != M_NMSTART) && (cttype != M_DIGIT) && (*p != wus))
|
||||
break;
|
||||
}
|
||||
if (p >= name + M_NAMELEN)
|
||||
{
|
||||
*(name + M_NAMELEN) = M_EOS;
|
||||
m_error("Element name too long");
|
||||
}
|
||||
if (! cname) *p = m_ctupper(*p);
|
||||
}
|
||||
ungetachar(c);
|
||||
*p = M_EOS;
|
||||
}
|
||||
|
||||
/* Reads the next token and returns it to the main procedure */
|
||||
int scan(M_NOPAR)
|
||||
{
|
||||
int c;
|
||||
int n;
|
||||
static char unexp[] = "c";
|
||||
M_WCHAR wus;
|
||||
|
||||
mbtowc(&wus, "_", 1);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
while ((n = gettoken(&c, COMCON)) == STARTCOMMENT)
|
||||
while ((n = gettoken(&c, INCOM)) != ENDCOMMENT)
|
||||
if (c == EOF)
|
||||
{
|
||||
m_error("EOF occurred within comment");
|
||||
done();
|
||||
exit(TRUE);
|
||||
}
|
||||
ungetachar(c);
|
||||
n = gettoken(&c, curcon);
|
||||
if (n)
|
||||
{
|
||||
if (n != LIT && n != LITA) return(n);
|
||||
if (litproc(n))
|
||||
{
|
||||
if (scantrace)
|
||||
{
|
||||
char *mbyte;
|
||||
|
||||
mbyte = MakeMByteString(literal);
|
||||
printf("literal '%s'\n", mbyte);
|
||||
m_free(mbyte, "multi-byte string");
|
||||
}
|
||||
return(LITERAL);
|
||||
}
|
||||
}
|
||||
if (c == EOF) return(ENDFILE);
|
||||
if (m_newcon(curcon - 1, TEXT - 1))
|
||||
{
|
||||
textchar = (M_WCHAR) c;
|
||||
return(TEXT);
|
||||
}
|
||||
if (m_whitespace((M_WCHAR) c)) continue;
|
||||
if (m_newcon(curcon - 1, NAME - 1))
|
||||
{
|
||||
if (curcon == INPARAM || curcon == INVALUE)
|
||||
{
|
||||
/* Check for C identifier */
|
||||
if (m_letter((M_WCHAR) c) || c == wus)
|
||||
{
|
||||
getname(c);
|
||||
return(NAME);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check for SGML name */
|
||||
if ((m_cttype(c) == M_NMSTART) ||
|
||||
(m_cttype(c) != M_NONNAME && curcon == VALUE))
|
||||
{
|
||||
getname(c);
|
||||
return(NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (curcon != ERROR)
|
||||
{
|
||||
m_mberr1("Unexpected character: '%s'", unexp);
|
||||
}
|
||||
} /* End while */
|
||||
} /* End scan */
|
||||
|
||||
#include "scanutil.c"
|
||||
|
||||
#if defined(sparse)
|
||||
#include "sparse.c"
|
||||
#endif
|
||||
80
cde/programs/dthelp/parser/pass2/htag2/Imakefile
Normal file
80
cde/programs/dthelp/parser/pass2/htag2/Imakefile
Normal file
@@ -0,0 +1,80 @@
|
||||
XCOMM $XConsortium: Imakefile /main/9 1996/10/09 14:05:16 drk $
|
||||
/* htag2 Imakefile */
|
||||
|
||||
.SUFFIXES : .e .c .h
|
||||
|
||||
HTAG2 = ..
|
||||
HTAG2SRC = $(HTAG2)/htag2
|
||||
SDLPARSERSRC = $(HTAG2)/parser
|
||||
SDLELTDEFSRC = $(HTAG2)/eltdef
|
||||
SDLDTDFILE = $(HTAG2SRC)/sdl.dtd
|
||||
SDLUTILSRC = $(HTAG2)/util
|
||||
SDLBUILDSRC = $(HTAG2)/build
|
||||
SDLUTILLIB = $(HTAG2)/util/libutil.a
|
||||
SDLIFFILE = $(HTAG2SRC)/sdl.if
|
||||
|
||||
XLATESRC = $(DTHELPSRC)
|
||||
XLATEHDRS = $(XLATESRC)/XlationSvc.h $(XLATESRC)/LocaleXlate.h
|
||||
XLATESRCS = LocaleXlate.c XlationSvc.c
|
||||
XLATEOBJS = LocaleXlate.o XlationSvc.o
|
||||
|
||||
INCLUDES = -I. -I$(SDLUTILSRC) -I$(SDLPARSERSRC) \
|
||||
-I$(SDLELTDEFSRC) -I$(XLATESRC)
|
||||
DEFINES = -DOSMAJORVERSION=OSMajorVersion \
|
||||
-DOSMINORVERSION=OSMinorVersion
|
||||
|
||||
ELTHDRS = $(SDLUTILSRC)/entdef.h $(SDLUTILSRC)/entext.h
|
||||
|
||||
XCOMM PARSEHDRS are header files used by many parser routines
|
||||
PARSEHDRS = $(SDLUTILSRC)/basic.h $(SDLUTILSRC)/trie.h \
|
||||
$(SDLUTILSRC)/common.h $(SDLUTILSRC)/dtddef.h \
|
||||
$(SDLUTILSRC)/dtdext.h $(SDLUTILSRC)/sparse.h \
|
||||
parser.h proto.h
|
||||
|
||||
APPLHDRS = $(PARSEHDRS) $(ELTHDRS) \
|
||||
$(SDLUTILSRC)/version.h \
|
||||
$(HTAG2SRC)/global.h \
|
||||
$(HTAG2SRC)/fproto.h \
|
||||
../parser/pval.h ../parser/globdec.h ../parser/signonx.h \
|
||||
../parser/userinc.h
|
||||
|
||||
SRCS = custom.c sdl.c option.c out.c $(XLATESRCS)
|
||||
|
||||
OBJS = custom.o sdl.o option.o out.o $(XLATEOBJS)
|
||||
|
||||
LOCAL_LIBRARIES = $(SDLUTILLIB)
|
||||
|
||||
/* Don't use shared libs for hp */
|
||||
#ifdef HPArchitecture
|
||||
#if OSMajorVersion > 7
|
||||
EXTRA_LOAD_FLAGS = -Wl,-a archive
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (SunArchitecture)
|
||||
SYS_LIBRARIES = -lm -ldl -lgen -lC
|
||||
#endif /* SunArchitecture */
|
||||
|
||||
all:: $(OBJS)
|
||||
|
||||
LinkSourceFile(LocaleXlate.c,$(DTSVCSRC)/DtUtil2)
|
||||
LinkSourceFile(XlationSvc.c,$(DTSVCSRC)/DtUtil2)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
|
||||
dthelp_htag2: $(SDLPARSERSRC)/parser
|
||||
$(RM) dthelp_htag2
|
||||
$(CP) (SDLPARSERSRC)/parser dthelp_htag2
|
||||
|
||||
clean::
|
||||
$(RM) dthelp_htag2
|
||||
$(RM) $(XLATESRCS)
|
||||
|
||||
|
||||
DependTarget()
|
||||
|
||||
tags ::
|
||||
etags -t *.c *.h *.if
|
||||
|
||||
etags ::
|
||||
etags -t *.c *.h *.if
|
||||
296
cde/programs/dthelp/parser/pass2/htag2/custom.c
Normal file
296
cde/programs/dthelp/parser/pass2/htag2/custom.c
Normal file
@@ -0,0 +1,296 @@
|
||||
/* $XConsortium: custom.c /main/7 1996/11/15 11:55:52 rswiston $ */
|
||||
/*
|
||||
Copyright (c) 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Custom.c contains standard PARSER functions, customized for the HP
|
||||
HelpTag formatting system. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#if defined(MSDOS)
|
||||
/* Standard startup code doesn't have room to load inherited environments
|
||||
in some cases. Since they're not used, don't bother. (Using Microsoft
|
||||
C compiler). */
|
||||
void _setenvp(M_NOPAR);
|
||||
void _setenvp(){}
|
||||
#endif
|
||||
|
||||
/* Write input file and line number for an error message */
|
||||
void m_dumpline(file, line)
|
||||
M_WCHAR *file;
|
||||
int line;
|
||||
{
|
||||
char buffer[10];
|
||||
char *mbyte;
|
||||
|
||||
m_errline("Line ");
|
||||
sprintf(buffer, "%d", line);
|
||||
m_errline(buffer);
|
||||
if (!file)
|
||||
{ /* no entity file */
|
||||
if (inFileName)
|
||||
{
|
||||
m_errline(" of ");
|
||||
m_errline(inFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* yes, entity file */
|
||||
mbyte = MakeMByteString(file);
|
||||
m_errline(" of ");
|
||||
m_errline(mbyte);
|
||||
m_free(mbyte, "multi-byte string");
|
||||
}
|
||||
}
|
||||
|
||||
/* Write error message prefix */
|
||||
void m_eprefix(M_NOPAR)
|
||||
{
|
||||
m_errline("\n*****\n");
|
||||
m_dumpline(m_thisfile(), m_thisline());
|
||||
m_errline(",\n");
|
||||
}
|
||||
|
||||
/* Process error message text */
|
||||
void m_errline(p)
|
||||
char *p;
|
||||
{
|
||||
char c;
|
||||
|
||||
for ( ; *p ; p++)
|
||||
{
|
||||
if (m_errfile) putc(*p, m_errfile);
|
||||
putc(*p, stderr);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
/* Write error message suffix */
|
||||
void m_esuffix(M_NOPAR)
|
||||
{
|
||||
m_errline(":\n");
|
||||
m_lastchars();
|
||||
if (++m_errcnt == m_errlim)
|
||||
{
|
||||
m_error("Too many errors, processing stopped");
|
||||
m_exit(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Exit procedure */
|
||||
void m_exit(status)
|
||||
int status;
|
||||
{
|
||||
|
||||
if (status)
|
||||
{
|
||||
if (status == 77) /* tell helptag to re-run for forward xrefs */
|
||||
{
|
||||
if (stoponerror)
|
||||
{
|
||||
if (m_errcnt == 0)
|
||||
exit(77);
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
exit(66);
|
||||
}
|
||||
|
||||
if (stoponerror)
|
||||
exit(1); /* tell helptag to quit */
|
||||
|
||||
exit(2); /* tell helptag to continue to next phases */
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Get-char procedure */
|
||||
int m_getc(m_ptr)
|
||||
void *m_ptr;
|
||||
{
|
||||
int c;
|
||||
M_WCHAR wc;
|
||||
char badch[2];
|
||||
char mbyte[32]; /* make this bigger than any possible multi-byte char */
|
||||
int length;
|
||||
static M_WCHAR wcr = 0, wsb, wsp, wtb;
|
||||
char tab, space;
|
||||
|
||||
/* Unix/Dos compatibility: 0D0A handling */
|
||||
if (!wcr)
|
||||
{
|
||||
mbtowc(&wcr, "\r", 1);
|
||||
mbtowc(&wsb, "\032", 1);
|
||||
|
||||
space = M_SPACE;
|
||||
mbtowc(&wsp, &space, 1);
|
||||
|
||||
tab = M_TAB;
|
||||
mbtowc(&wtb, &tab, 1);
|
||||
}
|
||||
|
||||
do {
|
||||
length = 0;
|
||||
|
||||
#ifdef NO_IBM_PATCH_U446072
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Note that the call to fflush before each call to getc is */
|
||||
/* a workaround for a bug in the re-entrant (thread-safe) getc */
|
||||
/* function. Earlier versions of AIX did not have this problem. */
|
||||
/* Made it very specific to AIX 4.2. The bug might appear again */
|
||||
/* in future releases of AIX. Hopefully this comment would help */
|
||||
/* to identify the problem quickly in case it appears again. */
|
||||
/* -------------------------------------------------------------- */
|
||||
fflush(NULL);
|
||||
#endif
|
||||
|
||||
if ((c = getc((FILE *)m_ptr)) == EOF) return(EOF);
|
||||
|
||||
#ifdef NO_IBM_PATCH_U446072
|
||||
fflush(NULL);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
mbyte[length++] = c;
|
||||
mbyte[length] = 0;
|
||||
if (mblen(mbyte,length) != -1) break; /* hurray! */
|
||||
if (length == MB_CUR_MAX)
|
||||
{ /* reached max without a hit */
|
||||
m_error("An invalid multi-byte character was found in the input");
|
||||
c = ' ';
|
||||
length = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef NO_IBM_PATCH_U446072
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Note that the call to fflush before each call to getc is */
|
||||
/* a workaround for a bug in the re-entrant (thread-safe) getc */
|
||||
/* function. Earlier versions of AIX did not have this problem. */
|
||||
/* Made it very specific to AIX 4.2. The bug might appear again */
|
||||
/* in future releases of AIX. Hopefully this comment would help */
|
||||
/* to identify the problem quickly in case it appears again. */
|
||||
/* -------------------------------------------------------------- */
|
||||
fflush(NULL);
|
||||
#endif
|
||||
|
||||
if ((c = getc((FILE *) m_ptr)) == EOF)
|
||||
{ /* huh? */
|
||||
m_error("End-of-file found in within a multi-byte character");
|
||||
return(EOF);
|
||||
}
|
||||
}
|
||||
mbtowc(&wc,mbyte,length);
|
||||
}
|
||||
|
||||
while ((wc == wcr) || (wc == wsb));
|
||||
|
||||
/* Change tabs to spaces */
|
||||
if (wc == wtb) return((int) wsp);
|
||||
return((int) wc);
|
||||
}
|
||||
|
||||
/* Open SYSTEM entity procedure */
|
||||
void *m_openent(entcontent)
|
||||
M_WCHAR *entcontent;
|
||||
{
|
||||
FILE *open;
|
||||
char *filename;
|
||||
SEARCH *searchp;
|
||||
char *mb_entcontent;
|
||||
|
||||
mb_entcontent = MakeMByteString(entcontent);
|
||||
if (!*mb_entcontent) return NULL; /* null file name, don't open a directory */
|
||||
|
||||
open = fopen(mb_entcontent, "r");
|
||||
if (open)
|
||||
{
|
||||
m_free(mb_entcontent, "multi-byte string");
|
||||
return((void *) open);
|
||||
}
|
||||
|
||||
for (searchp = path ; searchp ; searchp = searchp->next)
|
||||
{
|
||||
filename = (char *)
|
||||
m_malloc(strlen(searchp->directory) +
|
||||
strlen(mb_entcontent) + 1,
|
||||
"filename");
|
||||
strcpy(filename, searchp->directory);
|
||||
strcat(filename, mb_entcontent);
|
||||
open = fopen(filename, "r");
|
||||
m_free(filename, "filename");
|
||||
if (open)
|
||||
{
|
||||
m_free(mb_entcontent, "multi-byte string");
|
||||
return((void *) open);
|
||||
}
|
||||
}
|
||||
|
||||
m_free(mb_entcontent, "multi-byte string");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Open input file */
|
||||
void *m_openfirst(M_NOPAR)
|
||||
{
|
||||
return((void *) inFile);
|
||||
}
|
||||
|
||||
/* Set program options */
|
||||
void m_setoptions()
|
||||
{
|
||||
if (m_argc > 2)
|
||||
{
|
||||
m_optstring(m_argv[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process signon message text, stripping out MARKUP version number, so
|
||||
only one version number will appear */
|
||||
void m_signmsg(p)
|
||||
char *p;
|
||||
{
|
||||
char *q;
|
||||
char *pCopy;
|
||||
|
||||
if (q = strstr(p, VERSION)) {
|
||||
pCopy = strdup(p);
|
||||
q = strstr(pCopy, VERSION);
|
||||
*q = M_EOS;
|
||||
m_errline(pCopy);
|
||||
free(pCopy);
|
||||
return;
|
||||
}
|
||||
m_errline(p);
|
||||
}
|
||||
|
||||
/* All entity declarations have been processed. */
|
||||
void m_startdoc()
|
||||
{
|
||||
}
|
||||
|
||||
/* Write debugging trace information */
|
||||
void m_trace(p)
|
||||
char *p;
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void m_wctrace(p)
|
||||
M_WCHAR *p;
|
||||
{
|
||||
char *mb_p;
|
||||
|
||||
mb_p = MakeMByteString(p);
|
||||
m_trace(mb_p);
|
||||
m_free(mb_p,"multi-byte string");
|
||||
}
|
||||
73
cde/programs/dthelp/parser/pass2/htag2/delim.bld
Normal file
73
cde/programs/dthelp/parser/pass2/htag2/delim.bld
Normal file
@@ -0,0 +1,73 @@
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
Delimiter definitions for BUILD.
|
||||
|
||||
comment --
|
||||
produces ->
|
||||
except <EXCEPT>
|
||||
paropen <!PARAM
|
||||
param <PARAM>
|
||||
shortref <!SHORTREF
|
||||
usemap <USEMAP
|
||||
addmap <ADDMAP
|
||||
empty #EMPTY
|
||||
entstart <!ENTITY
|
||||
tagc >
|
||||
ero &
|
||||
entsystem FILE
|
||||
entst STARTTAG
|
||||
entet ENDTAG
|
||||
entmd MD
|
||||
entpi PI
|
||||
entsdata SDATA
|
||||
min <MIN>
|
||||
grpo (
|
||||
grpc )
|
||||
emi !
|
||||
incl +
|
||||
excl -
|
||||
psep ,
|
||||
rend ;
|
||||
opt ?
|
||||
plus +
|
||||
rep *
|
||||
seq ,
|
||||
or |
|
||||
and &
|
||||
vi =
|
||||
entlit "
|
||||
lit "
|
||||
entlita '
|
||||
lita '
|
||||
rnicdata #PCDATA
|
||||
connor |
|
||||
connseq ,
|
||||
connand &
|
||||
current #CURRENT
|
||||
required #REQUIRED
|
||||
nulldef #IMPLIED
|
||||
any ANY
|
||||
none EMPTY
|
||||
rcdata RCDATA
|
||||
cdata CDATA
|
||||
cro &#
|
||||
litrs &#RS
|
||||
litrsc &#RS;
|
||||
litre &#RE
|
||||
litrec &#RE;
|
||||
littab &#TAB
|
||||
littabc &#TAB;
|
||||
litspace &#SPACE
|
||||
litcspace &#SPACE;
|
||||
refc ;
|
||||
id ID
|
||||
idref IDREF
|
||||
idrefs IDREFS
|
||||
nametype NAME
|
||||
names NAMES
|
||||
nmtoken NAMETOKEN
|
||||
nmtokens NAMETOKENS
|
||||
number NUMBER
|
||||
numbers NUMBERS
|
||||
nutoken NUMBERTOKEN
|
||||
nutokens NUMBERTOKENS
|
||||
entatt ENTITY
|
||||
58
cde/programs/dthelp/parser/pass2/htag2/delim.elt
Normal file
58
cde/programs/dthelp/parser/pass2/htag2/delim.elt
Normal file
@@ -0,0 +1,58 @@
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
Delimiter definitions for ELTDEF.
|
||||
|
||||
startcomment /*
|
||||
endcomment */
|
||||
entstart <!ENTITY
|
||||
entsystem FILE
|
||||
entst STARTTAG
|
||||
entet ENDTAG
|
||||
entmd MD
|
||||
entpi PI
|
||||
entsdata SDATA
|
||||
entcdata CDATA
|
||||
typecode CODE
|
||||
endofcode <\CODE>
|
||||
entlit "
|
||||
entlita '
|
||||
lit "
|
||||
lita '
|
||||
cro &#
|
||||
litrs &#RS
|
||||
litrsc &#RS;
|
||||
litre &#RE
|
||||
litrec &#RE;
|
||||
littab &#TAB
|
||||
littabc &#TAB;
|
||||
litspace &#SPACE
|
||||
litcspace &#SPACE;
|
||||
refc ;
|
||||
signon <SIGN-ON>
|
||||
gdef <GLOBAL-DEFINE>
|
||||
gdec <GLOBAL-DECLARE>
|
||||
elt <ELEMENT
|
||||
tagc >
|
||||
sep ,
|
||||
grpo (
|
||||
grpc )
|
||||
param <PARAM>
|
||||
vi =
|
||||
rend ;
|
||||
inisstring <START-STRING>
|
||||
sss <START-STRING
|
||||
iniestring <END-STRING>
|
||||
ess <\START-STRING>
|
||||
ses <END-STRING
|
||||
ees <\END-STRING>
|
||||
inistart <START-CODE>
|
||||
scode <START-CODE
|
||||
iniend <END-CODE>
|
||||
ecode <END-CODE
|
||||
initext <TEXT-CODE>
|
||||
tcode <TEXT-CODE
|
||||
initpi <PI-CODE>
|
||||
pcode <PI-CODE
|
||||
inistring <STRING-CODE>
|
||||
stcode <STRING-CODE
|
||||
wildcard *
|
||||
|
||||
39
cde/programs/dthelp/parser/pass2/htag2/delim.par
Normal file
39
cde/programs/dthelp/parser/pass2/htag2/delim.par
Normal file
@@ -0,0 +1,39 @@
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
Delimiter definitions for PARSER.
|
||||
|
||||
m_comment --
|
||||
m_mdo <!
|
||||
m_mdc >
|
||||
m_usemap USEMAP
|
||||
m_addmap ADDMAP
|
||||
m_empty #EMPTY
|
||||
m_entkw ENTITY
|
||||
m_entst STARTTAG
|
||||
m_entet ENDTAG
|
||||
m_entcdata CDATA
|
||||
m_entsdata SDATA
|
||||
m_entsystem SYSTEM
|
||||
m_entmd MD
|
||||
m_entpi PI
|
||||
m_stago <
|
||||
m_etago </
|
||||
m_pio <?
|
||||
m_tagc >
|
||||
m_pic >
|
||||
m_vi =
|
||||
m_lit "
|
||||
m_litdelim "
|
||||
m_lita '
|
||||
m_litadelim '
|
||||
m_cro &#
|
||||
m_litrs &#RS
|
||||
m_litscr &#RS;
|
||||
m_litre &#RE
|
||||
m_litecr &#RE;
|
||||
m_litspace &#SPACE
|
||||
m_litcspace &#SPACE;
|
||||
m_littab &#TAB
|
||||
m_litctab &#TAB;
|
||||
m_ero ~+V%9a$|lwhy
|
||||
m_refc ;
|
||||
m_net |
|
||||
271
cde/programs/dthelp/parser/pass2/htag2/fproto.h
Normal file
271
cde/programs/dthelp/parser/pass2/htag2/fproto.h
Normal file
@@ -0,0 +1,271 @@
|
||||
/* $XConsortium: fproto.h /main/3 1995/11/08 10:46:14 rswiston $ */
|
||||
/* Copyright (c) 1988, 1989, 1990 Hewlett-Packard Co. */
|
||||
/* Function prototypes for HP Tag/TeX translator */
|
||||
|
||||
|
||||
int m_lower(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void options(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL filelenonly
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void setopt(
|
||||
#if defined(M_PROTO)
|
||||
char *string, LOGICAL filelenonly
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL setvalopt(
|
||||
#if defined(M_PROTO)
|
||||
int thisopt, char *string, LOGICAL filelenonly
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *strstr(
|
||||
#if defined(M_PROTO)
|
||||
const char *s1, const char *s2
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_upper(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *MakeMByteString(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *from
|
||||
#endif
|
||||
);
|
||||
|
||||
M_WCHAR *MakeWideCharString(
|
||||
#if defined(M_PROTO)
|
||||
const char *from
|
||||
#endif
|
||||
);
|
||||
|
||||
void PutString(
|
||||
#if defined(M_PROTO)
|
||||
char *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void PutWString(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void PutWChar(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR wchar
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void SaveWChar(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR wchar
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void OpenTag(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL hasAttributes,
|
||||
LOGICAL newlineOK
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void CloseTag(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL newlineOK
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void ImpliedlAttribute(
|
||||
#if defined(M_PROTO)
|
||||
char *name,
|
||||
M_WCHAR *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void RequiredAttribute(
|
||||
#if defined(M_PROTO)
|
||||
char *name,
|
||||
M_WCHAR *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *CopyWString(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void MakeNewElement(
|
||||
#if defined(M_PROTO)
|
||||
ElementTypes type
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void DeleteElement(
|
||||
#if defined(M_PROTO)
|
||||
ElementPtr pElement
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void OptimizeAndEmit(
|
||||
#if defined(M_PROTO)
|
||||
ElementPtr pVirpage
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void PushCurrentElement(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void PopCurrentElement(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
char *mb_realloc(
|
||||
#if defined(M_PROTO)
|
||||
char *ptr, long size
|
||||
#endif
|
||||
);
|
||||
|
||||
char *mb_malloc(
|
||||
#if defined(M_PROTO)
|
||||
long size
|
||||
#endif
|
||||
);
|
||||
|
||||
void mb_free(
|
||||
#if defined(M_PROTO)
|
||||
char **pptr
|
||||
#endif
|
||||
);
|
||||
|
||||
void EmitSDL(
|
||||
#if defined(M_PROTO)
|
||||
ElementPtr pVirpage
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int OpenFile(
|
||||
#if defined(M_PROTO)
|
||||
char *name, int type, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int ReadFile(
|
||||
#if defined(M_PROTO)
|
||||
int fd, char *name, char *buffer, int amount, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int WriteFile(
|
||||
#if defined(M_PROTO)
|
||||
int fd, char *name, char *buffer, int amount, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int FileExists(
|
||||
#if defined(M_PROTO)
|
||||
char *name
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void AssertFileIsReadable(
|
||||
#if defined(M_PROTO)
|
||||
char *name, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int FileSize(
|
||||
#if defined(M_PROTO)
|
||||
char *name, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void CloseFile(
|
||||
#if defined(M_PROTO)
|
||||
int fd, char *name, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
FILE *FopenFile(
|
||||
#if defined(M_PROTO)
|
||||
char *name, int type, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int GetALine(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, char *name, char *line, int max, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int FreadFile(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, char *name, char *buffer, int amount, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void FwriteFile(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, char *name, char *buffer, size_t amount, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void FcloseFile(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, char *name, int code
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int StringToUpper(
|
||||
#if defined(M_PROTO)
|
||||
char *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void BuildIndex(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void OpenDocument(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void CloseDocument(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void UpdateTossFileName(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void SetLocale(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *pLang, M_WCHAR *pCharset
|
||||
#endif
|
||||
) ;
|
||||
782
cde/programs/dthelp/parser/pass2/htag2/global.h
Normal file
782
cde/programs/dthelp/parser/pass2/htag2/global.h
Normal file
@@ -0,0 +1,782 @@
|
||||
/* $TOG: global.h /main/4 1998/04/06 13:19:19 mgreess $ */
|
||||
/* Copyright (c) 1988, 1989 Hewlett-Packard Co. */
|
||||
/* Global definitions for HP Tag/TeX translator */
|
||||
/* When changing this file, check "grphpar.h" for conflicts */
|
||||
|
||||
#if defined(DEFINE)
|
||||
#define EXTERN
|
||||
#define INIT(a) = a
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#define INIT(a)
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#if defined(MSDOS)
|
||||
#include <io.h>
|
||||
#include <stdlib.h>
|
||||
#include <process.h>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__) || defined(linux)
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef MB_MAX_LEN
|
||||
#define MB_MAX_LEN 4
|
||||
#endif
|
||||
|
||||
#ifndef WCOREDUMP
|
||||
#define WCOREDUMP(_X) ((int)(_X)&0200)
|
||||
#endif
|
||||
|
||||
/*????????????????????????????????????????????????????*/
|
||||
EXTERN LOGICAL stoponerror INIT(TRUE) ;
|
||||
|
||||
EXTERN char dirsep INIT('/') ;
|
||||
EXTERN char *indir INIT(NULL) ;
|
||||
EXTERN char *nodirbase ;
|
||||
EXTERN char *install INIT(NULL) ;
|
||||
|
||||
typedef struct search SEARCH ;
|
||||
struct search {
|
||||
char *directory ;
|
||||
SEARCH *next ;
|
||||
} ;
|
||||
EXTERN SEARCH *path INIT(NULL) ;
|
||||
EXTERN SEARCH **endpath INIT(&path) ;
|
||||
|
||||
/*====================================================*/
|
||||
#define xxx 1
|
||||
|
||||
/* Must be in same order as values in optkey, adjust NUMOPTIONS if changed*/
|
||||
#define ONERROR 1
|
||||
|
||||
#define NUMOPTIONS 1
|
||||
|
||||
EXTERN int optval INIT(M_NULLVAL) ;
|
||||
|
||||
EXTERN char *optkey[NUMOPTIONS]
|
||||
#if defined(DEFINE)
|
||||
= {
|
||||
"onerror",
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define RS '\036'
|
||||
#define LINEMAX (BUFSIZ * 8)
|
||||
|
||||
EXTERN LOGICAL haveIndex INIT(FALSE);
|
||||
|
||||
#define TMPDIR "/tmp"
|
||||
#define VERSION "Version"
|
||||
|
||||
#define SDLNAMESIZ sizeof("SDL-RESERVED")
|
||||
EXTERN char sdlReservedName[] INIT("SDL-RESERVED");
|
||||
|
||||
#define DOTSDLSIZ sizeof(".sdl")
|
||||
EXTERN char dotSDL[] INIT(".sdl");
|
||||
#define DOTERRSIZ sizeof(".err")
|
||||
EXTERN char dotERR[] INIT(".err");
|
||||
#define DOTIDXSIZ sizeof(".idx")
|
||||
EXTERN char dotIDX[] INIT(".idx");
|
||||
#define DOTSNBSIZ sizeof(".snb")
|
||||
EXTERN char dotSNB[] INIT(".snb");
|
||||
#define DOTTSSSIZ sizeof(".tss")
|
||||
EXTERN char dotTSS[] INIT(".tss");
|
||||
|
||||
/* set to TRUE if the user asks for compression */
|
||||
EXTERN LOGICAL compressFlag INIT(FALSE);
|
||||
/* set to TRUE if the user asks for optimization */
|
||||
EXTERN LOGICAL optimizeFlag INIT(FALSE);
|
||||
/* set to TRUE if the user asks for <toss> to be necessary and sufficient */
|
||||
EXTERN LOGICAL minimalTossFlag INIT(FALSE);
|
||||
/* set to TRUE if the user asks for decompression */
|
||||
EXTERN LOGICAL decompressFlag INIT(FALSE);
|
||||
|
||||
/* we change outFile from vstructFile to tempFile upon first virpage */
|
||||
EXTERN LOGICAL firstVirpage INIT(TRUE);
|
||||
EXTERN long int vstructSize INIT(0);
|
||||
|
||||
/* the base name of this program - used in error messages */
|
||||
EXTERN char *progName INIT(NULL);
|
||||
|
||||
/*
|
||||
* Names for all the input, output and intermediate files we'll need.
|
||||
*/
|
||||
char *inFileName;
|
||||
char *outFileName;
|
||||
char *errFileName;
|
||||
char *idxFileName;
|
||||
char *snbFileName;
|
||||
char *sortedIdxFileName;
|
||||
char *tossFileName;
|
||||
char *vstructFileName;
|
||||
char *tempFileName;
|
||||
char *compFileName;
|
||||
char *compZFileName;
|
||||
|
||||
FILE *inFile;
|
||||
FILE *outFile;
|
||||
|
||||
typedef struct _loidsRec *LoidsPtr;
|
||||
typedef struct _loidsRec {
|
||||
char *type;
|
||||
char *rid;
|
||||
char *rssi;
|
||||
char *rlevel;
|
||||
long int offset;
|
||||
LoidsPtr next;
|
||||
} LoidsRec;
|
||||
|
||||
EXTERN LoidsRec loids; /* first node is a dummy to make the logic easier */
|
||||
EXTERN LoidsPtr pLoidsEnd INIT(&loids);
|
||||
|
||||
EXTERN int startOfLOIDS INIT(0);
|
||||
EXTERN int startOfIndex INIT(0);
|
||||
EXTERN int startOfLOPhrases INIT(0);
|
||||
EXTERN int startOfTOSS INIT(0);
|
||||
EXTERN int endOfLOIDS INIT(0);
|
||||
EXTERN int endOfIndex INIT(0);
|
||||
EXTERN int endOfLOPhrases INIT(0);
|
||||
EXTERN int endOfTOSS INIT(0);
|
||||
|
||||
typedef enum _element_types {
|
||||
e_sdldoc,
|
||||
e_vstruct,
|
||||
e_virpage,
|
||||
e_snb,
|
||||
e_block,
|
||||
e_form,
|
||||
e_fstyle,
|
||||
e_frowvec,
|
||||
e_fdata,
|
||||
e_p,
|
||||
e_cp,
|
||||
e_head,
|
||||
e_subhead,
|
||||
e_anchor,
|
||||
e_link,
|
||||
e_snref,
|
||||
e_refitem,
|
||||
e_alttext,
|
||||
e_rev,
|
||||
e_key,
|
||||
e_sphrase,
|
||||
e_if,
|
||||
e_cond,
|
||||
e_then,
|
||||
e_else,
|
||||
e_spc,
|
||||
e_graphic,
|
||||
e_text,
|
||||
e_audio,
|
||||
e_video,
|
||||
e_animate,
|
||||
e_script,
|
||||
e_crossdoc,
|
||||
e_man_page,
|
||||
e_textfile,
|
||||
e_sys_cmd,
|
||||
e_callback,
|
||||
e_switch,
|
||||
e_rel_docs,
|
||||
e_rel_file,
|
||||
e_notes,
|
||||
e_loids,
|
||||
e_id,
|
||||
e_index,
|
||||
e_entry,
|
||||
e_lophrases,
|
||||
e_phrase,
|
||||
e_toss,
|
||||
e_keystyle,
|
||||
e_headstyle,
|
||||
e_formstyle,
|
||||
e_frmtstyle,
|
||||
e_grphstyle,
|
||||
e_cdata
|
||||
} ElementTypes;
|
||||
|
||||
typedef struct _element *ElementPtr;
|
||||
|
||||
typedef struct _sdldoc {
|
||||
ElementPtr pVstruct;
|
||||
ElementPtr pHead;
|
||||
ElementPtr pSnb;
|
||||
ElementPtr pVirpage;
|
||||
M_WCHAR *pub_id;
|
||||
M_WCHAR *doc_id;
|
||||
M_WCHAR *timestmp;
|
||||
M_WCHAR *first_page;
|
||||
M_WCHAR *product;
|
||||
M_WCHAR *prodpn;
|
||||
M_WCHAR *prodver;
|
||||
M_WCHAR *license;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *author;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *sdldtd;
|
||||
M_WCHAR *srcdtd;
|
||||
} Sdldoc_el;
|
||||
|
||||
typedef struct _vstruct {
|
||||
ElementPtr pLoids;
|
||||
ElementPtr pToss;
|
||||
ElementPtr pLophrases;
|
||||
ElementPtr pIndex;
|
||||
ElementPtr pRel_docs;
|
||||
ElementPtr pRel_file;
|
||||
ElementPtr pNotes;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *doc_id;
|
||||
} Vstruct_el;
|
||||
|
||||
typedef struct _virpage {
|
||||
ElementPtr pHead;
|
||||
ElementPtr pSnb;
|
||||
ElementPtr pBlockOrForm;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *level;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *doc_id;
|
||||
M_WCHAR *ssi;
|
||||
} Virpage_el;
|
||||
|
||||
typedef struct _snb {
|
||||
ElementPtr pHead;
|
||||
ElementPtr pSystemNotations;
|
||||
M_WCHAR *version;
|
||||
} Snb_el;
|
||||
|
||||
typedef struct _block {
|
||||
ElementPtr pHead;
|
||||
ElementPtr pCpOrP;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *level;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *length;
|
||||
M_WCHAR *app;
|
||||
M_WCHAR *timing;
|
||||
M_WCHAR *ssi;
|
||||
} Block_el;
|
||||
|
||||
typedef struct _form {
|
||||
ElementPtr pHead;
|
||||
ElementPtr pFdata;
|
||||
ElementPtr pFstyle;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *level;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *length;
|
||||
M_WCHAR *app;
|
||||
M_WCHAR *ssi;
|
||||
} Form_el;
|
||||
|
||||
typedef struct _fstyle {
|
||||
ElementPtr pFrowvec;
|
||||
M_WCHAR *ncols;
|
||||
} Fstyle_el;
|
||||
|
||||
typedef struct _frowvec {
|
||||
M_WCHAR *hdr;
|
||||
M_WCHAR *cells;
|
||||
} Frowvec_el;
|
||||
|
||||
typedef struct _fdata {
|
||||
ElementPtr pBlockOrForm;
|
||||
} Fdata_el;
|
||||
|
||||
typedef struct _p {
|
||||
ElementPtr pHead;
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *type;
|
||||
M_WCHAR *ssi;
|
||||
} P_el;
|
||||
|
||||
typedef struct _cp {
|
||||
ElementPtr pCDATA;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *type;
|
||||
M_WCHAR *ssi;
|
||||
} Cp_el;
|
||||
|
||||
typedef struct _head {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
ElementPtr pSubhead;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *type;
|
||||
M_WCHAR *abbrev;
|
||||
M_WCHAR *ssi;
|
||||
} Head_el;
|
||||
|
||||
typedef struct _subhead {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *version;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *type;
|
||||
M_WCHAR *abbrev;
|
||||
M_WCHAR *ssi;
|
||||
} Subhead_el;
|
||||
|
||||
typedef struct _anchor {
|
||||
M_WCHAR *id;
|
||||
} Anchor_el;
|
||||
|
||||
typedef struct _link {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
M_WCHAR *rid;
|
||||
M_WCHAR *button;
|
||||
M_WCHAR *linkinfo;
|
||||
M_WCHAR *descript;
|
||||
M_WCHAR *window;
|
||||
M_WCHAR *traversal;
|
||||
} Link_el;
|
||||
|
||||
typedef struct _snref {
|
||||
ElementPtr pRefitem;
|
||||
ElementPtr pAlttext;
|
||||
M_WCHAR *id;
|
||||
} Snref_el;
|
||||
|
||||
typedef struct _refitem {
|
||||
ElementPtr pHead;
|
||||
ElementPtr pReferencedItem;
|
||||
M_WCHAR *rid;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *button;
|
||||
M_WCHAR *ssi;
|
||||
} Refitem_el;
|
||||
|
||||
typedef struct _alttext {
|
||||
ElementPtr pCDATA;
|
||||
} Alttext_el;
|
||||
|
||||
typedef struct _rev {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
} Rev_el;
|
||||
|
||||
typedef struct _key {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
M_WCHAR *charset;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
} Key_el;
|
||||
|
||||
typedef struct _sphrase {
|
||||
ElementPtr pSpcOrPCDATA;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
} Sphrase_el;
|
||||
|
||||
typedef struct _if {
|
||||
ElementPtr pCond;
|
||||
ElementPtr pThen;
|
||||
ElementPtr pElse;
|
||||
} If_el;
|
||||
|
||||
typedef struct _cond {
|
||||
ElementPtr pCDATA;
|
||||
M_WCHAR *interp;
|
||||
} Cond_el;
|
||||
|
||||
typedef struct _then {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
} Then_el;
|
||||
|
||||
typedef struct _else {
|
||||
ElementPtr pAtomicOrPCDATA;
|
||||
} Else_el;
|
||||
|
||||
typedef struct _spc {
|
||||
M_WCHAR *name;
|
||||
} Spc_el;
|
||||
|
||||
typedef struct _graphic {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *format;
|
||||
M_WCHAR *method;
|
||||
M_WCHAR *xid;
|
||||
} Graphic_el;
|
||||
|
||||
typedef struct _text {
|
||||
ElementPtr pCpOrP;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *language;
|
||||
M_WCHAR *charset;
|
||||
} Text_el;
|
||||
|
||||
typedef struct _audio {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *format;
|
||||
M_WCHAR *method;
|
||||
M_WCHAR *xid;
|
||||
} Audio_el;
|
||||
|
||||
typedef struct _video {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *format;
|
||||
M_WCHAR *method;
|
||||
M_WCHAR *xid;
|
||||
} Video_el;
|
||||
|
||||
typedef struct _animate {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *format;
|
||||
M_WCHAR *method;
|
||||
M_WCHAR *xid;
|
||||
} Animate_el;
|
||||
|
||||
typedef struct _script {
|
||||
ElementPtr pCDATA;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *interp;
|
||||
} Script_el;
|
||||
|
||||
typedef struct _crossdoc {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *xid;
|
||||
} Crossdoc_el;
|
||||
|
||||
typedef struct _man_page {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *xid;
|
||||
} Man_page_el;
|
||||
|
||||
typedef struct _textfile {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *xid;
|
||||
M_WCHAR *offset;
|
||||
M_WCHAR *format;
|
||||
} Textfile_el;
|
||||
|
||||
typedef struct _sys_cmd {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *command;
|
||||
} Sys_cmd_el;
|
||||
|
||||
typedef struct _callback {
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *data;
|
||||
} Callback_el;
|
||||
|
||||
typedef struct _switch {
|
||||
ElementPtr pCDATA;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *interp;
|
||||
M_WCHAR *branches;
|
||||
} Switch_el;
|
||||
|
||||
typedef struct _rel_docs {
|
||||
void *no_attrs;
|
||||
} Rel_docs_el;
|
||||
|
||||
typedef struct _rel_file {
|
||||
void *no_attrs;
|
||||
} Rel_file_el;
|
||||
|
||||
typedef struct _notes {
|
||||
void *no_attrs;
|
||||
} Notes_el;
|
||||
|
||||
typedef struct _loids {
|
||||
ElementPtr pId;
|
||||
} Loids_el;
|
||||
|
||||
typedef struct _id {
|
||||
M_WCHAR *type;
|
||||
M_WCHAR *rid;
|
||||
M_WCHAR *rssi;
|
||||
M_WCHAR *rlevel;
|
||||
M_WCHAR *offset;
|
||||
} Id_el;
|
||||
|
||||
typedef struct _index {
|
||||
ElementPtr pEntry;
|
||||
M_WCHAR *head;
|
||||
} Index_el;
|
||||
|
||||
typedef struct _entry {
|
||||
ElementPtr pSimpleOrPCDATA;
|
||||
ElementPtr pEntry;
|
||||
M_WCHAR *id;
|
||||
M_WCHAR *main;
|
||||
M_WCHAR *locs;
|
||||
M_WCHAR *syns;
|
||||
M_WCHAR *sort;
|
||||
} Entry_el;
|
||||
|
||||
typedef struct _lophrases {
|
||||
ElementPtr pPhrase;
|
||||
} Lophrases_el;
|
||||
|
||||
typedef struct _phrase {
|
||||
M_WCHAR *text;
|
||||
} Phrase_el;
|
||||
|
||||
typedef struct _toss {
|
||||
ElementPtr pKeyStyle;
|
||||
ElementPtr pHeadStyle;
|
||||
ElementPtr pFormStyle;
|
||||
ElementPtr pFrmtStyle;
|
||||
ElementPtr pGrphStyle;
|
||||
} Toss_el;
|
||||
|
||||
typedef struct _keystyle {
|
||||
LOGICAL beenUsed;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
M_WCHAR *rlevel;
|
||||
M_WCHAR *phrase;
|
||||
M_WCHAR *srch_wt;
|
||||
M_WCHAR *enter;
|
||||
M_WCHAR *exit;
|
||||
M_WCHAR *pointsz;
|
||||
M_WCHAR *set_width;
|
||||
M_WCHAR *color;
|
||||
M_WCHAR *xlfd;
|
||||
M_WCHAR *xlfdi;
|
||||
M_WCHAR *xlfdb;
|
||||
M_WCHAR *xlfdib;
|
||||
M_WCHAR *typenam;
|
||||
M_WCHAR *typenami;
|
||||
M_WCHAR *typenamb;
|
||||
M_WCHAR *typenamib;
|
||||
M_WCHAR *style;
|
||||
M_WCHAR *spacing;
|
||||
M_WCHAR *weight;
|
||||
M_WCHAR *slant;
|
||||
M_WCHAR *special;
|
||||
} Keystyle_el;
|
||||
|
||||
typedef struct _headstyle {
|
||||
LOGICAL beenUsed;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
M_WCHAR *rlevel;
|
||||
M_WCHAR *phrase;
|
||||
M_WCHAR *srch_wt;
|
||||
M_WCHAR *orient;
|
||||
M_WCHAR *vorient;
|
||||
M_WCHAR *placement;
|
||||
M_WCHAR *headw;
|
||||
M_WCHAR *stack;
|
||||
M_WCHAR *flow;
|
||||
M_WCHAR *pointsz;
|
||||
M_WCHAR *set_width;
|
||||
M_WCHAR *color;
|
||||
M_WCHAR *xlfd;
|
||||
M_WCHAR *xlfdi;
|
||||
M_WCHAR *xlfdb;
|
||||
M_WCHAR *xlfdib;
|
||||
M_WCHAR *typenam;
|
||||
M_WCHAR *typenami;
|
||||
M_WCHAR *typenamb;
|
||||
M_WCHAR *typenamib;
|
||||
M_WCHAR *style;
|
||||
M_WCHAR *spacing;
|
||||
M_WCHAR *weight;
|
||||
M_WCHAR *slant;
|
||||
M_WCHAR *special;
|
||||
M_WCHAR *l_margin;
|
||||
M_WCHAR *r_margin;
|
||||
M_WCHAR *t_margin;
|
||||
M_WCHAR *b_margin;
|
||||
M_WCHAR *border;
|
||||
M_WCHAR *vjust;
|
||||
M_WCHAR *justify;
|
||||
} Headstyle_el;
|
||||
|
||||
typedef struct _formstyle {
|
||||
LOGICAL beenUsed;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
M_WCHAR *rlevel;
|
||||
M_WCHAR *phrase;
|
||||
M_WCHAR *srch_wt;
|
||||
M_WCHAR *colw;
|
||||
M_WCHAR *colj;
|
||||
M_WCHAR *pointsz;
|
||||
M_WCHAR *set_width;
|
||||
M_WCHAR *color;
|
||||
M_WCHAR *xlfd;
|
||||
M_WCHAR *xlfdi;
|
||||
M_WCHAR *xlfdb;
|
||||
M_WCHAR *xlfdib;
|
||||
M_WCHAR *typenam;
|
||||
M_WCHAR *typenami;
|
||||
M_WCHAR *typenamb;
|
||||
M_WCHAR *typenamib;
|
||||
M_WCHAR *style;
|
||||
M_WCHAR *spacing;
|
||||
M_WCHAR *weight;
|
||||
M_WCHAR *slant;
|
||||
M_WCHAR *special;
|
||||
M_WCHAR *l_margin;
|
||||
M_WCHAR *r_margin;
|
||||
M_WCHAR *t_margin;
|
||||
M_WCHAR *b_margin;
|
||||
M_WCHAR *border;
|
||||
M_WCHAR *vjust;
|
||||
} Formstyle_el;
|
||||
|
||||
typedef struct _frmtstyle {
|
||||
LOGICAL beenUsed;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
M_WCHAR *rlevel;
|
||||
M_WCHAR *phrase;
|
||||
M_WCHAR *f_margin;
|
||||
M_WCHAR *srch_wt;
|
||||
M_WCHAR *pointsz;
|
||||
M_WCHAR *set_width;
|
||||
M_WCHAR *color;
|
||||
M_WCHAR *xlfd;
|
||||
M_WCHAR *xlfdi;
|
||||
M_WCHAR *xlfdb;
|
||||
M_WCHAR *xlfdib;
|
||||
M_WCHAR *typenam;
|
||||
M_WCHAR *typenami;
|
||||
M_WCHAR *typenamb;
|
||||
M_WCHAR *typenamib;
|
||||
M_WCHAR *style;
|
||||
M_WCHAR *spacing;
|
||||
M_WCHAR *weight;
|
||||
M_WCHAR *slant;
|
||||
M_WCHAR *special;
|
||||
M_WCHAR *l_margin;
|
||||
M_WCHAR *r_margin;
|
||||
M_WCHAR *t_margin;
|
||||
M_WCHAR *b_margin;
|
||||
M_WCHAR *border;
|
||||
M_WCHAR *vjust;
|
||||
M_WCHAR *justify;
|
||||
} Frmtstyle_el;
|
||||
|
||||
typedef struct _grphstyle {
|
||||
LOGICAL beenUsed;
|
||||
M_WCHAR *class;
|
||||
M_WCHAR *ssi;
|
||||
M_WCHAR *rlevel;
|
||||
M_WCHAR *phrase;
|
||||
M_WCHAR *l_margin;
|
||||
M_WCHAR *r_margin;
|
||||
M_WCHAR *t_margin;
|
||||
M_WCHAR *b_margin;
|
||||
M_WCHAR *border;
|
||||
M_WCHAR *vjust;
|
||||
M_WCHAR *justify;
|
||||
} Grphstyle_el;
|
||||
|
||||
typedef struct _cdata {
|
||||
M_WCHAR *buffer;
|
||||
int buffPos;
|
||||
int buffSize;
|
||||
} CDATA_el;
|
||||
|
||||
typedef struct _element {
|
||||
ElementTypes type;
|
||||
ElementPtr pNext;
|
||||
LOGICAL beenEmitted;
|
||||
LOGICAL tossChecked;
|
||||
M_WCHAR *inheritedLevel;
|
||||
M_WCHAR *inheritedClass;
|
||||
union {
|
||||
Sdldoc_el u_sdldoc;
|
||||
Vstruct_el u_vstruct;
|
||||
Virpage_el u_virpage;
|
||||
Snb_el u_snb;
|
||||
Block_el u_block;
|
||||
Form_el u_form;
|
||||
Fstyle_el u_fstyle;
|
||||
Frowvec_el u_frowvec;
|
||||
Fdata_el u_fdata;
|
||||
P_el u_p;
|
||||
Cp_el u_cp;
|
||||
Head_el u_head;
|
||||
Subhead_el u_subhead;
|
||||
Anchor_el u_anchor;
|
||||
Link_el u_link;
|
||||
Snref_el u_snref;
|
||||
Refitem_el u_refitem;
|
||||
Alttext_el u_alttext;
|
||||
Rev_el u_rev;
|
||||
Key_el u_key;
|
||||
Sphrase_el u_sphrase;
|
||||
If_el u_if;
|
||||
Cond_el u_cond;
|
||||
Then_el u_then;
|
||||
Else_el u_else;
|
||||
Spc_el u_spc;
|
||||
Graphic_el u_graphic;
|
||||
Text_el u_text;
|
||||
Audio_el u_audio;
|
||||
Video_el u_video;
|
||||
Animate_el u_animate;
|
||||
Script_el u_script;
|
||||
Crossdoc_el u_crossdoc;
|
||||
Man_page_el u_man_page;
|
||||
Textfile_el u_textfile;
|
||||
Sys_cmd_el u_sys_cmd;
|
||||
Callback_el u_callback;
|
||||
Switch_el u_switch;
|
||||
Rel_docs_el u_rel_docs;
|
||||
Rel_file_el u_rel_file;
|
||||
Notes_el u_notes;
|
||||
Loids_el u_loids;
|
||||
Id_el u_id;
|
||||
Index_el u_index;
|
||||
Entry_el u_entry;
|
||||
Lophrases_el u_lophrases;
|
||||
Phrase_el u_phrase;
|
||||
Toss_el u_toss;
|
||||
Keystyle_el u_keystyle;
|
||||
Headstyle_el u_headstyle;
|
||||
Formstyle_el u_formstyle;
|
||||
Frmtstyle_el u_frmtstyle;
|
||||
Grphstyle_el u_grphstyle;
|
||||
CDATA_el u_cdata;
|
||||
} u;
|
||||
} Element;
|
||||
|
||||
EXTERN ElementPtr pCurrentElement INIT(NULL);
|
||||
|
||||
/* variables for counting entry, phrase and style elements */
|
||||
EXTERN ElementPtr pElementChain INIT(NULL);
|
||||
EXTERN int nElements;
|
||||
|
||||
/* save the toss for later emission */
|
||||
EXTERN ElementPtr pTossChain INIT(NULL);
|
||||
EXTERN int nStyles;
|
||||
|
||||
EXTERN int saveSysECnt INIT(-1);
|
||||
|
||||
/* Function prototypes */
|
||||
#include "fproto.h"
|
||||
227
cde/programs/dthelp/parser/pass2/htag2/option.c
Normal file
227
cde/programs/dthelp/parser/pass2/htag2/option.c
Normal file
@@ -0,0 +1,227 @@
|
||||
/* $XConsortium: option.c /main/3 1995/11/08 10:46:37 rswiston $ */
|
||||
/* Copyright (c) 1986, 1987, 1988, 1989, 1992 Hewlett-Packard Co. */
|
||||
/* Functions for command-line options for Help Tag/Cache Creek translator */
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__)
|
||||
/* get definition of getenv(3c) for getting of environment variables */
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Interpret options from command line and specified files */
|
||||
#define OPTLEN 512 /* If OPTLEN changes, change fscanf call below */
|
||||
#define TAGDOTOPT "helptag.opt"
|
||||
#define DOTOPT ".opt"
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void options(LOGICAL filelenonly)
|
||||
#else
|
||||
void options(filelenonly)
|
||||
LOGICAL filelenonly;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
FILE *optfile;
|
||||
char option[OPTLEN + 1];
|
||||
char *nameofoptfile;
|
||||
|
||||
/* Check helptag.opt in installation directory */
|
||||
nameofoptfile = (char *) m_malloc(strlen(install) + strlen(TAGDOTOPT) + 1,
|
||||
"installation helptag.opt");
|
||||
strcpy(nameofoptfile, install);
|
||||
strcat(nameofoptfile, TAGDOTOPT);
|
||||
if (optfile = fopen(nameofoptfile, "r"))
|
||||
{
|
||||
while (fscanf(optfile, "%512s", option) != EOF)
|
||||
setopt(option, filelenonly);
|
||||
fclose(optfile);
|
||||
}
|
||||
m_free(nameofoptfile, "installation helptag.opt");
|
||||
|
||||
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__)|| defined(__osf__)
|
||||
{
|
||||
char *opts;
|
||||
|
||||
/* Check options in $TAGOPT */
|
||||
opts = getenv("TAGOPT");
|
||||
if (opts)
|
||||
{
|
||||
while (m_whitespace(*opts)) opts++;
|
||||
while (sscanf(opts, "%512s", option) != EOF)
|
||||
{
|
||||
setopt(option, filelenonly);
|
||||
opts += strlen(option);
|
||||
while (m_whitespace(*opts)) opts++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* hpux or _AIX or sun or __osf__ */
|
||||
|
||||
/* Check helptag.opt in input directory */
|
||||
if (indir)
|
||||
{
|
||||
nameofoptfile = (char *) m_malloc(strlen(indir) + strlen(TAGDOTOPT) + 1,
|
||||
"input helptag.opt");
|
||||
strcpy(nameofoptfile, indir);
|
||||
strcat(nameofoptfile, TAGDOTOPT);
|
||||
}
|
||||
else nameofoptfile = TAGDOTOPT;
|
||||
|
||||
if (optfile = fopen(nameofoptfile, "r"))
|
||||
{
|
||||
while (fscanf(optfile, "%512s", option) != EOF)
|
||||
setopt(option, filelenonly);
|
||||
fclose(optfile);
|
||||
}
|
||||
|
||||
if (indir) m_free(nameofoptfile, "input helptag.opt");
|
||||
|
||||
/* Check basename.opt in input directory */
|
||||
nameofoptfile = (char *) m_malloc((indir ? strlen(indir) : 0) +
|
||||
strlen(nodirbase) + strlen(DOTOPT) + 1,
|
||||
"basename.opt");
|
||||
*nameofoptfile = M_EOS;
|
||||
|
||||
if (indir) strcpy(nameofoptfile, indir);
|
||||
|
||||
strcat(nameofoptfile, nodirbase);
|
||||
strcat(nameofoptfile, DOTOPT);
|
||||
|
||||
if (optfile = fopen(nameofoptfile, "r"))
|
||||
{
|
||||
while (fscanf(optfile, "%512s", option) != EOF)
|
||||
setopt(option, filelenonly);
|
||||
fclose(optfile);
|
||||
}
|
||||
m_free(nameofoptfile, "basename.opt");
|
||||
|
||||
/* Read command line options */
|
||||
for (i = 3 ; i < m_argc ; i++)
|
||||
if (*m_argv[i] == '@')
|
||||
{
|
||||
if (optfile = fopen(m_argv[i] + 1, "r"))
|
||||
{
|
||||
while (fscanf(optfile, "%512s", option) != EOF)
|
||||
setopt(option, filelenonly);
|
||||
fclose(optfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mberr1("Unable to open option file %s", (m_argv[i] + 1));
|
||||
}
|
||||
}
|
||||
else setopt(m_argv[i], filelenonly);
|
||||
|
||||
if (filelenonly) return ;
|
||||
|
||||
if (optval)
|
||||
{
|
||||
m_mberr1("%s: Expecting value for option on command line or in option file",
|
||||
optkey[optval - 1]);
|
||||
}
|
||||
optval = M_NULLVAL;
|
||||
}
|
||||
|
||||
|
||||
/* Set a single option */
|
||||
/* Workonly parameter described with function options()*/
|
||||
#if defined(M_PROTO)
|
||||
void setopt(char *string, LOGICAL filelenonly)
|
||||
#else
|
||||
void setopt(string, filelenonly)
|
||||
char *string;
|
||||
LOGICAL filelenonly;
|
||||
#endif
|
||||
{
|
||||
char *p;
|
||||
int thisopt;
|
||||
LOGICAL ok;
|
||||
|
||||
if (optval)
|
||||
{
|
||||
/* Ignore '=' by itself */
|
||||
if (*string == '=' && *(string + 1) == M_EOS) return;
|
||||
setvalopt(optval, string, filelenonly);
|
||||
optval = M_NULLVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (p = strchr(string, '='))
|
||||
{
|
||||
*p = M_EOS;
|
||||
for (thisopt = 0 ; thisopt < NUMOPTIONS ; thisopt++)
|
||||
if (! m_mbmbupstrcmp(string, optkey[thisopt]))
|
||||
break;
|
||||
|
||||
/* Note: call setvalopt only if thisopt < NUMOPTIONS */
|
||||
ok = (LOGICAL)
|
||||
((thisopt < NUMOPTIONS) && setvalopt(thisopt + 1, p + 1, filelenonly));
|
||||
*p = '=';
|
||||
if (! ok && ! filelenonly)
|
||||
m_mberr1("%s: Unrecognized option on command line or in option file",
|
||||
string);
|
||||
return;
|
||||
} /* End strchr(string, '=') */
|
||||
|
||||
for (thisopt = 0 ; thisopt < NUMOPTIONS ; thisopt++)
|
||||
if (! m_mbmbupstrcmp(string, optkey[thisopt]))
|
||||
break;
|
||||
|
||||
if (thisopt >= NUMOPTIONS)
|
||||
{
|
||||
if (! filelenonly)
|
||||
m_mberr1("%s: Unrecognized option on command line or in option file",
|
||||
string);
|
||||
return;
|
||||
}
|
||||
else switch(thisopt + 1)
|
||||
{
|
||||
case ONERROR:
|
||||
optval = thisopt + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Process a value for a command line option */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL setvalopt(int thisopt, char *string, LOGICAL filelenonly)
|
||||
#else
|
||||
LOGICAL setvalopt(thisopt, string, filelenonly)
|
||||
int thisopt;
|
||||
char *string;
|
||||
LOGICAL filelenonly;
|
||||
#endif
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
char *tempstr;
|
||||
|
||||
/* Ignore leading = (occurs if "option =val" is entered in .opt file) */
|
||||
if (*string == '=') string++;
|
||||
|
||||
/* Check for empty string (occurs if "option= val" is entered in .opt file) */
|
||||
if (! *string)
|
||||
switch(thisopt)
|
||||
{
|
||||
case ONERROR:
|
||||
optval = thisopt;
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (thisopt)
|
||||
{
|
||||
case ONERROR:
|
||||
if (! m_mbmbupstrcmp(string, "GO"))
|
||||
stoponerror = FALSE;
|
||||
else if (! m_mbmbupstrcmp(string, "STOP"))
|
||||
stoponerror = TRUE;
|
||||
else m_mberr1("Invalid ONERROR option: %s", string);
|
||||
return(TRUE);
|
||||
default:
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
72
cde/programs/dthelp/parser/pass2/htag2/out.c
Normal file
72
cde/programs/dthelp/parser/pass2/htag2/out.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/* $XConsortium: out.c /main/3 1995/11/08 10:46:48 rswiston $ */
|
||||
/* Copyright (c) 1994 Hewlett-Packard Co. */
|
||||
/* Functions relevant to output of data characters */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void PutString(char *string)
|
||||
#else
|
||||
void PutString(string)
|
||||
char *string;
|
||||
#endif
|
||||
{
|
||||
fputs(string, outFile);
|
||||
}
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void PutWString(M_WCHAR *string)
|
||||
#else
|
||||
void PutWString(string)
|
||||
M_WCHAR *string;
|
||||
#endif
|
||||
{
|
||||
char *mb_string;
|
||||
|
||||
mb_string = MakeMByteString(string);
|
||||
fputs(mb_string, outFile);
|
||||
m_free(mb_string, "Multi-byte string");
|
||||
}
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void PutWChar(M_WCHAR wchar)
|
||||
#else
|
||||
void PutWChar(wchar)
|
||||
M_WCHAR wchar;
|
||||
#endif
|
||||
{
|
||||
M_WCHAR wc_string[2];
|
||||
char *mb_string;
|
||||
|
||||
wc_string[0] = wchar;
|
||||
wc_string[1] = 0;
|
||||
mb_string = MakeMByteString(wc_string);
|
||||
fputs(mb_string, outFile);
|
||||
m_free(mb_string, "Multi-byte string");
|
||||
}
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void SaveWChar(M_WCHAR wchar)
|
||||
#else
|
||||
void SaveWChar(wchar)
|
||||
M_WCHAR wchar;
|
||||
#endif
|
||||
{
|
||||
CDATA_el *pCdata;
|
||||
|
||||
if (pCurrentElement->type != e_cdata)
|
||||
return; /* we're in an error condition */
|
||||
|
||||
pCdata = &(pCurrentElement->u.u_cdata);
|
||||
|
||||
pCdata->buffPos++;
|
||||
if (pCdata->buffPos == pCdata->buffSize)
|
||||
{
|
||||
pCdata->buffSize += 256;
|
||||
pCdata->buffer = m_realloc(pCdata->buffer,
|
||||
pCdata->buffSize,
|
||||
"u_cdata.buffer");
|
||||
}
|
||||
pCdata->buffer[pCdata->buffPos] = wchar;
|
||||
}
|
||||
6908
cde/programs/dthelp/parser/pass2/htag2/sdl.c
Normal file
6908
cde/programs/dthelp/parser/pass2/htag2/sdl.c
Normal file
File diff suppressed because it is too large
Load Diff
547
cde/programs/dthelp/parser/pass2/htag2/sdl.dtd
Normal file
547
cde/programs/dthelp/parser/pass2/htag2/sdl.dtd
Normal file
@@ -0,0 +1,547 @@
|
||||
-- SDL Document-Type Definition
|
||||
Copyright (c) Hewlett-Packard Company, 1994
|
||||
Version 1.0 (2/23/94)
|
||||
$XConsortium: sdl.dtd /main/3 1996/11/07 11:55:55 drk $
|
||||
--
|
||||
|
||||
<!ENTITY m-lt CDATA "&<">
|
||||
<!ENTITY m-and CDATA "&&">
|
||||
<!ENTITY m-nl STARTTAG "newline">
|
||||
|
||||
<!SHORTREF sdldoc>
|
||||
"&<" -> &m-lt,
|
||||
"&&" -> &m-and,
|
||||
;
|
||||
|
||||
<!SHORTREF p>
|
||||
"&#RE;" -> &m-nl,
|
||||
"&<" -> &m-lt,
|
||||
"&&" -> &m-and,
|
||||
;
|
||||
|
||||
sdldoc -> (vstruct, head*, snb?, virpage +)
|
||||
<PARAM>
|
||||
pub-id CDATA,
|
||||
doc-id CDATA,
|
||||
timestmp CDATA,
|
||||
first-page CDATA,
|
||||
product CDATA,
|
||||
prodpn CDATA,
|
||||
prodver CDATA,
|
||||
license CDATA,
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
author CDATA,
|
||||
version CDATA,
|
||||
sdldtd CDATA,
|
||||
srcdtd CDATA,
|
||||
<USEMAP sdldoc>
|
||||
;
|
||||
|
||||
vstruct -> (loids, toss?, lophrases?, index?, rel-docs?, rel-file?, notes?)
|
||||
<PARAM>
|
||||
version CDATA,
|
||||
doc-id CDATA,
|
||||
;
|
||||
|
||||
virpage -> (head*, snb?, (block | form)*)
|
||||
<PARAM>
|
||||
id ID,
|
||||
level NUMBER,
|
||||
version CDATA,
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
doc-id CDATA,
|
||||
ssi CDATA,
|
||||
;
|
||||
|
||||
snb -> (head?,
|
||||
(graphic | text | audio | video | animate | crossdoc |
|
||||
man-page | textfile | sys-cmd | callback | script | switch) +)
|
||||
<PARAM>
|
||||
version CDATA,
|
||||
;
|
||||
|
||||
block -> (head*, (p | cp)*)
|
||||
<PARAM>
|
||||
id ID,
|
||||
level NUMBER,
|
||||
version CDATA,
|
||||
class (TABLE | CELL | LIST | ITEM | TEXT | UDEFFRMT),
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
length NUMBER,
|
||||
app (ALL | HELP | TUTORIAL | REF | SYS),
|
||||
timing (SYNC | ASYNC),
|
||||
SSI CDATA,
|
||||
;
|
||||
|
||||
form -> (head*, ((fstyle, fdata) | (fdata, fstyle)))
|
||||
<PARAM>
|
||||
id ID,
|
||||
level NUMBER,
|
||||
version CDATA,
|
||||
class (TABLE | CELL | LIST | ITEM | TEXT | UDEFFRMT),
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
length NUMBER,
|
||||
app (ALL | HELP | TUTORIAL | REF | SYS),
|
||||
ssi CDATA,
|
||||
;
|
||||
|
||||
fstyle -> (frowvec +)
|
||||
<PARAM>
|
||||
ncols NUMBER,
|
||||
;
|
||||
|
||||
frowvec -> EMPTY
|
||||
<PARAM>
|
||||
hdr (YES | NO),
|
||||
cells IDREFS,
|
||||
;
|
||||
|
||||
fdata -> ((block | form)*)
|
||||
;
|
||||
|
||||
p -> (head*, (#PCDATA | key | sphrase | rev | if | spc | snref |
|
||||
anchor | link) +)
|
||||
<EXCEPT> +(newline)
|
||||
<PARAM>
|
||||
id ID,
|
||||
version CDATA,
|
||||
type (LITERAL | LINED | DYNAMIC),
|
||||
ssi CDATA,
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
newline -> EMPTY
|
||||
;
|
||||
|
||||
cp -> CDATA
|
||||
<PARAM>
|
||||
id ID,
|
||||
version CDATA,
|
||||
type (LITERAL | LINED | DYNAMIC),
|
||||
ssi CDATA,
|
||||
;
|
||||
|
||||
head ->
|
||||
(((#PCDATA | key | sphrase | rev | if | spc | snref | anchor | link)*),
|
||||
subhead*)
|
||||
<EXCEPT> +(newline)
|
||||
<PARAM>
|
||||
id ID,
|
||||
version CDATA,
|
||||
class (LABEL | HEAD | CAPTION | ANNOTATION | PHEAD | UDEFHEAD),
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
type (LITERAL | LINED | DYNAMIC),
|
||||
abbrev CDATA,
|
||||
ssi CDATA,
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
subhead ->
|
||||
((#PCDATA | key | sphrase | rev | if | spc | snref | anchor | link)*)
|
||||
<EXCEPT> +(newline)
|
||||
<PARAM>
|
||||
id ID,
|
||||
version CDATA,
|
||||
class (LABEL | HEAD | CAPTION | ANNOTATION | PHEAD | UDEFHEAD),
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
type (LITERAL | LINED | DYNAMIC),
|
||||
abbrev CDATA,
|
||||
ssi CDATA,
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
anchor -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
<USEMAP sdldoc>
|
||||
;
|
||||
|
||||
link -> ((#PCDATA | key | sphrase | rev | if | spc | snref | anchor) +)
|
||||
<EXCEPT> -(link) +(newline)
|
||||
<PARAM>
|
||||
rid IDREF,
|
||||
button IDREF,
|
||||
linkinfo CDATA,
|
||||
descript CDATA,
|
||||
window (CURRENT | NEW | POPUP),
|
||||
traversal (RETURN | NORETURN),
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
snref -> (refitem +, alttext?)
|
||||
<EXCEPT> -(newline)
|
||||
<PARAM>
|
||||
id ID,
|
||||
<USEMAP sdldoc>
|
||||
;
|
||||
|
||||
refitem -> (head*)
|
||||
<PARAM>
|
||||
rid IDREF,
|
||||
class (FIGURE | IN-LINE | BUTTON | ICON | UDEFGRAPH |
|
||||
TABLE | CELL | LIST | ITEM | TEXT | UDEFFRMT),
|
||||
button IDREF,
|
||||
ssi CDATA,
|
||||
;
|
||||
|
||||
alttext -> CDATA
|
||||
;
|
||||
|
||||
rev -> ((#PCDATA | key | sphrase | if | spc | snref | anchor | link)*)
|
||||
<EXCEPT> -(rev) +(newline)
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
key -> ((#PCDATA | key | sphrase | rev | if | spc | snref | anchor)*)
|
||||
<EXCEPT> -(link) +(newline)
|
||||
<PARAM>
|
||||
charset CDATA,
|
||||
class (ACRO | BOOK | EMPH | JARGON | L10N |
|
||||
NAME | QUOTE | PRODUCT | TERMDEF | TERM |
|
||||
MACH-IN | MACH-OUT | MACH-CONT | PUB-LIT | UDEFKEY),
|
||||
ssi CDATA,
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
sphrase -> ((#PCDATA | spc)*)
|
||||
<PARAM>
|
||||
class (SUPER | SUB),
|
||||
ssi CDATA,
|
||||
<USEMAP sdldoc>
|
||||
;
|
||||
|
||||
if -> (cond, then, else?)
|
||||
<EXCEPT> -(newline)
|
||||
<USEMAP sdldoc>
|
||||
;
|
||||
|
||||
cond -> CDATA
|
||||
<PARAM>
|
||||
interp CDATA,
|
||||
;
|
||||
|
||||
then ->
|
||||
((#PCDATA | key | sphrase | rev | if | spc | snref | anchor | link)*)
|
||||
<EXCEPT> +(newline)
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
else ->
|
||||
((#PCDATA | key | sphrase | rev | if | spc | snref | anchor | link)*)
|
||||
<EXCEPT> +(newline)
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
spc -> EMPTY
|
||||
<PARAM>
|
||||
name CDATA,
|
||||
<USEMAP sdldoc>
|
||||
;
|
||||
|
||||
graphic -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
format CDATA,
|
||||
method IDREF,
|
||||
xid CDATA,
|
||||
;
|
||||
|
||||
text -> ((p | cp)*)
|
||||
<PARAM>
|
||||
id ID,
|
||||
language CDATA,
|
||||
charset CDATA,
|
||||
;
|
||||
|
||||
audio -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
format CDATA,
|
||||
method IDREF,
|
||||
xid CDATA,
|
||||
;
|
||||
|
||||
video -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
format CDATA,
|
||||
method IDREF,
|
||||
xid CDATA,
|
||||
;
|
||||
|
||||
animate -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
format CDATA,
|
||||
method IDREF,
|
||||
xid CDATA,
|
||||
;
|
||||
|
||||
script -> CDATA
|
||||
<PARAM>
|
||||
id ID,
|
||||
interp CDATA,
|
||||
;
|
||||
|
||||
crossdoc -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
xid CDATA,
|
||||
;
|
||||
|
||||
man-page -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
xid CDATA,
|
||||
;
|
||||
|
||||
textfile -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
xid CDATA,
|
||||
offset CDATA,
|
||||
format CDATA,
|
||||
;
|
||||
|
||||
sys-cmd -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
command CDATA,
|
||||
;
|
||||
|
||||
callback -> EMPTY
|
||||
<PARAM>
|
||||
id ID,
|
||||
data CDATA,
|
||||
;
|
||||
|
||||
switch -> CDATA
|
||||
<PARAM>
|
||||
id ID,
|
||||
interp CDATA,
|
||||
branches IDREFS,
|
||||
;
|
||||
|
||||
rel-docs -> EMPTY
|
||||
;
|
||||
|
||||
rel-file -> EMPTY
|
||||
;
|
||||
|
||||
notes -> EMPTY
|
||||
;
|
||||
|
||||
loids -> (id*)
|
||||
<PARAM>
|
||||
count NUMBER
|
||||
;
|
||||
|
||||
id -> EMPTY
|
||||
<PARAM>
|
||||
type (VIRPAGE | BLOCK | FORM | P | CP | HEAD |
|
||||
SUBHEAD | ANCHOR | SWITCH | SNREF | GRAPHIC | TEXT |
|
||||
AUDIO | VIDEO | ANIMATE | CROSSDOC | MAN-PAGE | TEXTFILE |
|
||||
SYS-CMD | SCRIPT | CALLBACK),
|
||||
rid IDREF,
|
||||
rssi CDATA,
|
||||
rlevel NUMBER,
|
||||
offset NUMBER,
|
||||
;
|
||||
|
||||
index -> (entry*)
|
||||
<PARAM>
|
||||
count NUMBER
|
||||
;
|
||||
|
||||
entry -> (((#PCDATA | key | sphrase | rev | if | spc | snref)*), entry*)
|
||||
<EXCEPT> +(newline)
|
||||
<PARAM>
|
||||
id ID,
|
||||
main IDREFS,
|
||||
locs IDREFS,
|
||||
syns IDREFS,
|
||||
sort CDATA,
|
||||
<USEMAP p>
|
||||
;
|
||||
|
||||
lophrases -> (phrase +)
|
||||
<PARAM>
|
||||
count NUMBER
|
||||
;
|
||||
|
||||
phrase -> EMPTY
|
||||
<PARAM>
|
||||
text CDATA,
|
||||
;
|
||||
|
||||
toss -> ((keystyle | headstyle | formstyle | frmtstyle | grphstyle)*)
|
||||
<PARAM>
|
||||
count NUMBER
|
||||
;
|
||||
|
||||
keystyle -> EMPTY
|
||||
<PARAM>
|
||||
class (ACRO | BOOK | EMPH | JARGON | L10N |
|
||||
NAME | QUOTE | PRODUCT | TERMDEF | TERM |
|
||||
MACH-IN | MACH-OUT | MACH-CONT | PUB-LIT | UDEFKEY),
|
||||
ssi CDATA,
|
||||
rlevel NUMBER,
|
||||
phrase CDATA,
|
||||
srch-wt NUMBER,
|
||||
enter CDATA,
|
||||
exit CDATA,
|
||||
pointsz NUMBER,
|
||||
set-width NUMBER,
|
||||
color CDATA,
|
||||
xlfd CDATA,
|
||||
xlfdi CDATA,
|
||||
xlfdb CDATA,
|
||||
xlfdib CDATA,
|
||||
typenam CDATA,
|
||||
typenami CDATA,
|
||||
typenamb CDATA,
|
||||
typenamib CDATA,
|
||||
style (SERIF | SANS-SERIF | SYMBOL),
|
||||
spacing (MONOSPACE | PROPSPACE),
|
||||
weight (MEDIUM | BOLD),
|
||||
slant (ROMAN | ITALIC | REV-ITALIC),
|
||||
special (UNDERLINE | STRIKEOUT | NONE),
|
||||
;
|
||||
|
||||
headstyle -> EMPTY
|
||||
<PARAM>
|
||||
class (LABEL | HEAD | CAPTION | ANNOTATION | PHEAD | UDEFHEAD),
|
||||
ssi CDATA,
|
||||
rlevel NUMBER,
|
||||
phrase CDATA,
|
||||
srch-wt NUMBER,
|
||||
orient (LEFT-ORIENT | CENTER-ORIENT | RIGHT-ORIENT |
|
||||
LEFT-MARGIN-ORIENT | RIGHT-MARGIN-ORIENT |
|
||||
LEFT-CORNER-ORIENT | RIGHT-CORNER-ORIENT ),
|
||||
vorient (TOP-VORIENT | BOTTOM-VORIENT | CENTER-VORIENT),
|
||||
placement (OBJECT | PARENT),
|
||||
headw CDATA,
|
||||
stack (HORIZ | VERT),
|
||||
flow (WRAP | NOWRAP | JOIN),
|
||||
pointsz NUMBER,
|
||||
set-width NUMBER,
|
||||
color CDATA,
|
||||
xlfd CDATA,
|
||||
xlfdi CDATA,
|
||||
xlfdb CDATA,
|
||||
xlfdib CDATA,
|
||||
typenam CDATA,
|
||||
typenami CDATA,
|
||||
typenamb CDATA,
|
||||
typenamib CDATA,
|
||||
style (SERIF | SANS-SERIF | SYMBOL),
|
||||
spacing (MONOSPACE | PROPSPACE),
|
||||
weight (MEDIUM | BOLD),
|
||||
slant (ROMAN | ITALIC | REV-ITALIC),
|
||||
special (UNDERLINE | STRIKEOUT | NONE),
|
||||
l-margin NUMBER,
|
||||
r-margin NUMBER,
|
||||
t-margin NUMBER,
|
||||
b-margin NUMBER,
|
||||
border (NO-BORDER | FULL-BORDER | HORIZONTAL-BORDER |
|
||||
VERTICAL-BORDER | TOP-BORDER | BOTTOM-BORDER |
|
||||
LEFT-BORDER | RIGHT-BORDER),
|
||||
vjust (TOP-VJUST | BOTTOM-VJUST | CENTER-VJUST),
|
||||
justify (LEFT-JUSTIFY | RIGHT-JUSTIFY |
|
||||
CENTER-JUSTIFY | NUMERIC-JUSTIFY),
|
||||
;
|
||||
|
||||
formstyle -> EMPTY
|
||||
<PARAM>
|
||||
class (TABLE | CELL | LIST | ITEM | TEXT | UDEFFRMT),
|
||||
ssi CDATA,
|
||||
rlevel NUMBER,
|
||||
phrase CDATA,
|
||||
srch-wt NUMBER,
|
||||
colw CDATA,
|
||||
colj CDATA,
|
||||
pointsz NUMBER,
|
||||
set-width NUMBER,
|
||||
color CDATA,
|
||||
xlfd CDATA,
|
||||
xlfdi CDATA,
|
||||
xlfdb CDATA,
|
||||
xlfdib CDATA,
|
||||
typenam CDATA,
|
||||
typenami CDATA,
|
||||
typenamb CDATA,
|
||||
typenamib CDATA,
|
||||
style (SERIF | SANS-SERIF | SYMBOL),
|
||||
spacing (MONOSPACE | PROPSPACE),
|
||||
weight (MEDIUM | BOLD),
|
||||
slant (ROMAN | ITALIC | REV-ITALIC),
|
||||
special (UNDERLINE | STRIKEOUT | NONE),
|
||||
l-margin NUMBER,
|
||||
r-margin NUMBER,
|
||||
t-margin NUMBER,
|
||||
b-margin NUMBER,
|
||||
border (NO-BORDER | FULL-BORDER | HORIZONTAL-BORDER |
|
||||
VERTICAL-BORDER | TOP-BORDER | BOTTOM-BORDER |
|
||||
LEFT-BORDER | RIGHT-BORDER),
|
||||
vjust (TOP-VJUST | BOTTOM-VJUST | CENTER-VJUST),
|
||||
;
|
||||
|
||||
frmtstyle -> EMPTY
|
||||
<PARAM>
|
||||
class (TABLE | CELL | LIST | ITEM | TEXT | UDEFFRMT),
|
||||
ssi CDATA,
|
||||
rlevel NUMBER,
|
||||
phrase CDATA,
|
||||
f-margin CDATA,
|
||||
srch-wt NUMBER,
|
||||
pointsz NUMBER,
|
||||
set-width NUMBER,
|
||||
color CDATA,
|
||||
xlfd CDATA,
|
||||
xlfdi CDATA,
|
||||
xlfdb CDATA,
|
||||
xlfdib CDATA,
|
||||
typenam CDATA,
|
||||
typenami CDATA,
|
||||
typenamb CDATA,
|
||||
typenamib CDATA,
|
||||
style (SERIF | SANS-SERIF | SYMBOL),
|
||||
spacing (MONOSPACE | PROPSPACE),
|
||||
weight (MEDIUM | BOLD),
|
||||
slant (ROMAN | ITALIC | REV-ITALIC),
|
||||
special (UNDERLINE | STRIKEOUT | NONE),
|
||||
l-margin NUMBER,
|
||||
r-margin NUMBER,
|
||||
t-margin NUMBER,
|
||||
b-margin NUMBER,
|
||||
border (NO-BORDER | FULL-BORDER | HORIZONTAL-BORDER |
|
||||
VERTICAL-BORDER | TOP-BORDER | BOTTOM-BORDER |
|
||||
LEFT-BORDER | RIGHT-BORDER),
|
||||
vjust (TOP-VJUST | BOTTOM-VJUST | CENTER-VJUST),
|
||||
justify (LEFT-JUSTIFY | RIGHT-JUSTIFY |
|
||||
CENTER-JUSTIFY | NUMERIC-JUSTIFY),
|
||||
;
|
||||
|
||||
grphstyle -> EMPTY
|
||||
<PARAM>
|
||||
class (FIGURE | IN-LINE | BUTTON | ICON | UDEFGRAPH),
|
||||
ssi CDATA,
|
||||
rlevel NUMBER,
|
||||
phrase CDATA,
|
||||
l-margin NUMBER,
|
||||
r-margin NUMBER,
|
||||
t-margin NUMBER,
|
||||
b-margin NUMBER,
|
||||
border (NO-BORDER | FULL-BORDER | HORIZONTAL-BORDER |
|
||||
VERTICAL-BORDER | TOP-BORDER | BOTTOM-BORDER |
|
||||
LEFT-BORDER | RIGHT-BORDER),
|
||||
vjust (TOP-VJUST | BOTTOM-VJUST | CENTER-VJUST),
|
||||
justify (LEFT-JUSTIFY | RIGHT-JUSTIFY |
|
||||
CENTER-JUSTIFY | NUMERIC-JUSTIFY),
|
||||
;
|
||||
1783
cde/programs/dthelp/parser/pass2/htag2/sdl.if
Normal file
1783
cde/programs/dthelp/parser/pass2/htag2/sdl.if
Normal file
File diff suppressed because it is too large
Load Diff
113
cde/programs/dthelp/parser/pass2/parser/Imakefile
Normal file
113
cde/programs/dthelp/parser/pass2/parser/Imakefile
Normal file
@@ -0,0 +1,113 @@
|
||||
XCOMM $XConsortium: Imakefile /main/10 1996/10/09 14:05:24 drk $
|
||||
/* parser Imakefile */
|
||||
|
||||
HTAG2 = ..
|
||||
HTAG2SRC = $(HTAG2)/htag2
|
||||
SDLPARSERSRC = $(HTAG2)/parser
|
||||
SDLELTDEFSRC = $(HTAG2)/eltdef
|
||||
SDLDTDFILE = $(HTAG2SRC)/sdl.dtd
|
||||
SDLUTILSRC = $(HTAG2)/util
|
||||
SDLBUILDSRC = $(HTAG2)/build
|
||||
SDLUTILLIB = $(HTAG2)/util/libutil.a
|
||||
|
||||
INCLUDES = -I. -I$(SDLUTILSRC) -I$(HTAG2SRC) -I$(SDLBUILDSRC) \
|
||||
-I$(SDLELTDEFSRC)
|
||||
|
||||
SRCS = parser.c actutil.c \
|
||||
closent.c code.c cyclent.c dcurelt.c \
|
||||
end.c entity.c \
|
||||
error.c getsign.c \
|
||||
input.c level.c lookent.c \
|
||||
minim.c optstrg.c param.c parent.c \
|
||||
parutil.c pi.c \
|
||||
scan.c setpar.c start.c string.c struct.c \
|
||||
text.c
|
||||
|
||||
OBJS = parser.o actutil.o \
|
||||
closent.o code.o cyclent.o dcurelt.o \
|
||||
end.o entity.o \
|
||||
error.o getsign.o \
|
||||
input.o level.o lookent.o \
|
||||
minim.o optstrg.o param.o parent.o \
|
||||
parutil.o pi.o \
|
||||
scan.o setpar.o start.o string.o struct.o \
|
||||
text.o
|
||||
|
||||
XLATEOBJECTS = $(HTAG2SRC)/LocaleXlate.o $(HTAG2SRC)/XlationSvc.o
|
||||
|
||||
APPLOBJECTS = \
|
||||
$(HTAG2SRC)/custom.o \
|
||||
$(HTAG2SRC)/sdl.o \
|
||||
$(HTAG2SRC)/option.o \
|
||||
$(HTAG2SRC)/out.o \
|
||||
$(XLATEOBJECTS)
|
||||
|
||||
ELT_H = \
|
||||
$(SDLELTDEFSRC)/entity2.h \
|
||||
$(SDLELTDEFSRC)/globdec.h \
|
||||
$(SDLELTDEFSRC)/globdef.h \
|
||||
$(SDLELTDEFSRC)/if.h \
|
||||
$(SDLELTDEFSRC)/pval.h \
|
||||
$(SDLELTDEFSRC)/signon.h \
|
||||
$(SDLELTDEFSRC)/signonx.h
|
||||
|
||||
ELT_C = \
|
||||
$(SDLELTDEFSRC)/efile.c \
|
||||
$(SDLELTDEFSRC)/entfile.c \
|
||||
$(SDLELTDEFSRC)/pfile.c \
|
||||
$(SDLELTDEFSRC)/sfile.c \
|
||||
$(SDLELTDEFSRC)/stfile.c \
|
||||
$(SDLELTDEFSRC)/tfile.c
|
||||
|
||||
ELT_DEFS = $(ELT_H) $(ELT_C)
|
||||
|
||||
#ifdef SunArchitecture
|
||||
.NO_PARALLEL:
|
||||
#endif
|
||||
|
||||
LOCAL_LIBRARIES = $(SDLUTILLIB)
|
||||
SYS_LIBRARIES = $(XLIB) DtClientSysLibs
|
||||
|
||||
#if defined (SunArchitecture)
|
||||
SYS_LIBRARIES = $(XLIB) -lm -ldl -lgen -lC
|
||||
#endif /* SunArchitecture */
|
||||
|
||||
all:: $(HTAG2SRC)/dthelp_htag2
|
||||
|
||||
other_dirs:
|
||||
cd $(SDLELTDEFSRC); make
|
||||
cd $(HTAG2SRC); make
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalProgramTarget(parser,$(OBJS) $(APPLOBJECTS),delim.h $(LOCAL_LIBRARIES) other_dirs,$(LOCAL_LIBRARIES),)
|
||||
|
||||
CPRODS = case.c context.h delim.h
|
||||
CTRASH = error delim.dat
|
||||
|
||||
$(HTAG2SRC)/dthelp_htag2: parser
|
||||
$(RM) $(HTAG2SRC)/dthelp_htag2
|
||||
$(CP) parser $(HTAG2SRC)/dthelp_htag2
|
||||
|
||||
$(CPRODS): $(SDLUTILSRC)/context $(HTAG2SRC)/delim.par context.dat
|
||||
$(RM) $(CPRODS) $(CTRASH)
|
||||
/* get application-specific delim.dat */
|
||||
$(CP) $(HTAG2SRC)/delim.par delim.dat
|
||||
$(SDLUTILSRC)/context
|
||||
|
||||
$(SDLUTILSRC)/context:
|
||||
cd $(SDLUTILSRC); make context
|
||||
|
||||
$(APPLOBJECTS):
|
||||
cd $(HTAG2SRC); make
|
||||
|
||||
$(ELT_DEFS):
|
||||
cd $(SDLELTDEFSRC); make
|
||||
|
||||
clean::
|
||||
$(RM) $(CPRODS) $(CTRASH) parser *.o
|
||||
|
||||
depend:: $(SRCS)
|
||||
|
||||
includes:: $(CPRODS)
|
||||
|
||||
DependTarget()
|
||||
316
cde/programs/dthelp/parser/pass2/parser/actutil.c
Normal file
316
cde/programs/dthelp/parser/pass2/parser/actutil.c
Normal file
@@ -0,0 +1,316 @@
|
||||
/* $XConsortium: actutil.c /main/3 1995/11/08 10:48:36 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Actutil.c contains utility procedures for processing actions specified
|
||||
in the interface definition.*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#define M_IFDEF
|
||||
#include "if.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
#include "signon.h"
|
||||
|
||||
/* When an explicit or implied end-tag occurs */
|
||||
void m_endaction(m_elt)
|
||||
M_ELEMENT m_elt;
|
||||
{
|
||||
M_ELEMENT m_action;
|
||||
char buffer[2*MAXD+M_NAMELEN+1];
|
||||
|
||||
if (m_tagtrace) {
|
||||
if (m_element[m_elt - 1].content != M_NONE) {
|
||||
if (m_toptstat == M_OTHER) {
|
||||
strcpy(buffer, "\n");
|
||||
m_trace(buffer);
|
||||
}
|
||||
sprintf(buffer,
|
||||
"%s%s%s",
|
||||
m_etago,
|
||||
m_nameofelt(m_elt),
|
||||
m_tagc);
|
||||
m_trace(buffer);
|
||||
}
|
||||
m_toptstat = M_OTHER;
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_ecarray)) {
|
||||
m_stackpar = m_stacktop;
|
||||
m_endcase(m_action);
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_etarray)) {
|
||||
m_stackpar = m_stacktop->stparam;
|
||||
m_textout(&m_string[m_action - 1], FALSE, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find appropriate action according to current stack */
|
||||
int m_findact(elt, array)
|
||||
M_ELEMENT elt;
|
||||
int *array;
|
||||
{
|
||||
int chainlen = 0;
|
||||
int index;
|
||||
|
||||
if (! array[elt - 1]) return(FALSE);
|
||||
if (m_stacktop->element != elt) {
|
||||
m_error("Program error in findact");
|
||||
m_exit(TRUE);
|
||||
}
|
||||
/* There is an action for this element with no context specification */
|
||||
if (m_action[array[elt - 1] - 1].data) {
|
||||
chainlen = 1;
|
||||
index = array[elt - 1];
|
||||
}
|
||||
/* Only actions for this element have context specified */
|
||||
else {
|
||||
chainlen = 0;
|
||||
index = 0;
|
||||
}
|
||||
m_findchain(m_stacktop->oldtop, array[elt - 1], chainlen, &chainlen,
|
||||
&index, FALSE);
|
||||
return(index ? m_action[index - 1].data : FALSE);
|
||||
}
|
||||
|
||||
/* Recursive procedure called by findact() to search m_action */
|
||||
#if defined(M_PROTO)
|
||||
void m_findchain(M_PARSE *stackptr, int start, int chainin, int *chainout, int *index, LOGICAL wild)
|
||||
#else
|
||||
void m_findchain(stackptr, start, chainin, chainout, index, wild)
|
||||
M_PARSE *stackptr;
|
||||
int start;
|
||||
int chainin;
|
||||
int *chainout;
|
||||
int *index;
|
||||
LOGICAL wild;
|
||||
#endif
|
||||
{
|
||||
int node;
|
||||
M_PARSE *stackp;
|
||||
|
||||
for (node = m_action[start - 1].son ; node;
|
||||
node = m_action[node - 1].next) {
|
||||
if (m_action[node - 1].element == 1)
|
||||
m_findchain(stackptr, node, chainin, chainout, index, TRUE);
|
||||
else for (stackp = stackptr;
|
||||
stackp->oldtop;
|
||||
stackp = stackp->oldtop) {
|
||||
if (stackp->element == m_action[node - 1].element - 1) {
|
||||
if (m_action[node - 1].data)
|
||||
if (chainin + 1 > *chainout ||
|
||||
(chainin + 1 == *chainout && node < *index)) {
|
||||
*chainout = chainin + 1;
|
||||
*index = node;
|
||||
}
|
||||
m_findchain(stackp->oldtop, node, chainin + 1, chainout,
|
||||
index, FALSE);
|
||||
}
|
||||
if (! wild) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Process global end string. In separate procedure to keep all references
|
||||
to if.h in one source file and minimize recompilation if interface
|
||||
changes. */
|
||||
void m_globes(M_NOPAR)
|
||||
{
|
||||
M_WCHAR *wc_string;
|
||||
|
||||
wc_string = MakeWideCharString(&m_string[m_ges]);
|
||||
if (m_ges) m_stcaction(wc_string, FALSE, TRUE);
|
||||
m_free(wc_string,"wide character string");
|
||||
}
|
||||
|
||||
/* Process global start string. In separate procedure to keep all references
|
||||
to if.h in one source file and minimize recompilation if interface
|
||||
changes. */
|
||||
void m_globss(M_NOPAR)
|
||||
{
|
||||
M_WCHAR *wc_string;
|
||||
|
||||
wc_string = MakeWideCharString(&m_string[m_gss]);
|
||||
if (m_gss) m_stcaction(wc_string, TRUE, FALSE);
|
||||
m_free(wc_string,"wide character string");
|
||||
}
|
||||
|
||||
/* When an explicit or implied start-tag occurs */
|
||||
void m_strtaction(m_elt)
|
||||
M_ELEMENT m_elt;
|
||||
{
|
||||
int m_par, m_i;
|
||||
M_WCHAR *m_p;
|
||||
M_ELEMENT m_action;
|
||||
static char newpar[] = "\n ";
|
||||
static char quote[] = " = \"";
|
||||
char buffer[M_NAMELEN + 1 +
|
||||
(sizeof(quote) + sizeof(newpar) - 2 > MAXD ?
|
||||
sizeof(quote) + sizeof(newpar) - 2 :
|
||||
MAXD)
|
||||
];
|
||||
|
||||
m_start = TRUE;
|
||||
m_getline(&m_stacktop->file, &m_stacktop->line);
|
||||
if (m_tagtrace) {
|
||||
sprintf(buffer, "%s%s", m_stago, m_nameofelt(m_elt));
|
||||
m_trace(buffer);
|
||||
for (m_i = 0, m_par = m_element[m_elt - 1].parptr;
|
||||
m_i < m_element[m_elt - 1].parcount;
|
||||
m_i++, m_par++)
|
||||
if (m_stacktop->param[m_i]) {
|
||||
sprintf(buffer, "%s%s%s",
|
||||
newpar, &m_pname[m_parameter[m_par - 1].paramname], quote);
|
||||
m_trace(buffer);
|
||||
buffer[1] = M_EOS;
|
||||
for (m_p = m_stacktop->param[m_i] ; *m_p ; m_p++)
|
||||
if (*m_p != '"') {
|
||||
buffer[0] = *m_p;
|
||||
m_trace(buffer);
|
||||
}
|
||||
else {
|
||||
sprintf(buffer, "%s%d", m_cro, '"');
|
||||
m_trace(buffer);
|
||||
buffer[1] = M_EOS;
|
||||
}
|
||||
buffer[0] = '"';
|
||||
m_trace(buffer);
|
||||
}
|
||||
if (m_element[m_elt - 1].parcount) {
|
||||
buffer[0] = '\n';
|
||||
buffer[1] = M_EOS;
|
||||
m_trace(buffer);
|
||||
}
|
||||
sprintf(buffer, "%s\n", m_tagc);
|
||||
m_trace(buffer);
|
||||
m_toptstat = M_TOPTSTARTTAG;
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_scarray)) {
|
||||
m_stackpar = m_stacktop;
|
||||
m_strtcase(m_action);
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_stcarray)) {
|
||||
m_stacktop->stccase = m_action;
|
||||
m_stacktop->stparam = m_stacktop;
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_starray)) {
|
||||
m_stackpar = m_stacktop->stparam;
|
||||
m_textout(&m_string[m_action - 1], TRUE, FALSE);
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_tcarray)) {
|
||||
m_stacktop->cdcase = m_action;
|
||||
m_stacktop->cdparam = m_stacktop;
|
||||
}
|
||||
if (m_action = m_findact(m_elt, m_pcarray)) {
|
||||
m_stacktop->picase = m_action;
|
||||
m_stacktop->piparam = m_stacktop;
|
||||
}
|
||||
}
|
||||
|
||||
/* Output a start-string or end-string */
|
||||
#if defined(M_PROTO)
|
||||
void m_textout(char *format, LOGICAL start, LOGICAL end)
|
||||
#else
|
||||
void m_textout(format, start, end)
|
||||
char *format;
|
||||
LOGICAL start;
|
||||
LOGICAL end;
|
||||
#endif
|
||||
{
|
||||
M_WCHAR name[M_NAMELEN + 1];
|
||||
int i, par;
|
||||
LOGICAL found;
|
||||
M_WCHAR *string;
|
||||
M_WCHAR *p;
|
||||
M_WCHAR *q;
|
||||
M_WCHAR *r;
|
||||
M_WCHAR *s;
|
||||
M_WCHAR *new;
|
||||
int stringlen;
|
||||
int changelen;
|
||||
int unused;
|
||||
|
||||
stringlen = strlen(format) + 1;
|
||||
unused = 0;
|
||||
string = (M_WCHAR *) m_malloc(stringlen, "string space");
|
||||
for (p = string ; *format ; )
|
||||
{
|
||||
if (*format == M_ESCAPECHAR)
|
||||
{
|
||||
for (i = 0, format++ ; i < M_NAMELEN ; i++, format++)
|
||||
{
|
||||
mbtowc(&name[i], format, 1);
|
||||
if (m_cttype(name[i]) == M_NONNAME ||
|
||||
(m_cttype(name[i]) != M_NMSTART && i == 0)
|
||||
) break;
|
||||
}
|
||||
if (! i)
|
||||
{
|
||||
char mb;
|
||||
|
||||
mb = M_ESCAPECHAR;
|
||||
mbtowc(p, &mb, 1);
|
||||
p++;
|
||||
/* Double escape character used to insert a single escape character
|
||||
in the output string */
|
||||
if (*format == M_ESCAPECHAR) format++;
|
||||
continue;
|
||||
}
|
||||
name[i] = M_EOS;
|
||||
for (found = FALSE, i = 0,
|
||||
par = m_element[m_stacktop->element - 1].parptr;
|
||||
i < m_element[m_stacktop->element - 1].parcount;
|
||||
i++, par++)
|
||||
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], name))
|
||||
{
|
||||
q = m_stacktop->param[i];
|
||||
if (! q)
|
||||
{
|
||||
found = TRUE;
|
||||
unused += w_strlen(name) + 1;
|
||||
break;
|
||||
}
|
||||
changelen = w_strlen(q) - w_strlen(name) - 1 - unused;
|
||||
if (changelen > 0)
|
||||
{
|
||||
new = (M_WCHAR *) m_malloc(stringlen + changelen,
|
||||
"string space");
|
||||
for (r = string, s = new ; r < p ; ) *s++ = *r++;
|
||||
m_free(string, "string space");
|
||||
string = new;
|
||||
stringlen = stringlen + changelen;
|
||||
p = s;
|
||||
unused = 0;
|
||||
}
|
||||
else if (changelen < 0) unused = -changelen;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
if (! found)
|
||||
{
|
||||
char mb;
|
||||
|
||||
mb = M_ESCAPECHAR;
|
||||
mbtowc(p, &mb, 1);
|
||||
p++;
|
||||
q = name;
|
||||
}
|
||||
if (q) while (*q) *p++ = *q++;
|
||||
}
|
||||
else *p++ = *format++;
|
||||
}
|
||||
*p = M_EOS;
|
||||
m_stcaction(string, start, end);
|
||||
m_free(string, "string space");
|
||||
}
|
||||
2
cde/programs/dthelp/parser/pass2/parser/addinput.c
Normal file
2
cde/programs/dthelp/parser/pass2/parser/addinput.c
Normal file
@@ -0,0 +1,2 @@
|
||||
/* $XConsortium: addinput.c /main/3 1995/11/08 10:48:50 rswiston $ */
|
||||
/* Obsolete */
|
||||
133
cde/programs/dthelp/parser/pass2/parser/charconv.h
Normal file
133
cde/programs/dthelp/parser/pass2/parser/charconv.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/* $XConsortium: charconv.h /main/3 1995/11/08 10:49:04 rswiston $ */
|
||||
EXTERN M_WCHAR pc8_to_r8 [256]
|
||||
#if defined(DEFINE)
|
||||
= {
|
||||
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
|
||||
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
|
||||
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
|
||||
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
|
||||
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
|
||||
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
|
||||
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
|
||||
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
|
||||
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
|
||||
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
|
||||
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
|
||||
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
|
||||
'\170','\171','\172','\173','\174','\175','\176','\177','\264','\317',
|
||||
'\305','\300','\314','\310','\324','\265','\301','\315','\311','\335',
|
||||
'\321','\331','\330','\320','\334','\327','\323','\302','\316','\312',
|
||||
'\303','\313','\357','\332','\333','\277','\273','\274','\120','\276',
|
||||
'\304','\325','\306','\307','\267','\266','\371','\372','\271','\055',
|
||||
'\052','\370','\367','\270','\373','\375','\374','\374','\374','\174',
|
||||
'\053','\043','\053','\053','\043','\043','\174','\043','\043','\053',
|
||||
'\043','\053','\053','\053','\053','\053','\055','\053','\043','\053',
|
||||
'\043','\043','\043','\043','\043','\075','\043','\043','\053','\043',
|
||||
'\053','\053','\043','\043','\053','\053','\043','\053','\053','\374',
|
||||
'\374','\374','\374','\374','\052','\336','\052','\052','\052','\052',
|
||||
'\363','\052','\052','\052','\052','\052','\052','\326','\052','\052',
|
||||
'\052','\376','\052','\052','\174','\174','\057','\176','\263','\362',
|
||||
'\362','\052','\052','\052','\374','\377'
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
EXTERN M_WCHAR pc8dn_to_r8 [256]
|
||||
#if defined(DEFINE)
|
||||
= {
|
||||
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
|
||||
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
|
||||
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
|
||||
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
|
||||
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
|
||||
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
|
||||
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
|
||||
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
|
||||
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
|
||||
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
|
||||
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
|
||||
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
|
||||
'\170','\171','\172','\173','\174','\175','\176','\177','\264','\317',
|
||||
'\305','\300','\314','\310','\324','\265','\301','\315','\311','\335',
|
||||
'\321','\331','\330','\320','\334','\327','\323','\302','\316','\312',
|
||||
'\303','\313','\357','\332','\333','\326','\273','\322','\114','\154',
|
||||
'\304','\325','\306','\307','\267','\266','\352','\351','\271','\342',
|
||||
'\341','\154','\156','\270','\052','\272','\374','\374','\374','\174',
|
||||
'\053','\043','\053','\053','\043','\043','\174','\043','\043','\053',
|
||||
'\043','\053','\053','\053','\053','\053','\055','\053','\043','\053',
|
||||
'\043','\043','\043','\043','\043','\075','\043','\043','\053','\043',
|
||||
'\053','\053','\043','\043','\053','\053','\043','\053','\053','\374',
|
||||
'\374','\374','\374','\374','\052','\336','\052','\052','\052','\052',
|
||||
'\363','\052','\052','\052','\052','\052','\052','\326','\052','\052',
|
||||
'\052','\376','\052','\052','\174','\174','\057','\176','\263','\362',
|
||||
'\362','\052','\052','\052','\374','\377'
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
EXTERN M_WCHAR r8_to_pc8 [256]
|
||||
#if defined(DEFINE)
|
||||
= {
|
||||
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
|
||||
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
|
||||
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
|
||||
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
|
||||
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
|
||||
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
|
||||
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
|
||||
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
|
||||
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
|
||||
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
|
||||
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
|
||||
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
|
||||
'\170','\171','\172','\173','\174','\175','\176','\177','\200','\201',
|
||||
'\202','\203','\204','\205','\206','\207','\210','\211','\212','\213',
|
||||
'\214','\215','\216','\217','\220','\221','\222','\223','\224','\225',
|
||||
'\226','\227','\230','\231','\232','\233','\234','\235','\236','\237',
|
||||
'\040','\101','\101','\105','\105','\105','\111','\111','\047','\140',
|
||||
'\136','\042','\176','\125','\125','\234','\055','\131','\171','\370',
|
||||
'\200','\207','\245','\244','\255','\250','\052','\234','\235','\052',
|
||||
'\237','\233','\203','\210','\223','\226','\240','\202','\242','\243',
|
||||
'\205','\212','\225','\227','\204','\211','\224','\201','\217','\214',
|
||||
'\117','\222','\206','\241','\355','\221','\216','\215','\231','\232',
|
||||
'\220','\213','\341','\117','\101','\101','\141','\104','\144','\111',
|
||||
'\111','\117','\117','\117','\157','\123','\163','\125','\131','\230',
|
||||
'\052','\052','\372','\346','\052','\052','\304','\254','\253','\246',
|
||||
'\247','\256','\376','\257','\361','\040'
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
EXTERN M_WCHAR r8_to_pc8dn [256]
|
||||
#if defined(DEFINE)
|
||||
= {
|
||||
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
|
||||
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
|
||||
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
|
||||
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
|
||||
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
|
||||
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
|
||||
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
|
||||
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
|
||||
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
|
||||
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
|
||||
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
|
||||
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
|
||||
'\170','\171','\172','\173','\174','\175','\176','\177','\200','\201',
|
||||
'\202','\203','\204','\205','\206','\207','\210','\211','\212','\213',
|
||||
'\214','\215','\216','\217','\220','\221','\222','\223','\224','\225',
|
||||
'\226','\227','\230','\231','\232','\233','\234','\235','\236','\237',
|
||||
'\040','\101','\101','\105','\105','\105','\111','\111','\047','\140',
|
||||
'\136','\042','\176','\125','\125','\234','\055','\131','\171','\370',
|
||||
'\200','\207','\245','\244','\255','\250','\257','\234','\131','\052',
|
||||
'\146','\143','\203','\210','\223','\226','\240','\202','\242','\243',
|
||||
'\205','\212','\225','\227','\204','\211','\224','\201','\217','\214',
|
||||
'\235','\222','\206','\241','\233','\221','\216','\215','\231','\232',
|
||||
'\220','\213','\341','\117','\101','\252','\251','\104','\144','\111',
|
||||
'\111','\117','\117','\247','\246','\123','\163','\125','\131','\230',
|
||||
'\052','\052','\372','\346','\052','\052','\304','\052','\052','\052',
|
||||
'\052','\074','\376','\076','\361','\040'
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
14
cde/programs/dthelp/parser/pass2/parser/closent.c
Normal file
14
cde/programs/dthelp/parser/pass2/parser/closent.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $XConsortium: closent.c /main/3 1995/11/08 10:49:21 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Default close SYSTEM entity procedure */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
void m_closent(m_ptr)
|
||||
void *m_ptr ;
|
||||
{
|
||||
fclose((FILE *) m_ptr) ;
|
||||
}
|
||||
|
||||
23
cde/programs/dthelp/parser/pass2/parser/code.c
Normal file
23
cde/programs/dthelp/parser/pass2/parser/code.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $XConsortium: code.c /main/3 1995/11/08 10:49:34 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Code.c executes code entities specified in the interface. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdef.h"
|
||||
#include <time.h>
|
||||
|
||||
/* Include generated file */
|
||||
#include "entfile.c"
|
||||
|
||||
/* When a reference to a CODE entity is encountered */
|
||||
void m_codeent(m_ent)
|
||||
int m_ent ;
|
||||
{
|
||||
(*m_ctable[m_ent])() ;
|
||||
}
|
||||
|
||||
681
cde/programs/dthelp/parser/pass2/parser/context.dat
Normal file
681
cde/programs/dthelp/parser/pass2/parser/context.dat
Normal file
@@ -0,0 +1,681 @@
|
||||
m_comment
|
||||
comcon:comcon {
|
||||
/* $XConsortium: context.dat /main/3 1995/07/17 19:58:23 lehors $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
|
||||
Context.dat defines the state transitions for program PARSER.
|
||||
*/
|
||||
}
|
||||
|
||||
pdecl:pdecl,
|
||||
decl:decl,
|
||||
mapname:mapname,
|
||||
endmap:endmap,
|
||||
entname:entname,
|
||||
entval:entval,
|
||||
dupent:dupent,
|
||||
typedentval:typedentval,
|
||||
typedupent:typedupent,
|
||||
entend:entend {m_readcomments() ;}
|
||||
;
|
||||
|
||||
m_mdo
|
||||
preamble:pdecl
|
||||
datacon:decl
|
||||
elcon:decl
|
||||
netdatacon:decl
|
||||
netelcon:decl
|
||||
poundcdata:decl
|
||||
netcdata:decl
|
||||
;
|
||||
|
||||
m_mdc
|
||||
entend:preamble
|
||||
perror:preamble
|
||||
pdecl:preamble
|
||||
endmap:start
|
||||
decl:start
|
||||
derror:start
|
||||
;
|
||||
|
||||
m_usemap
|
||||
decl:mapname
|
||||
;
|
||||
|
||||
m_addmap
|
||||
decl:amapname {
|
||||
if (m_conform) m_mberr1("%s not provided in IS 8879",
|
||||
m_addmap) ;
|
||||
}
|
||||
;
|
||||
|
||||
m_empty
|
||||
mapname:endmap {m_setmap(1, TRUE) ;}
|
||||
amapname:endmap {m_setmap(1, FALSE) ;}
|
||||
;
|
||||
|
||||
m_entkw
|
||||
pdecl:entname
|
||||
;
|
||||
|
||||
m_entst
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_STARTTAG ;}
|
||||
dupent:typedupent {m_eduptype(M_STARTTAG) ;}
|
||||
;
|
||||
|
||||
m_entet
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_ENDTAG ;}
|
||||
dupent:typedupent {m_eduptype(M_ENDTAG) ;}
|
||||
;
|
||||
|
||||
m_entcdata
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_CDATAENT ;}
|
||||
dupent:typedupent {m_eduptype(M_CDATAENT) ;}
|
||||
;
|
||||
|
||||
m_entsdata
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_SDATA ;}
|
||||
dupent:typedupent {m_eduptype(M_SDATA) ;}
|
||||
;
|
||||
|
||||
m_entsystem
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_SYSTEM ;}
|
||||
dupent:typedupent {m_eduptype(M_SYSTEM) ;}
|
||||
;
|
||||
|
||||
m_entmd
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_MD ;}
|
||||
dupent:typedupent {m_eduptype(M_MD) ;}
|
||||
;
|
||||
|
||||
m_entpi
|
||||
entval:typedentval {if (m_entity) m_entity->type = M_PI ;}
|
||||
dupent:typedupent {m_eduptype(M_PI) ;}
|
||||
;
|
||||
|
||||
m_stago
|
||||
datacon:selement,
|
||||
elcon:selement,
|
||||
netdatacon:selement,
|
||||
netelcon:selement,
|
||||
poundcdata:selement,
|
||||
netcdata:selement {m_scannet = FALSE ;}
|
||||
|
||||
eelement:selement {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
selement:selement {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attname:selement {
|
||||
m_stcomplete() ;
|
||||
}
|
||||
needvi:selement {
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
etagend:selement {m_etcomplete() ;}
|
||||
;
|
||||
|
||||
m_etago
|
||||
elcon:eelement
|
||||
datacon:eelement
|
||||
netelcon:eelement
|
||||
netdatacon:eelement
|
||||
poundcdata:eelement
|
||||
netcdata:eelement
|
||||
cdatael:eelement
|
||||
rcdatael:eelement
|
||||
netelcdata:eelement
|
||||
netrcdata:eelement
|
||||
|
||||
eelement:eelement {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
selement:eelement {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attname:eelement {m_stcomplete() ;}
|
||||
needvi:eelement {
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
etagend:eelement {m_etcomplete() ;}
|
||||
;
|
||||
|
||||
m_pio
|
||||
datacon:procint
|
||||
elcon:procint
|
||||
netdatacon:procint
|
||||
netelcon:procint
|
||||
selement:procint {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
eelement:procint {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
poundcdata:procint
|
||||
netcdata:procint
|
||||
attname:procint {m_stcomplete() ;}
|
||||
needvi:procint {
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
etagend:procint {m_etcomplete() ;}
|
||||
;
|
||||
|
||||
m_tagc
|
||||
eelement:start {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stacktop->holdre = FALSE ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
selement:start {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attname:start {m_stcomplete() ;}
|
||||
etagend:start {m_etcomplete() ;}
|
||||
needvi:start {
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
;
|
||||
|
||||
m_pic
|
||||
procint:start {
|
||||
m_pi[m_pilen] = M_EOS ;
|
||||
m_piaction(m_pi, NULL, M_NULLVAL) ;
|
||||
m_pilen = 0 ;
|
||||
}
|
||||
pierror:start
|
||||
;
|
||||
|
||||
m_vi
|
||||
needvi:attval {m_findatt() ;}
|
||||
;
|
||||
|
||||
m_lit
|
||||
attname:litcon
|
||||
attval:litcon
|
||||
litcon:litcon
|
||||
;
|
||||
|
||||
m_litdelim
|
||||
entval:litent,
|
||||
typedentval:litent,
|
||||
dupent:dlitent,
|
||||
typedupent:dlitent {m_entclen = 0 ;}
|
||||
|
||||
litent:entend,
|
||||
elitent:entend {
|
||||
if (m_entity) {
|
||||
m_entcontent[m_entclen] = M_EOS ;
|
||||
m_entity->content =
|
||||
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
|
||||
w_strcpy(m_entity->content, m_entcontent) ;
|
||||
}
|
||||
}
|
||||
|
||||
dlitent:entend,
|
||||
edlitent:entend {
|
||||
m_entcontent[m_entclen] = M_EOS ;
|
||||
if (w_strcmp(m_entity->content, m_entcontent))
|
||||
m_err1("Redefinition of entity %s ignored", m_entity->name) ;
|
||||
}
|
||||
;
|
||||
|
||||
m_lita
|
||||
attname:litacon
|
||||
attval:litacon
|
||||
litacon:litacon
|
||||
;
|
||||
|
||||
m_litadelim
|
||||
entval:litaent,
|
||||
typedentval:litaent,
|
||||
dupent:dlitaent,
|
||||
typedupent:dlitaent {m_entclen = 0 ;}
|
||||
|
||||
litaent:entend,
|
||||
elitaent:entend {
|
||||
if (m_entity) {
|
||||
m_entcontent[m_entclen] = M_EOS ;
|
||||
m_entity->content =
|
||||
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
|
||||
w_strcpy(m_entity->content, m_entcontent) ;
|
||||
}
|
||||
}
|
||||
|
||||
dlitaent:entend,
|
||||
edlitaent:entend {
|
||||
m_entcontent[m_entclen] = M_EOS ;
|
||||
if (w_strcmp(m_entity->content, m_entcontent))
|
||||
m_err1("Redefinition of entity %s ignored", m_entity->name) ;
|
||||
}
|
||||
;
|
||||
|
||||
m_cro
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:poundcdata
|
||||
netelcon:netcdata
|
||||
|
||||
rcdatael:rcdatael
|
||||
netrcdata:netrcdata
|
||||
;
|
||||
|
||||
m_litrs
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_litscr
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_litre
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_litecr
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_litspace
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_litcspace
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_littab
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_litctab
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
|
||||
elcon:elcon
|
||||
netelcon:netelcon
|
||||
;
|
||||
|
||||
m_ero
|
||||
rcdatael:rcdatael
|
||||
netrcdata:netrcdata
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
datacon:datacon
|
||||
elcon:elcon
|
||||
netdatacon:netdatacon
|
||||
netelcon:netelcon
|
||||
preamble:preamble
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
entinlit:entinlit
|
||||
;
|
||||
|
||||
m_refc
|
||||
entref:entref
|
||||
;
|
||||
|
||||
m_net
|
||||
netdatacon:start,
|
||||
netelcon:start,
|
||||
netcdata:start,
|
||||
netelcdata:start,
|
||||
netrcdata:start {m_nullendtag() ;}
|
||||
selement:start {
|
||||
m_scannet = TRUE ;
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attname:start {
|
||||
m_scannet = TRUE ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
needvi:start {
|
||||
m_scannet = TRUE ;
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
m_endfile
|
||||
datacon:datacon
|
||||
elcon:elcon
|
||||
netdatacon:netdatacon
|
||||
netelcon:netelcon
|
||||
poundcdata:poundcdata
|
||||
netcdata:netcdata
|
||||
preamble:preamble {
|
||||
m_startdoc() ;
|
||||
if (! m_state[2].final) m_error("Empty document") ;
|
||||
}
|
||||
rcdatael:rcdatael
|
||||
netrcdata:netrcdata
|
||||
rcnewent:rcnewent
|
||||
cdatael:cdatael
|
||||
netelcdata:netelcdata
|
||||
eelement:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Missing %s in end-tag", m_tagc) ;
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stacktop->holdre = FALSE ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
selement:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Missing %s in start-tag", m_tagc) ;
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attname:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Invalid parameter or missing %s", m_tagc) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
etagend:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Missing %s delimiter in end-tag", m_tagc) ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
needvi:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Invalid parameter or missing %s", m_tagc) ;
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attval:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Invalid parameter or missing %s", m_tagc) ;
|
||||
m_err1("Expecting value for %s",
|
||||
&m_pname[m_parameter[m_ppsave - 1].paramname]) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
;
|
||||
|
||||
m_name
|
||||
mapname:endmap {m_ckmap(m_name, TRUE) ;}
|
||||
amapname:endmap {m_ckmap(m_name, FALSE) ;}
|
||||
entname:entval {
|
||||
m_ntrent(m_name) ;
|
||||
if (! m_entity) m_curcon = PERROR ;
|
||||
}
|
||||
selement:attname {
|
||||
{
|
||||
int i ;
|
||||
|
||||
if (m_scanel = m_eltname()) {
|
||||
for (i = 0 ; i < m_element[m_scanel - 1].parcount ; i++)
|
||||
m_poccur[i] = 0 ;
|
||||
}
|
||||
else m_curcon = START ;
|
||||
}
|
||||
}
|
||||
eelement:etagend {
|
||||
if (m_scanel = m_eltname()) m_stacktop->holdre = FALSE ;
|
||||
else
|
||||
if (m_element[m_stacktop->element - 1].content == M_CDATA ||
|
||||
m_element[m_stacktop->element - 1].content == M_RCDATA) {
|
||||
m_ckend(m_stacktop->element, FALSE) ;
|
||||
m_curcon = START ;
|
||||
}
|
||||
else m_curcon = START ;
|
||||
}
|
||||
attname:needvi {if (m_validinpar(m_name))
|
||||
w_strcpy(m_saveatt, m_name) ;}
|
||||
attval:attname {m_attval(m_name) ;}
|
||||
needvi:needvi {
|
||||
m_attvonly(m_saveatt) ;
|
||||
if (m_validinpar(m_name))
|
||||
w_strcpy(m_saveatt, m_name) ;
|
||||
}
|
||||
;
|
||||
|
||||
m_text
|
||||
litcon:litcon
|
||||
litacon:litacon
|
||||
entinlit:entinlit
|
||||
|
||||
litent:litent {m_longent(ELITENT) ;}
|
||||
litaent:litaent {m_longent(ELITAENT) ;}
|
||||
dlitent:dlitent {m_longent(EDLITENT) ;}
|
||||
dlitaent:dlitaent {m_longent(EDLITAENT) ;}
|
||||
|
||||
elitent:elitent
|
||||
elitaent:elitaent
|
||||
edlitent:edlitent
|
||||
edlitaent:edlitaent
|
||||
|
||||
perror:perror
|
||||
derror:derror
|
||||
|
||||
pdecl:perror,
|
||||
decl:derror {m_error("Invalid markup declaration") ;}
|
||||
|
||||
rcdatael:rcdatael,
|
||||
netrcdata:netrcdata,
|
||||
rcnewent:rcnewent,
|
||||
cdatael:cdatael,
|
||||
netelcdata:netelcdata,
|
||||
poundcdata:poundcdata,
|
||||
netcdata:netcdata {m_textaction(m_scanval) ;}
|
||||
|
||||
procint:procint {
|
||||
m_pi[m_pilen++] = m_scanval ;
|
||||
if (m_pilen > M_PILEN) {
|
||||
m_error("Processing instruction too long") ;
|
||||
m_pi[m_pilen - 1] = M_EOS ;
|
||||
m_piaction(m_pi, NULL, M_NULLVAL) ;
|
||||
m_curcon = PIERROR ;
|
||||
m_pilen = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
pierror:pierror
|
||||
|
||||
datacon:poundcdata,
|
||||
netdatacon:netcdata {m_strtcdata(m_scanval) ;}
|
||||
;
|
||||
|
||||
m_blackspace
|
||||
elcon:poundcdata,
|
||||
netelcon:netcdata {m_strtcdata(m_scanval) ;}
|
||||
|
||||
preamble:start {
|
||||
m_ungetachar((int) m_scanval, M_NORMAL, TRUE) ;
|
||||
m_startdoc() ;
|
||||
}
|
||||
|
||||
amapname:derror,
|
||||
mapname:derror,
|
||||
endmap:derror {m_error("Invalid usemap declaration") ;}
|
||||
|
||||
typedentval:perror,
|
||||
entname:perror,
|
||||
entval:perror,
|
||||
typedupent:perror,
|
||||
dupent:perror
|
||||
{
|
||||
m_error("Invalid ENTITY declaration") ;
|
||||
if (m_entity)
|
||||
{
|
||||
m_entcontent[m_entclen] = M_EOS ;
|
||||
m_entity->content =
|
||||
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
|
||||
w_strcpy(m_entity->content, m_entcontent) ;
|
||||
}
|
||||
}
|
||||
|
||||
entend:perror
|
||||
{
|
||||
m_error("Unexpected characters within ENTITY declaration") ;
|
||||
if (m_entity)
|
||||
{
|
||||
m_entcontent[m_entclen] = M_EOS ;
|
||||
m_entity->content =
|
||||
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
|
||||
w_strcpy(m_entity->content, m_entcontent) ;
|
||||
}
|
||||
}
|
||||
|
||||
selement:poundcdata {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_strtcdata(m_scanval) ;
|
||||
}
|
||||
eelement:poundcdata {
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_etcomplete() ;
|
||||
m_strtcdata(m_scanval) ;
|
||||
}
|
||||
;
|
||||
|
||||
m_literal
|
||||
attname:attname {m_attvonly(m_literal) ;}
|
||||
attval:attname {m_attval(m_literal) ;}
|
||||
;
|
||||
|
||||
m_entityend
|
||||
eelement:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Missing %s in entity containing end-tag", m_tagc) ;
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stacktop->holdre = FALSE ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
selement:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Missing %s in entity containing start-tag", m_tagc) ;
|
||||
if (! m_stacktop->oldtop)
|
||||
m_scanel = m_arc[m_state[0].first - 1].label ;
|
||||
else m_scanel = m_stacktop->element ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attname:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1(
|
||||
"Invalid parameter or missing %s in entity containing start-tag",
|
||||
m_tagc) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
etagend:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1("Missing %s in entity containing end-tag", m_tagc) ;
|
||||
m_etcomplete() ;
|
||||
}
|
||||
needvi:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1(
|
||||
"Invalid parameter or missing %s in entity containing start-tag",
|
||||
m_tagc) ;
|
||||
m_attvonly(m_saveatt) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
attval:start {
|
||||
if (! m_wholetag)
|
||||
m_mberr1(
|
||||
"Invalid parameter or missing %s in entity containing start-tag",
|
||||
m_tagc) ;
|
||||
m_err1("Expecting value for %s",
|
||||
&m_pname[m_parameter[m_ppsave - 1].paramname]) ;
|
||||
m_stcomplete() ;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
57
cde/programs/dthelp/parser/pass2/parser/cyclent.c
Normal file
57
cde/programs/dthelp/parser/pass2/parser/cyclent.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* $XConsortium: cyclent.c /main/3 1995/11/08 10:49:50 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Cyclent.c contains procedure m_cyclent(), callable by interface
|
||||
designers, to cycle through all defined entities, returning information
|
||||
about them */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *m_cyclent(LOGICAL init, unsigned char *type, M_WCHAR **content, unsigned char *wheredef)
|
||||
#else
|
||||
M_WCHAR *m_cyclent(init, type, content, wheredef)
|
||||
LOGICAL init ;
|
||||
unsigned char *type ;
|
||||
M_WCHAR **content ;
|
||||
unsigned char *wheredef ;
|
||||
#endif
|
||||
{
|
||||
static M_TRIE *current ;
|
||||
static M_TRIE *ancestor[M_NAMELEN + 1] ;
|
||||
static length = 0 ;
|
||||
static M_WCHAR name[M_NAMELEN + 1] ;
|
||||
|
||||
if (init) {
|
||||
current = m_enttrie->data ;
|
||||
length = 0 ;
|
||||
}
|
||||
if (length < 0) return(NULL) ;
|
||||
while (current->symbol) {
|
||||
ancestor[length] = current ;
|
||||
name[length++] = current->symbol ;
|
||||
current = current->data ;
|
||||
}
|
||||
name[length] = M_EOS ;
|
||||
*type = ((M_ENTITY *) current->data)->type ;
|
||||
*content = ((M_ENTITY *) current->data)->content ;
|
||||
*wheredef = ((M_ENTITY *) current->data)->wheredef ;
|
||||
while (length >= 0) {
|
||||
if (current->next) {
|
||||
current = current->next ;
|
||||
break ;
|
||||
}
|
||||
length-- ;
|
||||
if (length < 0) break ;
|
||||
current = ancestor[length] ;
|
||||
}
|
||||
return(name) ;
|
||||
}
|
||||
|
||||
23
cde/programs/dthelp/parser/pass2/parser/dcurelt.c
Normal file
23
cde/programs/dthelp/parser/pass2/parser/dcurelt.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $XConsortium: dcurelt.c /main/3 1995/11/08 10:50:02 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Displays current element after some error messages */
|
||||
void m_dispcurelt(file, line)
|
||||
M_WCHAR *file ;
|
||||
int line ;
|
||||
{
|
||||
char *mb_parent;
|
||||
|
||||
m_errline("Current element is ") ;
|
||||
mb_parent = MakeMByteString(m_parent(0));
|
||||
m_errline(mb_parent) ;
|
||||
m_free(mb_parent,"multi-byte string");
|
||||
m_errline(" begun on ") ;
|
||||
m_dumpline(file, line) ;
|
||||
m_errline(".\n") ;
|
||||
}
|
||||
39
cde/programs/dthelp/parser/pass2/parser/delfree.c
Normal file
39
cde/programs/dthelp/parser/pass2/parser/delfree.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $XConsortium: delfree.c /main/3 1995/11/08 10:50:16 rswiston $ */
|
||||
/* Copyright (c) 1988 Hewlett-Packard Co. */
|
||||
|
||||
/* Versions of m_free and m_malloc for debugging. */
|
||||
|
||||
/**/
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtd.h"
|
||||
#include "parser.h"
|
||||
|
||||
m_free(block, msg)
|
||||
char *block ;
|
||||
char *msg ;
|
||||
{
|
||||
free(block) ;
|
||||
fprintf(m_outfile, "%5u:%5u- Freed %s\n",
|
||||
(unsigned int) ((unsigned long) block >> 16),
|
||||
(unsigned int) block, msg) ;
|
||||
}
|
||||
|
||||
char *m_mallocx(size, msg)
|
||||
int size ;
|
||||
char *msg ;
|
||||
{
|
||||
char *p ;
|
||||
|
||||
if (! size) return(NULL) ;
|
||||
p = malloc(size) ;
|
||||
if (! p) {
|
||||
m_err1("Unable to allocate space for %s", msg) ;
|
||||
exit(TRUE) ;
|
||||
}
|
||||
fprintf(m_outfile, "%5u:%5u- Allocated %s\n",
|
||||
(unsigned int) ((unsigned long) p >> 16), (unsigned int) p, msg) ;
|
||||
return(p) ;
|
||||
}
|
||||
28
cde/programs/dthelp/parser/pass2/parser/dmpline.c
Normal file
28
cde/programs/dthelp/parser/pass2/parser/dmpline.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* $XConsortium: dmpline.c /main/3 1995/11/08 10:50:31 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Write input file and line number for an error message */
|
||||
void m_dumpline(file, line)
|
||||
M_WCHAR *file ;
|
||||
int line ;
|
||||
{
|
||||
char buffer[10] ;
|
||||
|
||||
m_errline("Line ") ;
|
||||
sprintf(buffer, "%d", line) ;
|
||||
m_errline(buffer) ;
|
||||
if (file)
|
||||
{
|
||||
char mb_file;
|
||||
|
||||
m_errline(" of File ") ;
|
||||
mb_file = MakeMByteString(file);
|
||||
m_errline(mb_file) ;
|
||||
m_free(mb_file,"multi-byte string");
|
||||
}
|
||||
}
|
||||
23
cde/programs/dthelp/parser/pass2/parser/end.c
Normal file
23
cde/programs/dthelp/parser/pass2/parser/end.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $XConsortium: end.c /main/3 1995/11/08 10:50:46 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* End.c executes end-code specified in the interface. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Include generated file */
|
||||
#include "efile.c"
|
||||
|
||||
|
||||
/* Perform the m_action-th end-code in the interface */
|
||||
void m_endcase(m_action)
|
||||
int m_action ;
|
||||
{
|
||||
(*m_etable[m_action])() ;
|
||||
}
|
||||
|
||||
95
cde/programs/dthelp/parser/pass2/parser/entity.c
Normal file
95
cde/programs/dthelp/parser/pass2/parser/entity.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/* $XConsortium: entity.c /main/3 1995/11/08 10:51:00 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Entity.c contains procedures pertaining to entities */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "context.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
|
||||
/* Process the name in a usemap delaration */
|
||||
#if defined(M_PROTO)
|
||||
void m_ckmap(M_WCHAR *name, LOGICAL useoradd)
|
||||
#else
|
||||
void m_ckmap(name, useoradd)
|
||||
M_WCHAR *name ;
|
||||
LOGICAL useoradd ;
|
||||
#endif
|
||||
{
|
||||
int mapid ;
|
||||
|
||||
if (mapid = m_packedlook(m_maptree, name))
|
||||
m_setmap(mapid + 1, useoradd) ;
|
||||
else m_err1("Undefined short reference map %s", name) ;
|
||||
}
|
||||
|
||||
/* Check type specified in entity declaration for previously defined
|
||||
entity. Testing to see if the new declaration is identical to the
|
||||
original one. */
|
||||
void m_eduptype(type)
|
||||
int type ;
|
||||
{
|
||||
if ((int) m_entity->type != type) {
|
||||
m_err1("Redefinition of entity %s ignored", m_entity->name) ;
|
||||
m_entity = NULL ;
|
||||
m_curcon = TYPEDENTVAL ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tests if an entity is too long */
|
||||
void m_longent(context)
|
||||
int context ;
|
||||
{
|
||||
if (m_entclen >= M_LITLEN) {
|
||||
m_curcon = context ;
|
||||
m_error("Entity content too long") ;
|
||||
}
|
||||
else m_entcontent[m_entclen++] = m_scanval ;
|
||||
}
|
||||
|
||||
/* Enters an entity name into the entity name tree */
|
||||
void m_ntrent(p)
|
||||
M_WCHAR *p ;
|
||||
{
|
||||
M_ENTITY *new ;
|
||||
|
||||
new = (M_ENTITY *) m_malloc(sizeof(M_ENTITY), "entity") ;
|
||||
if (m_entity = (M_ENTITY *) m_ntrtrie(p, m_enttrie, (M_TRIE *) new)) {
|
||||
m_free(new, "entity") ;
|
||||
if (m_entity->wheredef == M_DPARSER) {
|
||||
if (m_entdupchk) {
|
||||
m_err1("Redefinition of entity %s ignored", p) ;
|
||||
m_entity = NULL ;
|
||||
}
|
||||
else m_curcon = DUPENT ;
|
||||
}
|
||||
else {
|
||||
if (m_entity->content) {
|
||||
m_err1("Warning: Redefinition of predefined entity %s", p) ;
|
||||
m_entity->type = M_GENERAL ;
|
||||
m_entity->content = NULL ;
|
||||
}
|
||||
m_entity->wheredef = M_DPARSER ;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
m_entity = new ;
|
||||
m_entity->type = M_GENERAL ;
|
||||
m_entity->wheredef = M_DPARSER ;
|
||||
m_entity->content = NULL ;
|
||||
m_entity->name = (M_WCHAR *) m_malloc(w_strlen(p) + 1, "entity name") ;
|
||||
w_strcpy(m_entity->name, p) ;
|
||||
}
|
||||
14
cde/programs/dthelp/parser/pass2/parser/eprefix.c
Normal file
14
cde/programs/dthelp/parser/pass2/parser/eprefix.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $XConsortium: eprefix.c /main/3 1995/11/08 10:51:14 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Write error message prefix */
|
||||
void m_eprefix(M_NOPAR)
|
||||
{
|
||||
m_errline("\n*****\n") ;
|
||||
}
|
||||
|
||||
20
cde/programs/dthelp/parser/pass2/parser/errline.c
Normal file
20
cde/programs/dthelp/parser/pass2/parser/errline.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* $XConsortium: errline.c /main/3 1995/11/08 10:51:28 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Process error message text */
|
||||
void m_errline(p)
|
||||
M_WCHAR *p ;
|
||||
{
|
||||
char mb_p;
|
||||
|
||||
mb_p = MakeMByteString(p);
|
||||
fputs(mb_p, m_errfile) ;
|
||||
fputs(mb_p, stderr) ;
|
||||
m_free(mb_p,"multi-byte string");
|
||||
}
|
||||
|
||||
466
cde/programs/dthelp/parser/pass2/parser/error.c
Normal file
466
cde/programs/dthelp/parser/pass2/parser/error.c
Normal file
@@ -0,0 +1,466 @@
|
||||
/* $XConsortium: error.c /main/3 1995/11/08 10:51:44 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Util.c contains general utilities for program PARSER */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
|
||||
|
||||
/* Issue error message (no arguments) */
|
||||
void m_error(text)
|
||||
char *text;
|
||||
{
|
||||
m_startmsg();
|
||||
m_errline(text);
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Issue error message (one argument) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err1(
|
||||
const char *text,
|
||||
const M_WCHAR *arg)
|
||||
#else
|
||||
void m_err1(text, arg)
|
||||
char *text;
|
||||
M_WCHAR *arg;
|
||||
#endif
|
||||
{
|
||||
char *buffer, *mb_arg;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for the %s and add an EOS*/
|
||||
mb_arg = MakeMByteString(arg);
|
||||
buffer = (char *)
|
||||
m_malloc(strlen(text) + strlen(mb_arg) - 2 + 1, "error message");
|
||||
sprintf(buffer, text, mb_arg);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void m_mberr1(
|
||||
const char *text,
|
||||
const char *arg)
|
||||
#else
|
||||
void m_err1(text, arg)
|
||||
char *text;
|
||||
char *arg;
|
||||
#endif
|
||||
{
|
||||
M_WCHAR *wc_arg;
|
||||
|
||||
wc_arg = MakeWideCharString(arg);
|
||||
m_err1(text, wc_arg);
|
||||
m_free(wc_arg,"wide character string");
|
||||
}
|
||||
|
||||
/* Issue error message (two arguments) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err2(
|
||||
const char *text,
|
||||
const M_WCHAR *arg1,
|
||||
const M_WCHAR *arg2)
|
||||
#else
|
||||
void m_err2(text, arg1, arg2)
|
||||
char *text;
|
||||
M_WCHAR *arg1;
|
||||
M_WCHAR *arg2;
|
||||
#endif
|
||||
{
|
||||
char *buffer;
|
||||
char *mb_arg1,*mb_arg2;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for each of 2 %s's and add an EOS*/
|
||||
mb_arg1 = MakeMByteString(arg1);
|
||||
mb_arg2 = MakeMByteString(arg2);
|
||||
buffer = (char *) m_malloc(
|
||||
strlen(text) + strlen(mb_arg1) + strlen(mb_arg2) - 4 + 1,
|
||||
"error message");
|
||||
sprintf(buffer, text, mb_arg1, mb_arg2);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg1,"multi-byte string");
|
||||
m_free(mb_arg2,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Issue error message (three arguments) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err3(
|
||||
char *text,
|
||||
M_WCHAR *arg1,
|
||||
M_WCHAR *arg2,
|
||||
M_WCHAR *arg3)
|
||||
#else
|
||||
void m_err3(text, arg1, arg2, arg3)
|
||||
char *text;
|
||||
M_WCHAR *arg1;
|
||||
M_WCHAR *arg2;
|
||||
M_WCHAR *arg3;
|
||||
#endif
|
||||
{
|
||||
char *buffer;
|
||||
char *mb_arg1, *mb_arg2, *mb_arg3;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for each of 3 %s's and add an EOS*/
|
||||
mb_arg1 = MakeMByteString(arg1);
|
||||
mb_arg2 = MakeMByteString(arg2);
|
||||
mb_arg3 = MakeMByteString(arg3);
|
||||
buffer = (char *) m_malloc(
|
||||
strlen(text) +
|
||||
strlen(mb_arg1) +
|
||||
strlen(mb_arg2) +
|
||||
strlen(mb_arg3) - 6 + 1,
|
||||
"error message");
|
||||
sprintf(buffer, text, mb_arg1, mb_arg2, mb_arg3);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg1,"multi-byte string");
|
||||
m_free(mb_arg2,"multi-byte string");
|
||||
m_free(mb_arg3,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Issue error message (four arguments) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err4(
|
||||
char *text,
|
||||
M_WCHAR *arg1,
|
||||
M_WCHAR *arg2,
|
||||
M_WCHAR *arg3,
|
||||
M_WCHAR *arg4)
|
||||
#else
|
||||
void m_err4(text, arg1, arg2, arg3, arg4)
|
||||
char *text;
|
||||
M_WCHAR *arg1;
|
||||
M_WCHAR *arg2;
|
||||
M_WCHAR *arg3;
|
||||
M_WCHAR *arg4;
|
||||
#endif
|
||||
{
|
||||
char *buffer;
|
||||
char *mb_arg1, *mb_arg2,*mb_arg3,*mb_arg4;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for each of 4 %s's and add an EOS*/
|
||||
mb_arg1 = MakeMByteString(arg1);
|
||||
mb_arg2 = MakeMByteString(arg2);
|
||||
mb_arg3 = MakeMByteString(arg3);
|
||||
mb_arg4 = MakeMByteString(arg4);
|
||||
buffer = (char *) m_malloc(
|
||||
strlen(text) +
|
||||
strlen(mb_arg1) +
|
||||
strlen(mb_arg2) +
|
||||
strlen(mb_arg3) +
|
||||
strlen(mb_arg4) - 8 + 1,
|
||||
"error message");
|
||||
sprintf(buffer, text, arg1, arg2, arg3, arg4);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg1,"multi-byte string");
|
||||
m_free(mb_arg2,"multi-byte string");
|
||||
m_free(mb_arg3,"multi-byte string");
|
||||
m_free(mb_arg4,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Issue error message (five arguments) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err5(
|
||||
char *text,
|
||||
M_WCHAR *arg1,
|
||||
M_WCHAR *arg2,
|
||||
M_WCHAR *arg3,
|
||||
M_WCHAR *arg4,
|
||||
M_WCHAR *arg5)
|
||||
#else
|
||||
void m_err5(text, arg1, arg2, arg3, arg4, arg5)
|
||||
char *text;
|
||||
M_WCHAR *arg1;
|
||||
M_WCHAR *arg2;
|
||||
M_WCHAR *arg3;
|
||||
M_WCHAR *arg4;
|
||||
M_WCHAR *arg5;
|
||||
#endif
|
||||
{
|
||||
char *buffer;
|
||||
char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for each of 5 %s's and add an EOS*/
|
||||
mb_arg1 = MakeMByteString(arg1);
|
||||
mb_arg2 = MakeMByteString(arg2);
|
||||
mb_arg3 = MakeMByteString(arg3);
|
||||
mb_arg4 = MakeMByteString(arg4);
|
||||
mb_arg5 = MakeMByteString(arg5);
|
||||
buffer = (char *) m_malloc(
|
||||
strlen(text) +
|
||||
strlen(mb_arg1) +
|
||||
strlen(mb_arg2) +
|
||||
strlen(mb_arg3) +
|
||||
strlen(mb_arg4) +
|
||||
strlen(mb_arg5) - 10 + 1,
|
||||
"error message");
|
||||
sprintf(buffer,
|
||||
text,
|
||||
mb_arg1,
|
||||
mb_arg2,
|
||||
mb_arg3,
|
||||
mb_arg4,
|
||||
mb_arg5);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg1,"multi-byte string");
|
||||
m_free(mb_arg2,"multi-byte string");
|
||||
m_free(mb_arg3,"multi-byte string");
|
||||
m_free(mb_arg4,"multi-byte string");
|
||||
m_free(mb_arg5,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Issue error message (six arguments) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err6(
|
||||
char *text,
|
||||
M_WCHAR *arg1,
|
||||
M_WCHAR *arg2,
|
||||
M_WCHAR *arg3,
|
||||
M_WCHAR *arg4,
|
||||
M_WCHAR *arg5,
|
||||
M_WCHAR *arg6)
|
||||
#else
|
||||
void m_err6(text, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
char *text;
|
||||
M_WCHAR *arg1;
|
||||
M_WCHAR *arg2;
|
||||
M_WCHAR *arg3;
|
||||
M_WCHAR *arg4;
|
||||
M_WCHAR *arg5;
|
||||
M_WCHAR *arg6;
|
||||
#endif
|
||||
{
|
||||
char *buffer;
|
||||
char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5, *mb_arg6;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for each of 6 %s's and add an EOS*/
|
||||
mb_arg1 = MakeMByteString(arg1);
|
||||
mb_arg2 = MakeMByteString(arg2);
|
||||
mb_arg3 = MakeMByteString(arg3);
|
||||
mb_arg4 = MakeMByteString(arg4);
|
||||
mb_arg5 = MakeMByteString(arg5);
|
||||
mb_arg6 = MakeMByteString(arg6);
|
||||
buffer = (char *) m_malloc(
|
||||
strlen(text) +
|
||||
strlen(mb_arg1) +
|
||||
strlen(mb_arg2) +
|
||||
strlen(mb_arg3) +
|
||||
strlen(mb_arg4) +
|
||||
strlen(mb_arg5) +
|
||||
strlen(mb_arg6) - 12 + 1,
|
||||
"error message");
|
||||
sprintf(buffer,
|
||||
text,
|
||||
mb_arg1,
|
||||
mb_arg2,
|
||||
mb_arg3,
|
||||
mb_arg4,
|
||||
mb_arg5,
|
||||
mb_arg6);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg1,"multi-byte string");
|
||||
m_free(mb_arg2,"multi-byte string");
|
||||
m_free(mb_arg3,"multi-byte string");
|
||||
m_free(mb_arg4,"multi-byte string");
|
||||
m_free(mb_arg5,"multi-byte string");
|
||||
m_free(mb_arg6,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Issue error message (seven arguments) */
|
||||
#if defined(M_PROTO)
|
||||
void m_err7(
|
||||
char *text,
|
||||
M_WCHAR *arg1,
|
||||
M_WCHAR *arg2,
|
||||
M_WCHAR *arg3,
|
||||
M_WCHAR *arg4,
|
||||
M_WCHAR *arg5,
|
||||
M_WCHAR *arg6,
|
||||
M_WCHAR *arg7)
|
||||
#else
|
||||
void m_err7(text, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
||||
char *text;
|
||||
M_WCHAR *arg1;
|
||||
M_WCHAR *arg2;
|
||||
M_WCHAR *arg3;
|
||||
M_WCHAR *arg4;
|
||||
M_WCHAR *arg5;
|
||||
M_WCHAR *arg6;
|
||||
M_WCHAR *arg7;
|
||||
#endif
|
||||
{
|
||||
char *buffer;
|
||||
char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5, *mb_arg6, *mb_arg7;
|
||||
|
||||
m_startmsg();
|
||||
/* Subtract 2 characters for each of 7 %s's and add an EOS*/
|
||||
mb_arg1 = MakeMByteString(arg1);
|
||||
mb_arg2 = MakeMByteString(arg2);
|
||||
mb_arg3 = MakeMByteString(arg3);
|
||||
mb_arg4 = MakeMByteString(arg4);
|
||||
mb_arg5 = MakeMByteString(arg5);
|
||||
mb_arg6 = MakeMByteString(arg6);
|
||||
mb_arg7 = MakeMByteString(arg7);
|
||||
buffer = (char *) m_malloc(
|
||||
strlen(text) +
|
||||
strlen(mb_arg1) +
|
||||
strlen(mb_arg2) +
|
||||
strlen(mb_arg3) +
|
||||
strlen(mb_arg4) +
|
||||
strlen(mb_arg5) +
|
||||
strlen(mb_arg6) +
|
||||
strlen(mb_arg7) - 14 + 1,
|
||||
"error message");
|
||||
sprintf(buffer,
|
||||
text,
|
||||
mb_arg1,
|
||||
mb_arg2,
|
||||
mb_arg3,
|
||||
mb_arg4,
|
||||
mb_arg5,
|
||||
mb_arg6,
|
||||
mb_arg7);
|
||||
m_errline(buffer);
|
||||
m_free(buffer, "error message");
|
||||
m_free(mb_arg1,"multi-byte string");
|
||||
m_free(mb_arg2,"multi-byte string");
|
||||
m_free(mb_arg3,"multi-byte string");
|
||||
m_free(mb_arg4,"multi-byte string");
|
||||
m_free(mb_arg5,"multi-byte string");
|
||||
m_free(mb_arg6,"multi-byte string");
|
||||
m_free(mb_arg7,"multi-byte string");
|
||||
m_esuffix();
|
||||
}
|
||||
|
||||
/* Getline.c returns the name of the current input file and the number
|
||||
of the current line */
|
||||
void m_getline(file, line)
|
||||
M_WCHAR **file;
|
||||
int *line;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (m_sysecnt) {
|
||||
for (i = m_eopencnt ; i ; i--)
|
||||
if (m_opene[i - 1]->type == M_SYSTEM) break;
|
||||
*file = m_opene[i - 1]->content;
|
||||
}
|
||||
else *file = NULL;
|
||||
*line = m_line[m_sysecnt];
|
||||
}
|
||||
|
||||
/* Dump last characters read from input stream to give context to
|
||||
an error message */
|
||||
void m_lastchars(M_NOPAR)
|
||||
{
|
||||
int i;
|
||||
M_WCHAR buffer[2];
|
||||
|
||||
buffer[1] = M_EOS;
|
||||
if (m_svlnwrap[m_sysecnt] || m_svlncnt[m_sysecnt])
|
||||
m_errline("...");
|
||||
if (m_svlnwrap[m_sysecnt])
|
||||
for (i = m_svlncnt[m_sysecnt] ; i < M_LINELENGTH ; i++)
|
||||
{
|
||||
char *mb_buffer;
|
||||
|
||||
buffer[0] = (M_WCHAR) m_saveline[i][m_sysecnt];
|
||||
if (buffer[0] == (M_WCHAR) -1)
|
||||
{
|
||||
m_errline("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
mb_buffer = MakeMByteString(buffer);
|
||||
m_errline(mb_buffer);
|
||||
m_free(mb_buffer,"multi-byte string");
|
||||
}
|
||||
}
|
||||
for (i = 0 ; i < m_svlncnt[m_sysecnt] ; i++)
|
||||
{
|
||||
char *mb_buffer;
|
||||
buffer[0] = (M_WCHAR) m_saveline[i][m_sysecnt];
|
||||
|
||||
if (buffer[0] == (M_WCHAR) -1)
|
||||
{
|
||||
m_errline("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
mb_buffer = MakeMByteString(buffer);
|
||||
m_errline(mb_buffer);
|
||||
m_free(mb_buffer,"multi-byte string");
|
||||
}
|
||||
}
|
||||
if ((m_svlncnt[m_sysecnt] &&
|
||||
m_saveline[m_svlncnt[m_sysecnt] - 1][m_sysecnt] != M_RE) ||
|
||||
(! m_svlncnt[m_sysecnt] && m_svlnwrap[m_sysecnt] &&
|
||||
m_saveline[M_LINELENGTH - 1][m_sysecnt] != M_RE)
|
||||
) m_errline("...\n");
|
||||
}
|
||||
|
||||
/* Display information about the current element */
|
||||
void m_showcurelt(M_NOPAR)
|
||||
{
|
||||
if (m_stacktop->oldtop)
|
||||
m_dispcurelt(m_stacktop->file, m_stacktop->line);
|
||||
}
|
||||
|
||||
/* Start an error message */
|
||||
void m_startmsg(M_NOPAR)
|
||||
{
|
||||
m_eprefix();
|
||||
m_errexit = TRUE;
|
||||
}
|
||||
|
||||
/* Return the name of the current input file (most recently opened, but
|
||||
unclosed SYSTEM entity) */
|
||||
M_WCHAR *m_thisfile(M_NOPAR)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (m_sysecnt) {
|
||||
for (i = m_eopencnt ; i ; i--)
|
||||
if (m_opene[i - 1]->type == M_SYSTEM)
|
||||
return(m_opene[i - 1]->content);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Return the line number in the current input file */
|
||||
int m_thisline(M_NOPAR)
|
||||
{
|
||||
return(m_line[m_sysecnt]);
|
||||
}
|
||||
24
cde/programs/dthelp/parser/pass2/parser/esuffix.c
Normal file
24
cde/programs/dthelp/parser/pass2/parser/esuffix.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* $XConsortium: esuffix.c /main/3 1995/11/08 10:52:01 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
/* Write error message suffix */
|
||||
void m_esuffix(M_NOPAR)
|
||||
{
|
||||
m_errline("\n") ;
|
||||
m_dumpline(m_thisfile(), m_thisline()) ;
|
||||
m_errline(":\n") ;
|
||||
m_lastchars() ;
|
||||
if (++m_errcnt == m_errlim) {
|
||||
m_error("Too many errors, processing stopped") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
}
|
||||
|
||||
19
cde/programs/dthelp/parser/pass2/parser/exit.c
Normal file
19
cde/programs/dthelp/parser/pass2/parser/exit.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* $XConsortium: exit.c /main/3 1995/11/08 10:52:16 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
/* Default version of PARSER m_exit(). Allows interface control if
|
||||
internal error causes PARSER to halt. */
|
||||
void m_exit(status)
|
||||
int status ;
|
||||
{
|
||||
exit(status) ;
|
||||
}
|
||||
|
||||
77
cde/programs/dthelp/parser/pass2/parser/findpar.c
Normal file
77
cde/programs/dthelp/parser/pass2/parser/findpar.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/* $XConsortium: findpar.c /main/3 1995/11/08 10:52:30 rswiston $ */
|
||||
/*
|
||||
Copyright 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Function callable by interface designers. Returns index in parameter
|
||||
list of a specified parameter for an element (i.e., 1 for first parameter
|
||||
specified in the DTD, 2 for second, etc.). First parameter, elt, is
|
||||
the name of the element. Second parameter is the name of the parameter
|
||||
or NULL. Third parameter is used only if second parameter is NULL. In
|
||||
the latter case, function returns first keyword parameter, if any, for
|
||||
which the specified value is a legal value and otherwise first
|
||||
Returns 0 if elt is not a valid element name, if param is specified
|
||||
but is not a valid parameter name, or if param is NULL and value is
|
||||
not a valid value of any of elt's parameters. */
|
||||
#if defined(M_PROTO)
|
||||
int m_findpar( const char *elt , const char *param , const M_WCHAR *value )
|
||||
#else
|
||||
int m_findpar(elt, param, value)
|
||||
char *elt ;
|
||||
char *param ;
|
||||
M_WCHAR *value ;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
M_ELEMENT eltid ;
|
||||
int par ;
|
||||
int i ;
|
||||
M_WCHAR *wc_elt;
|
||||
|
||||
wc_elt = MakeWideCharString(elt);
|
||||
if (! (eltid = m_packedlook(m_entree, wc_elt)))
|
||||
{
|
||||
m_free(wc_elt,"wide character string");
|
||||
return(M_NULLVAL) ;
|
||||
}
|
||||
m_free(wc_elt,"wide character string");
|
||||
|
||||
/* A parameter name specified */
|
||||
if (param)
|
||||
{
|
||||
for (par = m_element[eltid - 1].parptr, i = 1 ;
|
||||
|
||||
i <= m_element[eltid - 1].parcount ;
|
||||
par++, i++)
|
||||
if (!m_wcmbupstrcmp(&m_pname[m_parameter[par - 1].paramname], param))
|
||||
return(i) ;
|
||||
return(M_NULLVAL) ;
|
||||
}
|
||||
|
||||
/* No parameter name specified */
|
||||
|
||||
/* First check is it a valid keyword? */
|
||||
for (par = m_element[eltid - 1].parptr, i = 1 ;
|
||||
i <= m_element[eltid - 1].parcount ;
|
||||
par++, i++)
|
||||
if (m_parameter[par - 1].type == M_KEYWORD)
|
||||
if (m_partype(par, value)) return(i) ;
|
||||
|
||||
/* It wasn't a keyword. Check for valid value for some other parameter.*/
|
||||
for (par = m_element[eltid - 1].parptr, i = 1 ;
|
||||
i <= m_element[eltid - 1].parcount ;
|
||||
par++, i++)
|
||||
{
|
||||
if (m_parameter[par - 1].type == M_KEYWORD) continue ;
|
||||
if (m_partype(par, value)) return(i) ;
|
||||
}
|
||||
|
||||
/* Not a valid value for any parameter */
|
||||
return(M_NULLVAL) ;
|
||||
}
|
||||
|
||||
13
cde/programs/dthelp/parser/pass2/parser/getc.c
Normal file
13
cde/programs/dthelp/parser/pass2/parser/getc.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* $XConsortium: getc.c /main/3 1995/11/08 10:52:46 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Default get-char procedure */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
int m_getc(m_ptr)
|
||||
void *m_ptr ;
|
||||
{
|
||||
return(getc((FILE*) m_ptr)) ;
|
||||
}
|
||||
20
cde/programs/dthelp/parser/pass2/parser/getsign.c
Normal file
20
cde/programs/dthelp/parser/pass2/parser/getsign.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* $XConsortium: getsign.c /main/3 1995/11/08 10:53:02 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Issue interface-generated sign-on message */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "signonx.h"
|
||||
|
||||
void m_getsignon(M_NOPAR)
|
||||
{
|
||||
m_errline(m_signon) ;
|
||||
}
|
||||
|
||||
|
||||
49
cde/programs/dthelp/parser/pass2/parser/ifdata.c
Normal file
49
cde/programs/dthelp/parser/pass2/parser/ifdata.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/* $XConsortium: ifdata.c /main/3 1995/11/08 10:53:18 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Ifdata.c contains functions used by the interface to access the
|
||||
single item of interface-determined data stored on the parse stack. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Retrieve the interface data stored with the current element's nth parent */
|
||||
void *m_getdata(n, flag)
|
||||
int n ;
|
||||
LOGICAL *flag ;
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop && n >= 0 ;
|
||||
stackptr = stackptr->oldtop, n--) {
|
||||
if (! n) {
|
||||
*flag = TRUE ;
|
||||
return(stackptr->ifdata) ;
|
||||
}
|
||||
}
|
||||
*flag = FALSE ;
|
||||
return(NULL) ;
|
||||
}
|
||||
|
||||
/* Store interface data for the current element's nth parent */
|
||||
LOGICAL m_putdata(data, n)
|
||||
void *data ;
|
||||
int n ;
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop && n >= 0 ;
|
||||
stackptr = stackptr->oldtop, n--) {
|
||||
if (! n) {
|
||||
stackptr->ifdata = data ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
}
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
140
cde/programs/dthelp/parser/pass2/parser/input.c
Normal file
140
cde/programs/dthelp/parser/pass2/parser/input.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/* $XConsortium: input.c /main/3 1995/11/08 10:53:34 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Input.c contains procedures that deal with the interface between the
|
||||
scanner and parser for PARSER */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* M_etcomplete is called when a complete end-tag has been read */
|
||||
void m_etcomplete(M_NOPAR)
|
||||
{
|
||||
if (! m_scanel) {
|
||||
M_WCHAR *wc_etago, *wc_tagc;
|
||||
|
||||
wc_etago = MakeWideCharString(m_etago);
|
||||
wc_tagc = MakeWideCharString(m_tagc);
|
||||
m_err3("%s%s%s ignored: element undefined", wc_etago, m_name, wc_tagc) ;
|
||||
m_free(wc_etago,"multi-byte string");
|
||||
m_free(wc_tagc,"multi-byte string");
|
||||
}
|
||||
else
|
||||
if (! m_ckend(m_scanel, FALSE)) {
|
||||
m_err1("End tag for %s unexpected", m_nameofelt(m_scanel)) ;
|
||||
m_expecting() ;
|
||||
m_showcurelt() ;
|
||||
if (m_element[m_stacktop->element - 1].content == M_CDATA ||
|
||||
m_element[m_stacktop->element - 1].content == M_RCDATA)
|
||||
m_ckend(m_stacktop->element, FALSE) ;
|
||||
m_frcend(m_scanel) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* M_frcend is called after a syntax error to end element VAL even
|
||||
if more content for that element is expected */
|
||||
void m_frcend(val)
|
||||
M_ELEMENT val ;
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
M_ELEMENT poppedval ;
|
||||
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop && stackptr->element != val ;
|
||||
stackptr = stackptr->oldtop) ;
|
||||
if (! stackptr->oldtop) {
|
||||
m_err1("No %s element currently opened", m_nameofelt(val)) ;
|
||||
if (m_stacktop->oldtop)
|
||||
if (m_element[m_stacktop->element].content == M_CDATA ||
|
||||
m_element[m_stacktop->element].content == M_RCDATA)
|
||||
m_ckend(m_stacktop->element, FALSE) ;
|
||||
return ;
|
||||
}
|
||||
while (TRUE) {
|
||||
poppedval = m_stacktop->element ;
|
||||
m_endaction(m_stacktop->element) ;
|
||||
m_pop() ;
|
||||
if (poppedval == val) return ;
|
||||
}
|
||||
}
|
||||
|
||||
/* M_frcstart is called to force the start of an element when that element
|
||||
cannot legally occur in the current context but does appear in the text*/
|
||||
void m_frcstart(M_NOPAR)
|
||||
{
|
||||
m_push(m_scanel, m_element[m_scanel - 1].start, m_scannet) ;
|
||||
if (m_scannet) m_netlevel++ ;
|
||||
m_stacktop->contextual = FALSE ;
|
||||
m_stkparams() ;
|
||||
if (m_element[m_scanel - 1].content == M_CDATA ||
|
||||
m_element[m_scanel - 1].content == M_RCDATA) {
|
||||
m_stacktop->intext = TRUE ;
|
||||
m_curcon = m_element[m_scanel - 1].content == M_CDATA ?
|
||||
CDATAEL : RCDATAEL ;
|
||||
m_stacktop->thisent = m_eopencnt ;
|
||||
}
|
||||
}
|
||||
|
||||
/* M_holdproc processes a RE that was saved to test if it was the last
|
||||
RE in an element's content */
|
||||
void m_holdproc(M_NOPAR)
|
||||
{
|
||||
if (m_stacktop->holdre) {
|
||||
m_stacktop->holdre = FALSE ;
|
||||
if (m_stacktop->intext) m_textaction(M_RE) ;
|
||||
else {
|
||||
m_strtcdata((int) M_RE) ;
|
||||
if (m_curcon == NETDATACON) m_curcon = NETCDATA ;
|
||||
else if (m_curcon == DATACON) m_curcon = POUNDCDATA ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* M_stcomplete is called when a complete start tag has been recognized */
|
||||
void m_stcomplete(M_NOPAR)
|
||||
{
|
||||
if (! m_scanel) return ;
|
||||
if (m_strtproc(m_scanel))
|
||||
m_stkparams() ;
|
||||
else {
|
||||
if (m_stacktop->holdre) m_holdproc() ;
|
||||
/* M_strtproc should not return TRUE as long as #PCDATA is considered
|
||||
optional, but this code should work if the standard is changed */
|
||||
if (m_strtproc(m_scanel)) m_stkparams() ;
|
||||
else {
|
||||
if (m_stacktop->oldtop) {
|
||||
m_err2("%s not allowed at this point in %s",
|
||||
m_nameofelt(m_scanel),
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_expecting() ;
|
||||
m_showcurelt() ;
|
||||
}
|
||||
else if (! m_start) {
|
||||
M_WCHAR *wc_stago, *wc_tagc;
|
||||
|
||||
wc_stago = MakeWideCharString(m_stago);
|
||||
wc_tagc = MakeWideCharString(m_tagc);
|
||||
m_err6("Expecting %s%s%s instead of %s%s%s to start document",
|
||||
wc_stago,
|
||||
m_nameofelt(1),
|
||||
wc_tagc,
|
||||
wc_stago,
|
||||
m_nameofelt(m_scanel),
|
||||
wc_tagc) ;
|
||||
m_free(wc_stago,"multi-byte string");
|
||||
m_free(wc_tagc,"multi-byte string");
|
||||
}
|
||||
m_frcstart() ;
|
||||
}
|
||||
}
|
||||
if (m_element[m_scanel - 1].content == M_NONE) m_endtag(m_scanel) ;
|
||||
}
|
||||
39
cde/programs/dthelp/parser/pass2/parser/level.c
Normal file
39
cde/programs/dthelp/parser/pass2/parser/level.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $XConsortium: level.c /main/3 1995/11/08 10:53:50 rswiston $ */
|
||||
/*
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Procedure callable by interface designer. Returns number of occurrences
|
||||
of element on parse stack */
|
||||
int m_level(elt)
|
||||
M_WCHAR *elt ;
|
||||
{
|
||||
int i = 0 ;
|
||||
M_PARSE *stackptr ;
|
||||
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop ;
|
||||
stackptr = stackptr->oldtop) {
|
||||
if (! m_wcupstrcmp(elt, m_nameofelt(stackptr->element))) i++ ;
|
||||
}
|
||||
return(i) ;
|
||||
}
|
||||
|
||||
|
||||
int m_mblevel(elt)
|
||||
char *elt ;
|
||||
{
|
||||
int retval;
|
||||
M_WCHAR *wc_elt;
|
||||
|
||||
wc_elt = MakeWideCharString(elt);
|
||||
retval = m_level(wc_elt);
|
||||
m_free(wc_elt,"wide character string");
|
||||
return(retval);
|
||||
}
|
||||
34
cde/programs/dthelp/parser/pass2/parser/lookent.c
Normal file
34
cde/programs/dthelp/parser/pass2/parser/lookent.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* $XConsortium: lookent.c /main/3 1995/11/08 10:54:08 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Lookent.c contains procedure m_lookent(), callable by interface
|
||||
designers, to return entity type and content. Useful for entity
|
||||
parameters */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
|
||||
LOGICAL m_lookent(name, type, content, wheredef)
|
||||
M_WCHAR *name ;
|
||||
unsigned char *type ;
|
||||
M_WCHAR **content ;
|
||||
unsigned char *wheredef ;
|
||||
{
|
||||
M_ENTITY *entity ;
|
||||
|
||||
if (entity = (M_ENTITY *) m_lookfortrie(name, m_enttrie)) {
|
||||
*type = entity->type ;
|
||||
*content = entity->content ;
|
||||
*wheredef = entity->wheredef ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
else return(FALSE) ;
|
||||
}
|
||||
404
cde/programs/dthelp/parser/pass2/parser/minim.c
Normal file
404
cde/programs/dthelp/parser/pass2/parser/minim.c
Normal file
@@ -0,0 +1,404 @@
|
||||
/* $XConsortium: minim.c /main/3 1995/11/08 10:54:22 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Minim.c contains procedures relevant to tag minimization */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
|
||||
/* M_expecting reports to the user the possible valid content at a particular
|
||||
state in the parse of the document */
|
||||
void m_expecting(M_NOPAR)
|
||||
{
|
||||
LOGICAL expstart = TRUE ;
|
||||
M_PARSE *stackptr ;
|
||||
M_OPENFSA *fsastack ;
|
||||
M_ANDLIST *usedand ;
|
||||
M_ANDGROUP pand ;
|
||||
LOGICAL required = FALSE ;
|
||||
LOGICAL data = FALSE ;
|
||||
|
||||
m_expcount = 0 ;
|
||||
if (m_stacktop->intext) m_expline(&expstart, &data, M_NULLVAL) ;
|
||||
for (stackptr = m_stacktop ; stackptr ; stackptr = stackptr->oldtop) {
|
||||
if (m_explimit && m_expcount > M_EXPLIMIT) return ;
|
||||
if (m_start && ! stackptr->oldtop) return ;
|
||||
/* First check for possible start-tags.
|
||||
Begin by testing if at start of document or not within a
|
||||
CDATA or RCDATA element. */
|
||||
if (! stackptr->oldtop ||
|
||||
m_element[stackptr->element - 1].content == M_REGEXP) {
|
||||
/* Note the following statement, which checks the type of the
|
||||
element at the top of the stack, is not a repeat of the previous
|
||||
one, which checks the type of an element embedded in the stack.
|
||||
The second comparison prevents traversing paths from
|
||||
a parent of an RCDATA or CDATA element and still allows displaying
|
||||
the end-tag of the parent */
|
||||
if (! stackptr->oldtop ||
|
||||
m_element[m_stacktop->element - 1].content == M_REGEXP)
|
||||
for (fsastack = stackptr->fsastack ;
|
||||
fsastack ;
|
||||
fsastack = fsastack->oldtop) {
|
||||
for (pand = fsastack->andgroup ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
for (usedand = fsastack->usedand ;
|
||||
usedand ;
|
||||
usedand = usedand->next)
|
||||
if (usedand->group == pand) break ;
|
||||
if (! usedand)
|
||||
m_expexpand(&expstart, m_andgroup[pand - 1].start, &required,
|
||||
&data) ;
|
||||
}
|
||||
if (required) return ;
|
||||
m_expexpand(&expstart, fsastack->current, &required, &data) ;
|
||||
if (! m_state[fsastack->current - 1].final) return ;
|
||||
}
|
||||
}
|
||||
else if (m_element[stackptr->element - 1].content == M_CDATA ||
|
||||
m_element[stackptr->element - 1].content == M_RCDATA)
|
||||
m_expline(&expstart, &data, M_NULLVAL) ;
|
||||
if (m_explimit && m_expcount > M_EXPLIMIT) return ;
|
||||
/* Now report the end-tag */
|
||||
m_exptend(&expstart, stackptr) ;
|
||||
if (! m_element[stackptr->element - 1].emin) return ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Recursive procedure first called from expecting() to display
|
||||
names of elements reachable from a particular node */
|
||||
void m_expexpand(expstart, node, required, data)
|
||||
LOGICAL *expstart ;
|
||||
M_STATE node ;
|
||||
LOGICAL *required ;
|
||||
LOGICAL *data ;
|
||||
{
|
||||
M_ARC parc ;
|
||||
M_ANDGROUP pand ;
|
||||
|
||||
for (parc = m_state[node - 1].first ;
|
||||
parc ;
|
||||
parc = m_arc[parc - 1].next) {
|
||||
if (m_explimit && m_expcount > M_EXPLIMIT) return ;
|
||||
if (m_arc[parc - 1].group)
|
||||
for (pand = m_arc[parc - 1].group ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next)
|
||||
m_expexpand(expstart, m_andgroup[pand - 1].start, required, data) ;
|
||||
else {
|
||||
if (! m_state[node - 1].final) *required = TRUE ;
|
||||
m_expline(expstart, data, m_arc[parc - 1].label) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* M_expline writes one line for m_expecting() */
|
||||
void m_expline(expstart, data, label)
|
||||
LOGICAL *expstart ;
|
||||
LOGICAL *data ;
|
||||
M_ELEMENT label ;
|
||||
{
|
||||
char buffer[M_NAMELEN + 2*MAXD + 1] ;
|
||||
|
||||
if (! label && *data) return ;
|
||||
if (m_excluded(label)) return ;
|
||||
if (*expstart) {
|
||||
sprintf(buffer, "Expecting ") ;
|
||||
m_errline(buffer) ;
|
||||
*expstart = FALSE ;
|
||||
}
|
||||
else {
|
||||
sprintf(buffer, " or ") ;
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
if (m_explimit && m_expcount == M_EXPLIMIT) {
|
||||
sprintf(buffer, ". . .\n") ;
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
else if (label) {
|
||||
char *mb_enptr;
|
||||
|
||||
mb_enptr = MakeMByteString(&m_ename[m_element[label - 1].enptr]);
|
||||
sprintf(buffer, "%s%s%s\n", m_stago, mb_enptr, m_tagc) ;
|
||||
m_free(mb_enptr,"multi-byte string");
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
else {
|
||||
sprintf(buffer, "data characters\n") ;
|
||||
m_errline(buffer) ;
|
||||
*data = TRUE ;
|
||||
}
|
||||
m_expcount++ ;
|
||||
}
|
||||
|
||||
/* M_exptend is called from m_expecting to inform the user after an
|
||||
error if an end tag is permitted */
|
||||
void m_exptend(expstart, stackptr)
|
||||
LOGICAL *expstart ;
|
||||
M_PARSE *stackptr ;
|
||||
{
|
||||
char buffer[M_NAMELEN + 2*MAXD + 1] ;
|
||||
|
||||
if (*expstart) {
|
||||
sprintf(buffer, "Expecting ") ;
|
||||
m_errline(buffer) ;
|
||||
*expstart = FALSE ;
|
||||
}
|
||||
else {
|
||||
sprintf(buffer, " or ") ;
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
if (m_explimit && m_expcount == M_EXPLIMIT) {
|
||||
sprintf(buffer, ". . .\n") ;
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
else if (stackptr->neednet) {
|
||||
sprintf(buffer, "%s\n", m_net) ;
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
else {
|
||||
char *mb_enptr;
|
||||
|
||||
mb_enptr =
|
||||
MakeMByteString(&m_ename[m_element[stackptr->element - 1].enptr]);
|
||||
sprintf(buffer, "%s%s%s\n", m_etago, mb_enptr, m_tagc) ;
|
||||
m_free(mb_enptr,"multi-byte string");
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
m_expcount++ ;
|
||||
}
|
||||
|
||||
/* M_findunique is used to test for start tag minimization. If the current
|
||||
parse state permits at least one element with explicit start-tag
|
||||
minimization, the left-most such element to occur in the content model
|
||||
is returned. Otherwise, the contextually-required element, if any,
|
||||
is returned. Finally, if the parse state permits a unique valid element,
|
||||
and the flag for conformance to ISO 8879 is not set, the unique valid
|
||||
element is returned by m_findunique.
|
||||
|
||||
Before returning, m_findunique verifies that the element to be returned
|
||||
permits start-tag minimization. If not, the value is returned only if
|
||||
conformance to ISO 8879 is set.
|
||||
|
||||
Actually m_findunique returns 1 greater than the index of the unique
|
||||
element, 1 if character data is expected, and 0 (FALSE) if there is
|
||||
no unique element.
|
||||
*/
|
||||
M_ELEMENT m_findunique(from, newleft)
|
||||
M_STATE from ;
|
||||
int *newleft ;
|
||||
{
|
||||
M_ARC parc ;
|
||||
M_ELEMENT cr = 0, minim = 0;
|
||||
int leftmost = M_BIGINT ;
|
||||
int testleft = M_BIGINT ;
|
||||
int testminim ;
|
||||
M_ANDGROUP pand ;
|
||||
|
||||
for (parc = m_state[from - 1].first ;
|
||||
parc ;
|
||||
parc = m_arc[parc - 1].next) {
|
||||
if (m_arc[parc - 1].group) {
|
||||
if (! m_conform)
|
||||
for (pand = m_arc[parc - 1].group ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
testminim = m_findunique(m_andgroup[pand - 1].start, &testleft) ;
|
||||
if (testminim && testleft < leftmost) {
|
||||
minim = testminim ;
|
||||
leftmost = testleft ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (! m_conform) {
|
||||
if (m_arc[parc - 1].minim &&
|
||||
m_arc[parc - 1].minim < leftmost &&
|
||||
! m_excluded(m_arc[parc - 1].label)) {
|
||||
/* Save the explicitly minimizable element plus its position
|
||||
in the content model */
|
||||
leftmost = m_arc[parc - 1].minim ;
|
||||
minim = m_arc[parc - 1].label + 1 ;
|
||||
} /* End arc.minim > leftmost */
|
||||
else if (m_arc[parc - 1].optional &&
|
||||
parc == m_state[from - 1].first &&
|
||||
! m_arc[parc - 1].next &&
|
||||
m_element[m_arc[parc - 1].label -1].smin &&
|
||||
! m_excluded(m_arc[parc - 1].label))
|
||||
/* Save the only element that can occur */
|
||||
cr = m_arc[parc - 1].label ;
|
||||
} /* End if (! m_conform) */
|
||||
/* Save the contextually-required element */
|
||||
if (! m_arc[parc - 1].optional && ! m_excluded(m_arc[parc - 1].label))
|
||||
cr = m_arc[parc - 1].label ;
|
||||
} /* End if (! group) */
|
||||
} /* End for parc */
|
||||
*newleft = leftmost ;
|
||||
if (minim) return(minim) ;
|
||||
if (cr) return(cr + 1) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* M_nullendtag is called when a null end tag is encountered; i.e., at the
|
||||
end of a short element */
|
||||
void m_nullendtag(M_NOPAR)
|
||||
{
|
||||
LOGICAL foundnet ;
|
||||
|
||||
while (m_stacktop->oldtop) {
|
||||
foundnet = m_stacktop->neednet ;
|
||||
if (! foundnet && ! m_element[m_stacktop->element - 1].emin) {
|
||||
m_err1("Missing end tag for %s",
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_showcurelt() ;
|
||||
}
|
||||
if (! m_ckend(m_stacktop->element, foundnet)) {
|
||||
M_WCHAR *wc_found;
|
||||
|
||||
wc_found = MakeWideCharString(foundnet ? "Null" : "Implied");
|
||||
m_err2("%s end tag for %s unexpected",
|
||||
wc_found,
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_free(wc_found,"wide character string");
|
||||
m_expecting() ;
|
||||
m_showcurelt() ;
|
||||
m_frcend(m_stacktop->element) ;
|
||||
}
|
||||
if (foundnet) return ;
|
||||
}
|
||||
m_error("Internal error: Invalid stack in Nullendtag") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
|
||||
/* Tests to see if an end tag may have been omitted at this point in the
|
||||
parse.*/
|
||||
LOGICAL m_omitend(M_NOPAR)
|
||||
{
|
||||
M_ANDGROUP pand ;
|
||||
M_OPENFSA *fsastack ;
|
||||
M_ANDLIST *usedand ;
|
||||
|
||||
if (! m_stacktop->oldtop) return(FALSE) ;
|
||||
if (m_element[m_stacktop->element - 1].content != M_REGEXP) return(TRUE) ;
|
||||
for (fsastack = m_stacktop->fsastack ;
|
||||
fsastack ;
|
||||
fsastack = fsastack->oldtop) {
|
||||
for (pand = fsastack->andgroup ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
/* Doesn't matter if optional submodel of and-group has occurred */
|
||||
if (m_state[m_andgroup[pand - 1].start - 1].final) continue ;
|
||||
for (usedand = fsastack->usedand ;
|
||||
usedand ;
|
||||
usedand = usedand->next)
|
||||
if (usedand->group == pand) break ;
|
||||
/* Required submodel of and-group has not occurred */
|
||||
if (! usedand) return(FALSE) ;
|
||||
}
|
||||
/* Current FSA not in final state */
|
||||
if (! m_state[fsastack->current - 1].final) return(FALSE) ;
|
||||
}
|
||||
*m_nextme = (M_MIN *) m_malloc(sizeof(M_MIN), "end-tag minimization") ;
|
||||
(*m_nextme)->val = m_stacktop->element ;
|
||||
(*m_nextme)->next = NULL ;
|
||||
m_nextme = &(*m_nextme)->next ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
|
||||
/* Tests to see if a start tag may have been omitted at this point of
|
||||
the parse. If so, saves the element name in the MINVAL array*/
|
||||
LOGICAL m_omitstart()
|
||||
{
|
||||
M_ELEMENT c = M_NULLVAL ;
|
||||
|
||||
/* int par ; (used in commented-out code below) */
|
||||
M_OPENFSA *fsastack ;
|
||||
M_ANDLIST *usedand ;
|
||||
M_ANDGROUP pand ;
|
||||
int leftmost = M_BIGINT ;
|
||||
int newleft = M_BIGINT ;
|
||||
M_ELEMENT newc = M_NULLVAL ;
|
||||
LOGICAL required = FALSE ;
|
||||
M_MIN *min ;
|
||||
|
||||
/* Make sure are in an element that has a content model */
|
||||
if (m_stacktop->oldtop &&
|
||||
m_element[m_stacktop->element - 1].content != M_REGEXP)
|
||||
return(FALSE) ;
|
||||
|
||||
/* Test for unique element expected, or only allowed token is #PCDATA */
|
||||
for (fsastack = m_stacktop->fsastack ;
|
||||
fsastack ;
|
||||
fsastack = fsastack->oldtop) {
|
||||
for (pand = fsastack->andgroup ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
for (usedand = fsastack->usedand ;
|
||||
usedand ;
|
||||
usedand = usedand->next)
|
||||
if (usedand->group == pand) break ;
|
||||
if (! usedand) {
|
||||
if (! m_state[m_andgroup[pand - 1].start - 1].final)
|
||||
required = TRUE ;
|
||||
newc = m_findunique(m_andgroup[pand - 1].start, &newleft) ;
|
||||
if (newleft < leftmost) {
|
||||
leftmost = newleft ;
|
||||
c = newc ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! required) {
|
||||
newc = m_findunique(fsastack->current, &newleft) ;
|
||||
if (newleft < leftmost) {
|
||||
leftmost = newleft ;
|
||||
c = newc ;
|
||||
}
|
||||
}
|
||||
if (c > 1) break ;
|
||||
if (fsastack == m_stacktop->fsastack && newc) {
|
||||
c = newc ;
|
||||
break ;
|
||||
}
|
||||
if (m_conform) return(FALSE) ;
|
||||
if (! m_state[fsastack->current - 1].final) return(FALSE) ;
|
||||
}
|
||||
if (! c) return(FALSE) ;
|
||||
|
||||
/* Have found a unique element. Can its start-tag be omitted? */
|
||||
c-- ;
|
||||
if (m_element[c - 1].content == M_NONE) return(FALSE) ;
|
||||
if (m_element[c - 1].content == M_CDATA) return(FALSE) ;
|
||||
if (m_element[c - 1].content == M_RCDATA) return(FALSE) ;
|
||||
|
||||
/* Following code allows start-tag to be omitted only if all required
|
||||
parameters are specified:
|
||||
for (par = m_element[c - 1].parptr ; par ;
|
||||
par = m_parameter[par - 1].next)
|
||||
if (m_parameter[par - 1].deftype == M_REQUIRED) return(FALSE) ;
|
||||
*/
|
||||
|
||||
/* Check for recursive sequences of omitted tags */
|
||||
for (min = m_minstart ; min ; min = min->next)
|
||||
if (c == min->val) return(FALSE) ;
|
||||
|
||||
m_push(c, m_element[c - 1].start, FALSE) ;
|
||||
*m_nextms = (M_MIN *) m_malloc(sizeof(M_MIN), "start-tag minimization") ;
|
||||
(*m_nextms)->val = m_stacktop->element ;
|
||||
(*m_nextms)->next = NULL ;
|
||||
m_nextms = &(*m_nextms)->next ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
|
||||
14
cde/programs/dthelp/parser/pass2/parser/openent.c
Normal file
14
cde/programs/dthelp/parser/pass2/parser/openent.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $XConsortium: openent.c /main/3 1995/11/08 10:54:37 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Default open SYSTEM entity procedure */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
void *m_openent(entcontent)
|
||||
M_WCHAR *entcontent ;
|
||||
{
|
||||
return((void *) fopen(entcontent, "r")) ;
|
||||
}
|
||||
|
||||
14
cde/programs/dthelp/parser/pass2/parser/openfrst.c
Normal file
14
cde/programs/dthelp/parser/pass2/parser/openfrst.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $XConsortium: openfrst.c /main/3 1995/11/08 10:54:51 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Default open SYSTEM entity procedure */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
void *m_openfirst(M_NOPAR)
|
||||
{
|
||||
return((void *) stdin) ;
|
||||
}
|
||||
|
||||
|
||||
38
cde/programs/dthelp/parser/pass2/parser/optstrg.c
Normal file
38
cde/programs/dthelp/parser/pass2/parser/optstrg.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* $XConsortium: optstrg.c /main/3 1995/11/08 10:55:04 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Get program options from a string */
|
||||
void m_optstring(p)
|
||||
char *p ;
|
||||
{
|
||||
if (strchr(p, 'a')) m_malftrace = TRUE ;
|
||||
if (strchr(p, 'c')) m_chtrace = TRUE ;
|
||||
if (strchr(p, 'd')) m_cdtrace = TRUE ;
|
||||
if (strchr(p, 'e')) m_entdupchk = FALSE ;
|
||||
if (strchr(p, 'h')) m_heapchk = TRUE ;
|
||||
if (strchr(p, 'l')) m_explimit = FALSE ;
|
||||
if (strchr(p, 'm')) m_conform = TRUE ;
|
||||
if (strchr(p, 's')) m_scantrace = TRUE ;
|
||||
if (strchr(p, 't')) m_tagtrace = TRUE ;
|
||||
if (strchr(p, 'w')) m_wholetag = TRUE ;
|
||||
|
||||
if (strchr(p, 'A')) m_malftrace = TRUE ;
|
||||
if (strchr(p, 'C')) m_chtrace = TRUE ;
|
||||
if (strchr(p, 'D')) m_cdtrace = TRUE ;
|
||||
if (strchr(p, 'E')) m_entdupchk = FALSE ;
|
||||
if (strchr(p, 'H')) m_heapchk = TRUE ;
|
||||
if (strchr(p, 'L')) m_explimit = FALSE ;
|
||||
if (strchr(p, 'M')) m_conform = TRUE ;
|
||||
if (strchr(p, 'S')) m_scantrace = TRUE ;
|
||||
if (strchr(p, 'T')) m_tagtrace = TRUE ;
|
||||
if (strchr(p, 'W')) m_wholetag = TRUE ;
|
||||
}
|
||||
338
cde/programs/dthelp/parser/pass2/parser/param.c
Normal file
338
cde/programs/dthelp/parser/pass2/parser/param.c
Normal file
@@ -0,0 +1,338 @@
|
||||
/* $XConsortium: param.c /main/3 1995/11/08 10:55:19 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Param.c has procedures relevant to parameters (attributes). */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
|
||||
/* Process the value for the parameter whose index number was previously
|
||||
saved in m_ppsave */
|
||||
void m_attval(string)
|
||||
M_WCHAR *string ;
|
||||
{
|
||||
const M_WCHAR *p ;
|
||||
|
||||
if (p = m_partype(m_ppsave, string)) {
|
||||
if (m_parameter[m_ppsave - 1].type == M_KEYWORD)
|
||||
m_poccur[m_psave] = (M_WCHAR *) p ;
|
||||
else {
|
||||
m_poccur[m_psave] = (M_WCHAR *)
|
||||
m_malloc(w_strlen(p) + 1, "parameter value") ;
|
||||
w_strcpy(m_poccur[m_psave], p) ;
|
||||
m_parupper(m_ppsave, m_poccur[m_psave]) ;
|
||||
}
|
||||
m_updatedefault(m_ppsave, p) ;
|
||||
}
|
||||
else m_err2("\"%s\" -- error in value for parameter %s",
|
||||
string,
|
||||
&m_pname[m_parameter[m_ppsave - 1].paramname]) ;
|
||||
}
|
||||
|
||||
/* Process a string that is a parameter value not prefixed by the parameter
|
||||
name and value indicator */
|
||||
LOGICAL m_attvonly(string)
|
||||
M_WCHAR *string ;
|
||||
{
|
||||
const M_WCHAR *p ;
|
||||
int par, i ;
|
||||
|
||||
if (! m_scanel) {
|
||||
m_error("Program error in m_attvonly") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
/* First check is it a valid keyword? */
|
||||
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
|
||||
i < m_element[m_scanel - 1].parcount ;
|
||||
par++, i++)
|
||||
if (m_parameter[par - 1].type == M_KEYWORD)
|
||||
if (p = m_partype(par, string)) {
|
||||
if (m_poccur[i])
|
||||
m_err2(
|
||||
"Redefinition of parameter %s. Discarding old value '%s'.",
|
||||
&m_pname[m_parameter[par - 1].paramname],
|
||||
m_poccur[i]) ;
|
||||
m_poccur[i] = (M_WCHAR *) p ;
|
||||
m_updatedefault(par, p) ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
/* It wasn't a keyword. Check for valid value for some other
|
||||
parameter whose value has not yet been specified. */
|
||||
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
|
||||
i < m_element[m_scanel - 1].parcount ;
|
||||
par++, i++)
|
||||
if (! m_poccur[i]) {
|
||||
m_poccur[i] = (M_WCHAR *) m_partype(par, string) ;
|
||||
if (m_poccur[i]) {
|
||||
m_parupper(par, string) ;
|
||||
m_poccur[i] = (M_WCHAR *)
|
||||
m_malloc(w_strlen(string) + 1, "parameter value") ;
|
||||
w_strcpy(m_poccur[i], string) ;
|
||||
m_updatedefault(par, m_poccur[i]) ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
}
|
||||
m_err2("%s: impossible value for any parameters of %s",
|
||||
string,
|
||||
m_nameofelt(m_scanel)) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Check a name previously saved in m_saveatt to see if it is the name of
|
||||
a valid parameter for the current start tag */
|
||||
void m_findatt(M_NOPAR)
|
||||
{
|
||||
int par, i ;
|
||||
|
||||
if (! m_scanel) {
|
||||
m_error("Program error in m_findatt") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
|
||||
i < m_element[m_scanel - 1].parcount ;
|
||||
par++, i++)
|
||||
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname],
|
||||
m_saveatt)) {
|
||||
if (m_poccur[i])
|
||||
m_err2("Redefinition of parameter %s. Discarding old value '%s'.",
|
||||
&m_pname[m_parameter[par - 1].paramname],
|
||||
m_poccur[i]) ;
|
||||
m_psave = i ;
|
||||
m_ppsave = par ;
|
||||
return ;
|
||||
}
|
||||
m_attvonly(m_saveatt) ;
|
||||
if (! m_wholetag) {
|
||||
M_WCHAR *wc_tagc;
|
||||
|
||||
wc_tagc = MakeWideCharString(m_tagc);
|
||||
m_err3("No %s parameter for %s (possibly missing %s)",
|
||||
m_saveatt,
|
||||
m_nameofelt(m_scanel),
|
||||
wc_tagc) ;
|
||||
m_free(wc_tagc,"multi-byte string");
|
||||
}
|
||||
m_undodelim(m_dlmptr[M_VI - 1], TRUE) ;
|
||||
m_stcomplete() ;
|
||||
m_curcon = START ;
|
||||
}
|
||||
|
||||
/* Free the parameter storage associated with an element on the parse stack */
|
||||
void m_freeparam(stackelt)
|
||||
M_PARSE *stackelt ;
|
||||
{
|
||||
int i ;
|
||||
int par ;
|
||||
|
||||
if (stackelt->param) {
|
||||
for (i = 0, par = m_element[stackelt->element - 1].parptr - 1 ;
|
||||
i < m_element[stackelt->element - 1].parcount ; i++, par++)
|
||||
if (m_parameter[par].type != M_KEYWORD)
|
||||
if (m_parameter[par].deftype != M_NAMEDEF ||
|
||||
stackelt->param[i] != m_parameter[par].defval)
|
||||
if (stackelt->param[i])
|
||||
m_free(stackelt->param[i], "parameter value") ;
|
||||
m_free(stackelt->param, "parameter block") ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Force a parameter value to uppercase, if appropriate for its type.
|
||||
Also, if list-valued attribute, remove leading and trailing spaces,
|
||||
and condense white-space sequences to a single blank*/
|
||||
void m_parupper(par, string)
|
||||
int par ;
|
||||
M_WCHAR *string ;
|
||||
{
|
||||
M_WCHAR *p ;
|
||||
M_WCHAR *q ;
|
||||
int i ;
|
||||
|
||||
switch (m_parameter[par - 1].type) {
|
||||
case M_ID:
|
||||
case M_IDRF:
|
||||
case M_NAMEPAR:
|
||||
case M_NMTOKEN:
|
||||
case M_NUTOKEN:
|
||||
case M_ENTATT:
|
||||
for ( ; *string ; string++)
|
||||
*string = m_ctupper(*string) ;
|
||||
return ;
|
||||
case M_IDRFS:
|
||||
case M_NAMES:
|
||||
case M_NMSTOKEN:
|
||||
case M_NUSTOKEN:
|
||||
case M_NUMS:
|
||||
for (p = string; *p ; p++)
|
||||
if (! m_whitespace(*p)) break ;
|
||||
w_strcpy(string, p) ;
|
||||
for (p = string, i = 0 ; *p ; p++, i++)
|
||||
*p = m_ctupper(*p) ;
|
||||
if (m_whitespace(*p)) {
|
||||
*p = M_SPACE ;
|
||||
for (q = p + 1 ; m_whitespace(*q); q++) ;
|
||||
w_strcpy(p + 1, q) ;
|
||||
}
|
||||
if (i && m_whitespace(string[i - 1])) string[i - 1] = M_EOS ;
|
||||
return ;
|
||||
default:
|
||||
for ( ; *string ; string++)
|
||||
if (*string == M_RE || *string == M_TAB) *string = M_SPACE ;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set all parameters to their default values for an element included by
|
||||
tag minimization */
|
||||
void m_stkdefaultparams(M_NOPAR)
|
||||
{
|
||||
int i, par = 0 ;
|
||||
|
||||
m_stacktop->param = (M_WCHAR **)
|
||||
m_malloc(
|
||||
m_element[m_stacktop->element - 1].parcount * sizeof(M_WCHAR *),
|
||||
"parameter block") ;
|
||||
for (i = 0, par = m_element[m_stacktop->element - 1].parptr ;
|
||||
i < m_element[m_stacktop->element - 1].parcount ;
|
||||
i++, par++)
|
||||
m_stkonedef(par, m_stacktop->element, m_stacktop->param, i) ;
|
||||
m_strtaction(m_stacktop->element) ;
|
||||
}
|
||||
|
||||
/* Stack one default parameter */
|
||||
void m_stkonedef(par, scanel, poccur, i)
|
||||
int par ;
|
||||
M_ELEMENT scanel ;
|
||||
M_WCHAR **poccur ;
|
||||
int i ;
|
||||
{
|
||||
if (m_parameter[par - 1].deftype == M_REQUIRED ||
|
||||
(m_parameter[par - 1].deftype == M_CURRENT &&
|
||||
! m_parameter[par - 1].defval))
|
||||
m_err2("Missing value for %s parameter of element %s",
|
||||
&m_pname[m_parameter[par - 1].paramname],
|
||||
m_nameofelt(scanel)) ;
|
||||
poccur[i] = m_parameter[par - 1].defval ;
|
||||
if (! m_parameter[par - 1].defval) return ;
|
||||
if (m_parameter[par - 1].type == M_KEYWORD) return ;
|
||||
|
||||
/* If parameter is an entity name, the default is usable only if
|
||||
the name is that of a defined entity */
|
||||
if (m_parameter[par - 1].type == M_ENTATT)
|
||||
if (! (M_ENTITY *)
|
||||
m_lookfortrie(m_parameter[par - 1].defval, m_enttrie)) {
|
||||
m_err1("Interface error: Default entity %s undefined", poccur[i]) ;
|
||||
poccur[i] = NULL ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Non-null, non-keyword current default must go on stack, since
|
||||
default could change in a subelement */
|
||||
if (m_parameter[par - 1].deftype != M_CURRENT &&
|
||||
m_parameter[par - 1].deftype != M_CHANGEDCUR) return ;
|
||||
poccur[i] = (M_WCHAR *)
|
||||
m_malloc(w_strlen(poccur[i]) + 1, "parameter value") ;
|
||||
w_strcpy(poccur[i], m_parameter[par - 1].defval) ;
|
||||
}
|
||||
|
||||
/* Stack parameter values */
|
||||
void m_stkparams(M_NOPAR)
|
||||
{
|
||||
int i, par ;
|
||||
|
||||
m_stacktop->param = (M_WCHAR **)
|
||||
m_malloc(
|
||||
m_element[m_stacktop->element - 1].parcount * sizeof(M_WCHAR *),
|
||||
"parameter block") ;
|
||||
for (i = 0, par = m_element[m_scanel - 1].parptr ;
|
||||
i < m_element[m_scanel - 1].parcount ;
|
||||
i++, par++) {
|
||||
if (! m_poccur[i]) m_stkonedef(par, m_scanel, m_stacktop->param, i) ;
|
||||
else m_stacktop->param[i] = m_poccur[i] ;
|
||||
}
|
||||
m_strtaction(m_stacktop->element) ;
|
||||
}
|
||||
|
||||
/* Update the default of a parameter whose default is #CURRENT */
|
||||
#if defined(M_PROTO)
|
||||
void m_updatedefault(const int par , const M_WCHAR *string )
|
||||
#else
|
||||
void m_updatedefault(par, string)
|
||||
int par ;
|
||||
M_WCHAR *string ;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
if (m_parameter[par - 1].deftype != M_CURRENT &&
|
||||
m_parameter[par - 1].deftype != M_CHANGEDCUR) return ;
|
||||
|
||||
/* For keyword parameters, the string is already saved in the
|
||||
keyword array; for entities, it is saved with the entity structure */
|
||||
/* In light of the above comment, why does the following if statement
|
||||
not test for parameters of type entity? */
|
||||
if (m_parameter[par - 1].type == M_KEYWORD)
|
||||
m_parameter[par - 1].defval = (M_WCHAR *) string ;
|
||||
|
||||
/* Save value in allocated storage */
|
||||
else {
|
||||
if (m_parameter[par - 1].deftype == M_CHANGEDCUR)
|
||||
m_free(m_parameter[par - 1].defval, "updateable default") ;
|
||||
m_parameter[par - 1].defval = (M_WCHAR *)
|
||||
m_malloc(w_strlen(string) + 1, "updateable default") ;
|
||||
w_strcpy(m_parameter[par - 1].defval, string) ;
|
||||
}
|
||||
|
||||
m_parameter[par - 1].deftype = M_CHANGEDCUR ;
|
||||
}
|
||||
|
||||
/* Check to see if a string that occurs after the element name in a start
|
||||
tag is a valid parameter name or value; if not, assume tag is ended */
|
||||
LOGICAL m_validinpar(string)
|
||||
M_WCHAR *string ;
|
||||
{
|
||||
int par ;
|
||||
M_WCHAR *p ;
|
||||
int i ;
|
||||
M_WCHAR *wc_tagc;
|
||||
|
||||
if (! m_scanel) {
|
||||
m_error("Program error in m_validinpar") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
|
||||
i < m_element[m_scanel - 1].parcount ;
|
||||
par++, i++) {
|
||||
/* Check if valid name of a parameter */
|
||||
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], string))
|
||||
return(TRUE) ;
|
||||
/* Check if possible value of a keyword parameter or of a non-keyword
|
||||
parameter that has not yet occurred*/
|
||||
if (m_partype(par, string) &&
|
||||
(m_parameter[par - 1].type == M_KEYWORD || ! m_poccur[i]))
|
||||
return(TRUE) ;
|
||||
}
|
||||
wc_tagc = MakeWideCharString(m_tagc);
|
||||
if (! m_wholetag) m_err1("Invalid parameter or missing %s", wc_tagc) ;
|
||||
m_free(wc_tagc,"wide character string");
|
||||
m_stcomplete() ;
|
||||
m_curcon = POUNDCDATA ;
|
||||
for (p = string ; *p ; p++) ;
|
||||
for (p-- ; p >= string ; p--) m_ungetachar((int) *p, M_NORMAL, TRUE) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
#include "paramu.c"
|
||||
|
||||
22
cde/programs/dthelp/parser/pass2/parser/parcount.c
Normal file
22
cde/programs/dthelp/parser/pass2/parser/parcount.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/* $XConsortium: parcount.c /main/3 1995/11/08 10:55:34 rswiston $ */
|
||||
/*
|
||||
Copyright 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Function callable by interface designers. Returns number of parameters
|
||||
of specified element (-1 indicates error). */
|
||||
int m_parcount(elt)
|
||||
M_WCHAR *elt ;
|
||||
{
|
||||
M_ELEMENT eltid ;
|
||||
|
||||
if (! (eltid = m_packedlook(m_entree, elt))) return(-1) ;
|
||||
return(m_element[eltid - 1].parcount) ;
|
||||
}
|
||||
|
||||
39
cde/programs/dthelp/parser/pass2/parser/pardef.c
Normal file
39
cde/programs/dthelp/parser/pass2/parser/pardef.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $XConsortium: pardef.c /main/3 1995/11/08 10:55:48 rswiston $ */
|
||||
/*
|
||||
Copyright 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Function callable by interface designers. Returns pointer to default
|
||||
value of a parameter of an element. Type is set to indicate type of
|
||||
default. Error indication is type is 0 and function returns NULL. */
|
||||
M_WCHAR *m_pardefault(elt, param, type)
|
||||
M_WCHAR *elt ;
|
||||
M_WCHAR *param ;
|
||||
unsigned char *type ;
|
||||
{
|
||||
M_ELEMENT eltid ;
|
||||
int par ;
|
||||
int i ;
|
||||
|
||||
*type = M_NULLVAL ;
|
||||
if (! (eltid = m_packedlook(m_entree, elt))) return(NULL) ;
|
||||
|
||||
for (par = m_element[eltid - 1].parptr, i = 0 ;
|
||||
i < m_element[eltid - 1].parcount ;
|
||||
par++, i++)
|
||||
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], param)) {
|
||||
*type = (unsigned char) m_parameter[par - 1].deftype ;
|
||||
if (*type == M_REQUIRED || *type == M_NULLDEF) return(NULL) ;
|
||||
return(m_parameter[par -1].defval) ;
|
||||
}
|
||||
|
||||
/* Can't find the parameter */
|
||||
return(NULL) ;
|
||||
}
|
||||
|
||||
27
cde/programs/dthelp/parser/pass2/parser/parent.c
Normal file
27
cde/programs/dthelp/parser/pass2/parser/parent.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* $XConsortium: parent.c /main/3 1995/11/08 10:56:02 rswiston $ */
|
||||
/*
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Procedure callable by interface designers. Returns pointer to name
|
||||
of nth level parent of current element (0 is self, 1 is parent, 2
|
||||
is grandparent, etc.) */
|
||||
M_WCHAR *m_parent(n)
|
||||
int n ;
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop && n >= 0 ;
|
||||
stackptr = stackptr->oldtop, n--) {
|
||||
if (! n)
|
||||
return(m_nameofelt(stackptr->element)) ;
|
||||
}
|
||||
return(NULL) ;
|
||||
}
|
||||
36
cde/programs/dthelp/parser/pass2/parser/parname.c
Normal file
36
cde/programs/dthelp/parser/pass2/parser/parname.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* $XConsortium: parname.c /main/3 1995/11/08 10:56:15 rswiston $ */
|
||||
/*
|
||||
Copyright 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Function callable by interface designers. Returns name of nth parameter
|
||||
of specified element (NULL indicates error). */
|
||||
M_WCHAR *m_parname(elt, n)
|
||||
M_WCHAR *elt ;
|
||||
int n ;
|
||||
{
|
||||
M_ELEMENT eltid ;
|
||||
|
||||
if (! (eltid = m_packedlook(m_entree, elt))) return(NULL) ;
|
||||
if (n < 1 || n > m_element[eltid - 1].parcount) return(NULL) ;
|
||||
return(&m_pname[m_parameter[(n - 1) + m_element[eltid - 1].parptr - 1].
|
||||
paramname]) ;
|
||||
}
|
||||
|
||||
M_WCHAR *m_mbparname(elt, n)
|
||||
char *elt ;
|
||||
int n ;
|
||||
{
|
||||
M_WCHAR *wc_elt, *retval;
|
||||
|
||||
wc_elt = MakeWideCharString(elt);
|
||||
retval = m_parname(wc_elt, n);
|
||||
m_free(wc_elt,"wide character string");
|
||||
}
|
||||
|
||||
90
cde/programs/dthelp/parser/pass2/parser/parser.c
Normal file
90
cde/programs/dthelp/parser/pass2/parser/parser.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/* $XConsortium: parser.c /main/3 1995/11/08 10:56:28 rswiston $ */
|
||||
/* Parser.c contains the main procedure for program PARSER */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "context.h"
|
||||
#include "delim.h"
|
||||
#include "parser.h"
|
||||
#include "if.h"
|
||||
#include "entext.h"
|
||||
|
||||
/* Main procedure */
|
||||
void main(argc, argv)
|
||||
int argc ;
|
||||
char **argv ;
|
||||
{
|
||||
static char parserr[] = "\nM_token=%d, m_prevcon=%d, m_scanval=%d\n" ;
|
||||
static char sopt[] =
|
||||
"prevcon=%d,token=%d,curcon=%d,scanval='%c'(%d),line=%d,netlevel=%d\n" ;
|
||||
static char name[] = "m_name = '%s'\n" ;
|
||||
static char literal[] = "m_literal = '%s'\n" ;
|
||||
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__) || defined(__osf__)
|
||||
char buffer[M_LITLEN + 80] ;
|
||||
#else
|
||||
#define max4(a,b,c,d) (a>b&&a>c&&a>d) ? a : ((b>c&&b>d) ? b : (c>d ? c : d))
|
||||
M_WCHAR buffer[max4(sizeof(parserr) + 3,
|
||||
sizeof(sopt) + 6,
|
||||
sizeof(name) + M_NAMELEN - 2,
|
||||
sizeof(literal) + M_LITLEN - 2)] ;
|
||||
#endif
|
||||
|
||||
m_argc = argc ;
|
||||
m_argv = argv ;
|
||||
|
||||
m_strtcase(1) ;
|
||||
m_globss() ;
|
||||
m_setoptions() ;
|
||||
m_initialize() ;
|
||||
while (TRUE) {
|
||||
m_token = m_scan() ;
|
||||
m_prevcon = m_curcon ;
|
||||
m_curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
|
||||
if (! m_curcon) {
|
||||
if (m_token != M_ENDFILE) {
|
||||
m_error("Parsing table error") ;
|
||||
sprintf(buffer, parserr, m_token, m_prevcon, m_scanval) ;
|
||||
m_errline(buffer) ;
|
||||
}
|
||||
else {
|
||||
m_error("Unexpected end of document") ;
|
||||
m_showcurelt() ;
|
||||
}
|
||||
m_done() ;
|
||||
}
|
||||
if ((! m_stacktop->oldtop) &&
|
||||
m_start &&
|
||||
! m_aftereod &&
|
||||
m_state[m_stacktop->fsastack->current - 1].final &&
|
||||
(m_token != M_ENDFILE) &&
|
||||
(m_token != M_TEXT || ! m_whitespace((M_WCHAR) m_scanval))
|
||||
) {
|
||||
m_error("Expecting end of document") ;
|
||||
m_aftereod = TRUE ;
|
||||
}
|
||||
if (m_scantrace) {
|
||||
sprintf(buffer, sopt,
|
||||
m_prevcon, m_token, m_curcon, m_scanval ? m_scanval : ' ',
|
||||
m_scanval, m_line[m_sysecnt], m_netlevel) ;
|
||||
m_trace(buffer) ;
|
||||
if (m_token == M_NAME) {
|
||||
sprintf(buffer, name, m_name) ;
|
||||
m_trace(buffer) ;
|
||||
}
|
||||
if (m_token == M_LITERAL) {
|
||||
sprintf(buffer, literal, m_literal) ;
|
||||
m_trace(buffer) ;
|
||||
}
|
||||
}
|
||||
#include "case.c"
|
||||
m_adjuststate() ;
|
||||
if (m_token == M_ENDFILE) break ;
|
||||
}
|
||||
/* At EOF */
|
||||
m_done() ;
|
||||
}
|
||||
|
||||
435
cde/programs/dthelp/parser/pass2/parser/parser.h
Normal file
435
cde/programs/dthelp/parser/pass2/parser/parser.h
Normal file
@@ -0,0 +1,435 @@
|
||||
/* $XConsortium: parser.h /main/3 1995/11/08 10:56:42 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Parser.h allocates global variables for PARSER */
|
||||
|
||||
#if defined(M_PARDEF)
|
||||
#define M_PAREXTERN
|
||||
#define M_PARINIT(a) = a
|
||||
#else
|
||||
#define M_PAREXTERN extern
|
||||
#define M_PARINIT(a)
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* Stack of open entities and line number in each external file */
|
||||
#define M_ENTLVL 16 /* Maximum number of open entities */
|
||||
M_PAREXTERN M_ENTITY *m_opene[M_ENTLVL] ;
|
||||
M_PAREXTERN int m_eopencnt M_PARINIT(0) ;
|
||||
M_PAREXTERN void *m_sysent[M_ENTLVL + 1] ;
|
||||
#define M_FIRSTLINE 1
|
||||
M_PAREXTERN int m_line[M_ENTLVL + 1] M_PARINIT({M_FIRSTLINE}) ;
|
||||
M_PAREXTERN int m_sysecnt M_PARINIT(0) ;
|
||||
|
||||
/* Possible states of a line -- no SGML characters yet processed, SGML
|
||||
characters processed but no data character or contextual end tag,
|
||||
data character or contextual end tag (i.e., end tag of a proper
|
||||
subelement) has occurred. Note that linestat is stacked with each
|
||||
element. If an element contains a line that
|
||||
* is neither its first nor last line
|
||||
* contains data characters within an included element
|
||||
the status of the line should be M_SOMETHING not M_DCORCET because the data
|
||||
characters belong to the inner element rather than the outer one.
|
||||
|
||||
Also note that "M_DCORCET" originally stood for "data character or contextual
|
||||
end tag" when the Standard used the term "contextual element" to mean
|
||||
an element allowed by a model rather than an inclusion and when
|
||||
the rules for ignoring RE's referred to the occurrence of end tags of
|
||||
such elements rather than the entire elements. Now the acronym can be
|
||||
interpreted as "data character or contextual element".
|
||||
*/
|
||||
#define M_NOTHING 0
|
||||
#define M_SOMETHING 1
|
||||
#define M_DCORCET 2
|
||||
|
||||
/* Definitions for parse stack. The primary data structure of PARSER
|
||||
is a stack containing one entry for each open element. Each entry
|
||||
on the stack is described in an m_parse structure. Entries for
|
||||
element's whose content is defined by a content model have a
|
||||
pointer to a stack of open FSAs. These FSA stacks do not describe
|
||||
the actual automata (which are coded in the data structures
|
||||
generated by BUILD, but rather the current state in the active
|
||||
automata. An element's FSA stack will have one entry for the
|
||||
content model and an additional entry for each active and-group.
|
||||
*/
|
||||
|
||||
typedef struct m_parse M_PARSE ;
|
||||
typedef struct m_openfsa M_OPENFSA ;
|
||||
typedef struct m_andlist M_ANDLIST ;
|
||||
|
||||
struct m_parse {
|
||||
/* Pointer to preceding entry on stack */
|
||||
M_PARSE *oldtop ;
|
||||
|
||||
/* Identifier of element this entry represents */
|
||||
M_ELEMENT element ;
|
||||
|
||||
/* Pointer to table of parameter pointers for this instance of this
|
||||
element */
|
||||
M_WCHAR **param ;
|
||||
|
||||
/* Pointer to stack of open FSAs for this element */
|
||||
M_OPENFSA *fsastack ;
|
||||
|
||||
/* For RCDATA elements to indicate the nesting level
|
||||
of entities when the element opened, since net and etago
|
||||
delimiters are not recognized except in the same entity
|
||||
as the element began. */
|
||||
int thisent ;
|
||||
|
||||
/* TRUE iff the element's start-tag ended with a NET so that a NET
|
||||
is expected to end the element */
|
||||
LOGICAL neednet ;
|
||||
|
||||
/* Has a Record End occurred in the element's content? */
|
||||
LOGICAL firstre ;
|
||||
|
||||
/* Flag that indicates whether the element is contextual, i.e.,
|
||||
whether it occurred because it was allowed in context by a
|
||||
content model, or it was allowed by an inclusion exception or
|
||||
occurred by error. (The term "contextual subelement" was used
|
||||
in the Draft International Standard in the same sense as
|
||||
"proper subelement" in the International Standard.) */
|
||||
LOGICAL contextual ;
|
||||
|
||||
/* Whether character data is currently being processed. */
|
||||
LOGICAL intext ;
|
||||
|
||||
/* Line status. Indicates whether anything has occurred after
|
||||
the start-tag or most recent Record Start in this element */
|
||||
char linestat ;
|
||||
|
||||
/* Flag indicating whether or not a Record End (carriage return)
|
||||
has been scanned and is being held to see if there is more
|
||||
content in the element. If there is, the RE will be processed
|
||||
as a data character, otherwise it will be discarded. */
|
||||
LOGICAL holdre ;
|
||||
|
||||
/* Pointer to the element's short reference map. The value is NULL
|
||||
if there is no map. */
|
||||
int *map ;
|
||||
|
||||
/* Index in actions for processing text characters encountered
|
||||
in this element, and pointer to stack location where parameters
|
||||
should be retrieved. */
|
||||
int cdcase ;
|
||||
M_PARSE *cdparam ;
|
||||
|
||||
/* Index in actions for processing processing instructions
|
||||
encountered in this element, and pointer to stack location where
|
||||
parameters should be retrieved. */
|
||||
int picase ;
|
||||
M_PARSE *piparam ;
|
||||
|
||||
/* Index in actions for processing start- and end-strings
|
||||
encountered in this element, and pointer to stack location where
|
||||
parameters should be retrieved. */
|
||||
int stccase ;
|
||||
M_PARSE *stparam ;
|
||||
|
||||
/* Pointer to name of input file in which the current element
|
||||
began (NULL if primary input file). */
|
||||
M_WCHAR *file ;
|
||||
|
||||
/* Line number where the current element began. */
|
||||
int line ;
|
||||
|
||||
/* Interface-defined pointer stored on the stack */
|
||||
void *ifdata ;
|
||||
} ;
|
||||
|
||||
struct m_openfsa {
|
||||
/* Pointer to preceding entry on FSA stack */
|
||||
M_OPENFSA *oldtop ;
|
||||
|
||||
/* Current state in this FSA */
|
||||
M_STATE current ;
|
||||
|
||||
/* Identifier of set of and-groups being processed and pointer to list of
|
||||
and-groups that have occurred within this set. */
|
||||
M_ANDGROUP andgroup ;
|
||||
M_ANDLIST *usedand ;
|
||||
} ;
|
||||
|
||||
struct m_andlist {
|
||||
M_ANDGROUP group ;
|
||||
M_ANDLIST *next ;
|
||||
} ;
|
||||
|
||||
extern M_OPENFSA m_botfsa ;
|
||||
|
||||
/* Bottom marker of parse stack */
|
||||
M_PAREXTERN M_PARSE m_stackbot
|
||||
#if defined(M_PARDEF)
|
||||
= {
|
||||
/* M_PARSE *oldtop ;*/ NULL,
|
||||
/* M_ELEMENT element ;*/ M_NULLVAL,
|
||||
/* M_WCHAR **param ;*/ NULL,
|
||||
/* M_OPENFSA *fsastack ;*/ &m_botfsa,
|
||||
/* int thisent ;*/ 0,
|
||||
/* LOGICAL neednet ;*/ FALSE,
|
||||
/* LOGICAL firstre ; */ FALSE,
|
||||
/* LOGICAL contextual ;*/ TRUE,
|
||||
/* LOGICAL intext ;*/ FALSE,
|
||||
/* int linestat ;*/ M_NOTHING,
|
||||
/* LOGICAL holdre ;*/ FALSE,
|
||||
/* int *map ;*/ NULL,
|
||||
/* int cdcase ;*/ 1,
|
||||
/* M_PARSE *cdparam ;*/ &m_stackbot,
|
||||
/* int picase ;*/ 1,
|
||||
/* M_PARSE *piparam ;*/ &m_stackbot,
|
||||
/* int stccase ;*/ 1,
|
||||
/* M_PARSE *stparam ;*/ &m_stackbot,
|
||||
/* M_WCHAR *file ;*/ NULL,
|
||||
/* int line ;*/ M_FIRSTLINE,
|
||||
/* void *ifdata ;*/ NULL,
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
M_PAREXTERN M_OPENFSA m_botfsa
|
||||
#if defined(M_PARDEF)
|
||||
= {
|
||||
/* M_OPENFSA *oldtop ;*/ NULL,
|
||||
/* M_STATE current ;*/ 1,
|
||||
/* M_ANDGROUP andgroup ;*/ M_NULLVAL,
|
||||
/* M_ANDGROUP *usedand ;*/ NULL,
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Index of current top of parse stack */
|
||||
M_PAREXTERN M_PARSE *m_stacktop M_PARINIT(&m_stackbot) ;
|
||||
|
||||
/* Pointer to stack location where parameters for current code
|
||||
segment are defined. Used for inherited code segments (text-code,
|
||||
pi-code, string-code) */
|
||||
M_PAREXTERN M_PARSE *m_stackpar ;
|
||||
|
||||
/* Type of characters */
|
||||
typedef char M_HOLDTYPE ;
|
||||
|
||||
#if defined(M_PARDEF)
|
||||
#include "chartype.h"
|
||||
#else
|
||||
extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
|
||||
#endif
|
||||
|
||||
/* Indicates a start tag is allowed by an inclusion exception */
|
||||
#define M_NONCONTEXTUAL 2
|
||||
|
||||
/* Character used to delimit parameter names in start and end strings
|
||||
entered as data to ELTDEF */
|
||||
#define M_ESCAPECHAR '@'
|
||||
|
||||
/* Pointer to name of element */
|
||||
#define m_nameofelt(x) &m_ename[m_element[x - 1].enptr]
|
||||
|
||||
/* Status of characters as read from input stream */
|
||||
#define M_EE 0
|
||||
#define M_NORMAL 1
|
||||
#define M_CDCHAR 2
|
||||
#define M_ENTNORMAL 3
|
||||
|
||||
/* State transition network generated by CONTEXT */
|
||||
#include "sparse.h"
|
||||
|
||||
/* Maximum length of a sequence of blanks in a short reference delimiter */
|
||||
#define M_BSEQLEN 100
|
||||
|
||||
/* #defines used in recognition of short reference delimiters */
|
||||
#if defined(M_PARDEF)
|
||||
#define M_HOLDSIZ M_MAXSR + M_BSEQLEN * M_MAXSEQ + 1
|
||||
#else
|
||||
#define M_HOLDSIZ
|
||||
#endif
|
||||
#define M_REGCHAR 1
|
||||
#define M_SEQCHAR 2
|
||||
#define M_BSCHAR 3
|
||||
#define M_WSCHAR 4
|
||||
#define M_RSCHAR 5
|
||||
|
||||
/* Number of allowable tokens to display after a syntax error */
|
||||
#define M_EXPLIMIT 5
|
||||
|
||||
/* Status of T option output */
|
||||
#define M_TOPTSTARTTAG 0
|
||||
#define M_WHITESPACE 1
|
||||
#define M_OTHER 2
|
||||
|
||||
/* Maximum length of processing instruction (not in a PI entity) */
|
||||
#define M_PILEN 240
|
||||
|
||||
/* Storage for a name token just read by the scanner; and for a name read
|
||||
while parsing parameters */
|
||||
M_PAREXTERN M_WCHAR m_name[M_NAMELEN + 1] ;
|
||||
M_PAREXTERN M_WCHAR m_saveatt[M_NAMELEN + 1] ;
|
||||
|
||||
/* M_curcon is current state of FSA that controls parser; m_prevcon is the
|
||||
value of m_curcon before last character was scanned; m_token is the token
|
||||
type returned by last call to scanner; and
|
||||
m_scanval is index of element name just read within tag delimiters */
|
||||
M_PAREXTERN int m_curcon M_PARINIT(PREAMBLE) ;
|
||||
M_PAREXTERN int m_prevcon ;
|
||||
M_PAREXTERN int m_token ;
|
||||
M_PAREXTERN int m_scanval ;
|
||||
|
||||
/* Declarations for tentative list of omitted tags when checking for tag
|
||||
MINimization */
|
||||
typedef struct m_min M_MIN ;
|
||||
struct m_min {
|
||||
int val ;
|
||||
M_MIN *next ;
|
||||
} ;
|
||||
M_PAREXTERN M_MIN *m_minstart ;
|
||||
M_PAREXTERN M_MIN *m_minend ;
|
||||
M_PAREXTERN M_MIN **m_nextms ;
|
||||
M_PAREXTERN M_MIN **m_nextme ;
|
||||
|
||||
/* Count of the number of open elements expecting to be terminated with
|
||||
a NET */
|
||||
M_PAREXTERN int m_netlevel M_PARINIT(0) ;
|
||||
|
||||
/* Count of errors that have occurred */
|
||||
M_PAREXTERN int m_errcnt M_PARINIT(0) ;
|
||||
#define M_ERRLIM 100
|
||||
M_PAREXTERN int m_errlim M_PARINIT(M_ERRLIM) ;
|
||||
M_PAREXTERN int m_expcount ;
|
||||
M_PAREXTERN LOGICAL m_errexit M_PARINIT(FALSE) ;
|
||||
|
||||
/* Flag to indicate whether processing of the text has begun */
|
||||
M_PAREXTERN LOGICAL m_start M_PARINIT(FALSE) ;
|
||||
|
||||
/* Flag indicates whether current start tag is terminated by End-tag
|
||||
indicator or by tag-close delimiter (or start of another tag) */
|
||||
M_PAREXTERN LOGICAL m_scannet ;
|
||||
|
||||
/* Storage for literals */
|
||||
M_PAREXTERN M_WCHAR m_literal[M_LITLEN + 1] ;
|
||||
|
||||
/* Buffer for sequence of white space that has been read before it is
|
||||
determined whether or not the white space is significant */
|
||||
#define M_WSPACELEN 100
|
||||
M_PAREXTERN int m_wspace[M_WSPACELEN] ;
|
||||
M_PAREXTERN int m_wscount M_PARINIT(0) ;
|
||||
M_PAREXTERN int m_maxws M_PARINIT(0) ;
|
||||
M_PAREXTERN int m_wsused ;
|
||||
|
||||
/* Temporary pointers to parameter values. Used while scanning start tag
|
||||
before element is placed on parse stack.*/
|
||||
M_PAREXTERN
|
||||
#if defined M_PROTO
|
||||
#endif
|
||||
M_WCHAR *m_poccur[
|
||||
#if defined(M_PARDEF)
|
||||
M_MAXPAR ? M_MAXPAR : 1
|
||||
#endif
|
||||
] ;
|
||||
|
||||
/* Index of a particular parameter within the parameter list for a given
|
||||
element */
|
||||
M_PAREXTERN int m_psave ;
|
||||
/* Index of a particular parameter within the list of all parameters for all
|
||||
elements */
|
||||
M_PAREXTERN int m_ppsave ;
|
||||
|
||||
/* Index of element of tag just scanned; may be result of short tag
|
||||
minimization */
|
||||
M_PAREXTERN M_ELEMENT m_scanel ;
|
||||
|
||||
/* Read-ahead buffer and number of characters currently in that buffer */
|
||||
#define M_SAVECHAR 500
|
||||
M_PAREXTERN int m_savechar[M_SAVECHAR] ;
|
||||
M_PAREXTERN M_WCHAR m_savedchar[M_SAVECHAR] ;
|
||||
M_PAREXTERN M_WCHAR m_oldlinestat[M_SAVECHAR] ;
|
||||
M_PAREXTERN M_WCHAR m_oldatrs[M_SAVECHAR] ;
|
||||
M_PAREXTERN int m_sourcefile[M_SAVECHAR] ;
|
||||
M_PAREXTERN M_WCHAR m_atrs M_PARINIT(TRUE) ;
|
||||
M_PAREXTERN int m_oldlsindex M_PARINIT(M_SAVECHAR - 1) ;
|
||||
M_PAREXTERN int m_toundo M_PARINIT(0) ;
|
||||
M_PAREXTERN int m_maxundo M_PARINIT(0) ;
|
||||
#define M_LINELENGTH 80
|
||||
M_PAREXTERN int m_saveline[M_LINELENGTH][M_ENTLVL + 1] ;
|
||||
M_PAREXTERN int m_svlncnt[M_ENTLVL + 1] M_PARINIT({0}) ;
|
||||
M_PAREXTERN LOGICAL m_svlnwrap[M_ENTLVL + 1] M_PARINIT({FALSE}) ;
|
||||
|
||||
/* Arrays used for short references */
|
||||
M_PAREXTERN int m_hold[M_HOLDSIZ] ;
|
||||
M_PAREXTERN M_HOLDTYPE m_dhold[M_HOLDSIZ] ;
|
||||
M_PAREXTERN int m_delim[M_HOLDSIZ] ;
|
||||
M_PAREXTERN char m_srefchartype[M_HOLDSIZ] ;
|
||||
M_PAREXTERN int m_current[M_HOLDSIZ] ;
|
||||
|
||||
/* Options
|
||||
A -- Trace of calls to m_malloc() and m_free()
|
||||
B --
|
||||
C -- Trace of calls to m_getachar(), putachar()
|
||||
D -- Trace of encountered data characters
|
||||
E -- Don't report duplicate entity declarations
|
||||
F --
|
||||
G --
|
||||
H -- M_malloc and m_free check for valid heap
|
||||
I --
|
||||
J --
|
||||
K --
|
||||
L -- Don't limit number of possible tokens displayed by expecting()
|
||||
M -- Determine start-tag minimization strictly according to the Standard
|
||||
N --
|
||||
O --
|
||||
P --
|
||||
Q --
|
||||
R --
|
||||
S -- Scanner trace
|
||||
T -- Tag trace
|
||||
U --
|
||||
V --
|
||||
W -- Missing tagc not considered an error
|
||||
X --
|
||||
Y --
|
||||
Z --
|
||||
*/
|
||||
|
||||
M_PAREXTERN LOGICAL m_malftrace M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_chtrace M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_cdtrace M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_entdupchk M_PARINIT(TRUE) ;
|
||||
M_PAREXTERN LOGICAL m_heapchk M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_explimit M_PARINIT(TRUE) ;
|
||||
M_PAREXTERN LOGICAL m_conform M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_scantrace M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_tagtrace M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN LOGICAL m_wholetag M_PARINIT(FALSE) ;
|
||||
M_PAREXTERN int m_toptstat ;
|
||||
|
||||
/* Flag that indicates when unexpected content detected after document
|
||||
appears to be complete */
|
||||
M_PAREXTERN LOGICAL m_aftereod M_PARINIT(FALSE) ;
|
||||
|
||||
/* Save standard C main program arguments */
|
||||
M_PAREXTERN int m_argc ;
|
||||
M_PAREXTERN char **m_argv ;
|
||||
|
||||
/* PARSER output file */
|
||||
M_PAREXTERN FILE *m_outfile M_PARINIT(stdout) ;
|
||||
M_PAREXTERN FILE *m_errfile M_PARINIT(stderr) ;
|
||||
|
||||
/* Save processing instruction */
|
||||
M_PAREXTERN M_WCHAR m_pi[M_PILEN + 1] ;
|
||||
M_PAREXTERN int m_pilen M_PARINIT(0) ;
|
||||
|
||||
/* Entity being defined */
|
||||
M_PAREXTERN M_ENTITY *m_entity ;
|
||||
M_PAREXTERN int m_entclen ;
|
||||
M_PAREXTERN M_WCHAR m_entcontent[M_LITLEN + 1] ;
|
||||
|
||||
/* Largest positive integer */
|
||||
#define M_BIGINT 0x7FFF
|
||||
|
||||
/* Include function prototypes */
|
||||
#include "proto.h"
|
||||
|
||||
118
cde/programs/dthelp/parser/pass2/parser/parutil.c
Normal file
118
cde/programs/dthelp/parser/pass2/parser/parutil.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $XConsortium: parutil.c /main/3 1995/11/08 10:56:57 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Parutil.c contains utility functions for program PARSER */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <locale.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
#include "if.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
/* Adjust parsing state after each token if necessary */
|
||||
void m_adjuststate(M_NOPAR)
|
||||
{
|
||||
if (m_curcon == START) {
|
||||
if (m_netlevel) {
|
||||
if (m_stacktop->intext) m_curcon = NETCDATA ;
|
||||
else if (m_textpermitted()) m_curcon = NETDATACON ;
|
||||
else m_curcon = NETELCON ;
|
||||
}
|
||||
else {
|
||||
if (m_stacktop->intext) m_curcon = POUNDCDATA ;
|
||||
else if (m_textpermitted()) m_curcon = DATACON ;
|
||||
else m_curcon = ELCON ;
|
||||
}
|
||||
}
|
||||
else if (m_netlevel) switch(m_curcon) {
|
||||
case POUNDCDATA:
|
||||
m_curcon = NETCDATA ;
|
||||
break ;
|
||||
case CDATAEL:
|
||||
if (m_stacktop->neednet) m_curcon = NETELCDATA ;
|
||||
break ;
|
||||
case RCDATAEL:
|
||||
if (m_stacktop->neednet) m_curcon = NETRCDATA ;
|
||||
break ;
|
||||
default:
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tests whether the element named in a tag is defined; if so, returns its
|
||||
index; otherwise return FALSE */
|
||||
M_ELEMENT m_eltname(M_NOPAR)
|
||||
{
|
||||
M_ELEMENT eltid ;
|
||||
|
||||
if (eltid = m_packedlook(m_entree, m_name)) return(eltid) ;
|
||||
else {
|
||||
m_err1("Undefined element %s", m_name) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
}
|
||||
|
||||
int get_mb_cur_max()
|
||||
{
|
||||
char *l;
|
||||
int i;
|
||||
|
||||
l = getenv("LANG");
|
||||
|
||||
i = MB_CUR_MAX;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Program initialization */
|
||||
void m_initialize(M_NOPAR)
|
||||
{
|
||||
char **mb_delims;
|
||||
M_WCHAR **wc_delims;
|
||||
m_signmsg(m_conform ?
|
||||
"MARKUP PARSER " :
|
||||
"MARKUP PARSER (with non-canonical SGML enhancements) ") ;
|
||||
m_signmsg(M_VERSION) ;
|
||||
m_signmsg("\n") ;
|
||||
m_signmsg("(c) Copyright 1993, 1994, 1995 Hewlett-Packard Company\n");
|
||||
m_signmsg("(c) Copyright 1993, 1994, 1995 International Business Machines Corp.\n");
|
||||
m_signmsg("(c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.\n");
|
||||
m_signmsg("(c) Copyright 1993, 1994, 1995 Unix System Labs, Inc., a subsidiary of Novell, Inc.\n");
|
||||
/* commented out since date stamp interfers with testing -- bad reason
|
||||
m_getsignon() ;
|
||||
*/
|
||||
if (! (m_sysent[m_sysecnt] = m_openfirst()))
|
||||
{
|
||||
m_error("Unable to open input file") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
get_mb_cur_max();
|
||||
|
||||
mb_delims = mb_dlmptr;
|
||||
wc_delims = m_dlmptr;
|
||||
|
||||
while (*mb_delims)
|
||||
{
|
||||
*wc_delims++ = MakeWideCharString(*mb_delims);
|
||||
mb_delims++;
|
||||
}
|
||||
*wc_delims = 0;
|
||||
}
|
||||
39
cde/programs/dthelp/parser/pass2/parser/parvalok.c
Normal file
39
cde/programs/dthelp/parser/pass2/parser/parvalok.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $XConsortium: parvalok.c /main/3 1995/11/08 10:57:12 rswiston $ */
|
||||
/*
|
||||
Copyright 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Function callable by interface designers. Returns TRUE if specified value
|
||||
is a legal value for the indicated parameter of the given element,
|
||||
FALSE otherwise. */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL m_parvalok( M_WCHAR *elt , M_WCHAR *param , const M_WCHAR *value )
|
||||
#else
|
||||
LOGICAL m_parvalok(elt, param, value)
|
||||
M_WCHAR *elt ;
|
||||
M_WCHAR *param ;
|
||||
M_WCHAR *value ;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
M_ELEMENT eltid ;
|
||||
int par ;
|
||||
int i ;
|
||||
|
||||
if (! (eltid = m_packedlook(m_entree, elt))) return(FALSE) ;
|
||||
for (par = m_element[eltid - 1].parptr, i = 1 ;
|
||||
i <= m_element[eltid - 1].parcount ;
|
||||
par++, i++)
|
||||
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], param))
|
||||
if (m_partype(par, value)) return(TRUE) ;
|
||||
else return(FALSE) ;
|
||||
|
||||
/* No such parameter */
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
27
cde/programs/dthelp/parser/pass2/parser/pi.c
Normal file
27
cde/programs/dthelp/parser/pass2/parser/pi.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* $XConsortium: pi.c /main/3 1995/11/08 10:57:26 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Pi.c executes pi-code specified in the interface. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Include generated code */
|
||||
#include "pfile.c"
|
||||
|
||||
|
||||
/* When a processing instruction or SDATA entity other than a CODE entity
|
||||
occurs */
|
||||
void m_piaction(m_pi, m_entname, m_enttype)
|
||||
M_WCHAR *m_pi ;
|
||||
M_WCHAR *m_entname ;
|
||||
int m_enttype ;
|
||||
{
|
||||
m_stackpar = m_stacktop->piparam ;
|
||||
(*m_ptable[m_stacktop->picase])(m_pi, m_entname, m_enttype) ;
|
||||
}
|
||||
|
||||
17
cde/programs/dthelp/parser/pass2/parser/procscmp.c
Normal file
17
cde/programs/dthelp/parser/pass2/parser/procscmp.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* $XConsortium: procscmp.c /main/3 1995/11/08 10:57:41 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Procscmp.c prefixes the interface's procs.c file with appropriate
|
||||
declarations so it can be compiled. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Include any procedures specified by the interface designer */
|
||||
#include "procs.c"
|
||||
|
||||
|
||||
825
cde/programs/dthelp/parser/pass2/parser/proto.h
Normal file
825
cde/programs/dthelp/parser/pass2/parser/proto.h
Normal file
@@ -0,0 +1,825 @@
|
||||
/* $XConsortium: proto.h /main/3 1995/11/08 10:57:56 rswiston $ */
|
||||
int m_actgetc(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_adjuststate(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_allwhite(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_attval(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_attvonly(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_checkstart(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT val
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_ckend(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT val, LOGICAL neednet
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_ckmap(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *name, LOGICAL useoradd
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_closent(
|
||||
#if defined(M_PROTO)
|
||||
void *m_ptr
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_codeent(
|
||||
#if defined(M_PROTO)
|
||||
int m_ent
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_PARSE *m_copystackelt(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *m_cyclent(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL init, unsigned char *type, M_WCHAR **content,
|
||||
unsigned char *wheredef
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_dispcurelt(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *file, int line
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_done(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_dumpline(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *file, int line
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_eduptype(
|
||||
#if defined(M_PROTO)
|
||||
int type
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_ELEMENT m_eltname(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_endaction(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT m_elt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_endcase(
|
||||
#if defined(M_PROTO)
|
||||
int m_action
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_endtag(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_entexpand(
|
||||
#if defined(M_PROTO)
|
||||
M_ENTITY *openent
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_eprefix(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err1(
|
||||
#if defined(M_PROTO)
|
||||
const char *text, const M_WCHAR *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err2(
|
||||
#if defined(M_PROTO)
|
||||
const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err3(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err4(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err5(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
|
||||
M_WCHAR *arg4, M_WCHAR *arg5
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err6(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
|
||||
M_WCHAR *arg4, M_WCHAR *arg5, M_WCHAR *arg6
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err7(
|
||||
#if defined(M_PROTO)
|
||||
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
|
||||
M_WCHAR *arg4, M_WCHAR *arg5, M_WCHAR *arg6, M_WCHAR *arg7
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_errline(
|
||||
#if defined(M_PROTO)
|
||||
char *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_error(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_esuffix(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_exit(
|
||||
#if defined(M_PROTO)
|
||||
int status
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_etcomplete(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_excluded(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT elt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_expecting(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_expexpand(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *expstart, M_STATE node, LOGICAL *required, LOGICAL *data
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_expline(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *expstart, LOGICAL *data, M_ELEMENT label
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_exptend(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *expstart, M_PARSE *stackptr
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_findact(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT elt, int *array
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_findatt(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_findchain(
|
||||
#if defined(M_PROTO)
|
||||
M_PARSE *stackptr, int start, int chainin, int *chainout, int *index,
|
||||
LOGICAL wild
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_findpar(
|
||||
#if defined(M_PROTO)
|
||||
const char *elt, const char *param, const M_WCHAR *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_ELEMENT m_findunique(
|
||||
#if defined(M_PROTO)
|
||||
M_STATE from, int *newleft
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_frcend(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT val
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_frcstart(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_free(
|
||||
#if defined(M_PROTO)
|
||||
void *block, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_freeFSA(
|
||||
#if defined(M_PROTO)
|
||||
M_PARSE *stackelt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_freemin(
|
||||
#if defined(M_PROTO)
|
||||
M_MIN *min
|
||||
, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_freeparam(
|
||||
#if defined(M_PROTO)
|
||||
M_PARSE *stackelt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_gendelim(
|
||||
#if defined(M_PROTO)
|
||||
int srlen, int context
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_getachar(
|
||||
#if defined(M_PROTO)
|
||||
M_HOLDTYPE *dchar
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_getc(
|
||||
#if defined(M_PROTO)
|
||||
void *m_ptr
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int mb_getwc(
|
||||
#if defined(M_PROTO)
|
||||
void *m_ptr
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_getdata(
|
||||
#if defined(M_PROTO)
|
||||
int n, LOGICAL *flag
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_getline(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR **file, int *line
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_getname(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR first
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_getsignon(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_gettoken(
|
||||
#if defined(M_PROTO)
|
||||
int *c, M_HOLDTYPE *dchar, int context
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_globes(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_globss(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_holdproc(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_inctest(
|
||||
#if defined(M_PROTO)
|
||||
int *count, int limit, char *message
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_initctype(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_initialize(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_lastchars(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_level(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *elt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_mblevel(
|
||||
#if defined(M_PROTO)
|
||||
char *elt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_litproc(
|
||||
#if defined(M_PROTO)
|
||||
int delim
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_longent(
|
||||
#if defined(M_PROTO)
|
||||
int context
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_lookent(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *name, unsigned char *type, M_WCHAR **content,
|
||||
unsigned char *wheredef
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void main(
|
||||
#if defined(M_PROTO)
|
||||
int argc, char **argv
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_malloc(
|
||||
#if defined(M_PROTO)
|
||||
int size, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_missingtagc(
|
||||
#if defined(M_PROTO)
|
||||
int c, M_HOLDTYPE dchar, LOGICAL start
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_nextand(
|
||||
#if defined(M_PROTO)
|
||||
M_OPENFSA *thisfsa, M_ELEMENT label
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_nextdelimchar(
|
||||
#if defined(M_PROTO)
|
||||
int *n, int i, LOGICAL *linestart, LOGICAL newlinestart, LOGICAL skipblank,
|
||||
unsigned char type
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_ntrent(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_nullendtag(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_omitend(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_omitstart(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_openchk(
|
||||
#if defined(M_PROTO)
|
||||
FILE **ptr, char *name, char *mode
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_openent(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *entcontent
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_openfirst(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_optstring(
|
||||
#if defined(M_PROTO)
|
||||
char *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_packedlook(
|
||||
#if defined(M_PROTO)
|
||||
M_PTRIE *xptrie, M_WCHAR *name
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_parcount(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *elt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *m_pardefault(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *elt, M_WCHAR *param, unsigned char *type
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *m_parent(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *m_parname(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *elt, int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *m_mbparname(
|
||||
#if defined(M_PROTO)
|
||||
char *elt, int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
const M_WCHAR *m_partype(
|
||||
#if defined(M_PROTO)
|
||||
const int par, const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_parupper(
|
||||
#if defined(M_PROTO)
|
||||
int par, M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_parvalok(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *elt, M_WCHAR *param, const M_WCHAR *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_piaction(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *m_pi, M_WCHAR *m_entname, int m_enttype
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_pop(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_push(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT elt, M_STATE current, LOGICAL need
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_putdata(
|
||||
#if defined(M_PROTO)
|
||||
void *data, int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_readcomments(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_realloc(
|
||||
#if defined(M_PROTO)
|
||||
void *ptr, int size, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_scan(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_setmap(
|
||||
#if defined(M_PROTO)
|
||||
int map, LOGICAL useoradd
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_setoptions(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_setparam(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR **cvar, int par
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_shortref(
|
||||
#if defined(M_PROTO)
|
||||
int context
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_showcurelt(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_signmsg(
|
||||
#if defined(M_PROTO)
|
||||
char *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_sigre(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_startdoc(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_startmsg(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_stcaction(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_stcomplete(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_stkdefaultparams(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_stkonedef(
|
||||
#if defined(M_PROTO)
|
||||
int par, M_ELEMENT scanel, M_WCHAR **poccur, int i
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_stkparams(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_strtaction(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT m_elt
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_strtcase(
|
||||
#if defined(M_PROTO)
|
||||
int m_action
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_strtcdata(
|
||||
#if defined(M_PROTO)
|
||||
int scanval
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_strtproc(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT scanval
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_strttag(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT val, LOGICAL net
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_textaction(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR m_textchar
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_textout(
|
||||
#if defined(M_PROTO)
|
||||
char *format, LOGICAL start, LOGICAL end
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_textpermitted(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
M_WCHAR *m_thisfile(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_thisline(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_trace(
|
||||
#if defined(M_PROTO)
|
||||
char *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_wctrace(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *p
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_transition(
|
||||
#if defined(M_PROTO)
|
||||
M_ELEMENT label, LOGICAL recur
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_undodelim(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *delim, LOGICAL flag
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_ungetachar(
|
||||
#if defined(M_PROTO)
|
||||
int c, M_HOLDTYPE dchar, LOGICAL preread
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_updatedefault(
|
||||
#if defined(M_PROTO)
|
||||
const int par, const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_wcupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *p, const M_WCHAR *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_wcmbupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *p, const char *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_mbmbupstrcmp(
|
||||
#if defined(M_PROTO)
|
||||
const char *p, const char *q
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_validinpar(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_vldentref(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_whitespace(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
1166
cde/programs/dthelp/parser/pass2/parser/scan.c
Normal file
1166
cde/programs/dthelp/parser/pass2/parser/scan.c
Normal file
File diff suppressed because it is too large
Load Diff
14
cde/programs/dthelp/parser/pass2/parser/setopt.c
Normal file
14
cde/programs/dthelp/parser/pass2/parser/setopt.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $XConsortium: setopt.c /main/3 1995/11/08 10:58:30 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
|
||||
/* Set program options */
|
||||
void m_setoptions(M_NOPAR)
|
||||
{
|
||||
if (m_argc > 1) m_optstring(m_argv[1]) ;
|
||||
}
|
||||
22
cde/programs/dthelp/parser/pass2/parser/setpar.c
Normal file
22
cde/programs/dthelp/parser/pass2/parser/setpar.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/* $XConsortium: setpar.c /main/3 1995/11/08 10:58:44 rswiston $ */
|
||||
/*
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Setparam.c is used by interfaces where code accesses an element's
|
||||
attributes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* Set a user-defined C variable to the corresponding parameter value */
|
||||
void m_setparam(cvar, par)
|
||||
M_WCHAR **cvar ;
|
||||
int par ;
|
||||
{
|
||||
*cvar = m_stackpar->param[par] ;
|
||||
}
|
||||
|
||||
18
cde/programs/dthelp/parser/pass2/parser/signmsg.c
Normal file
18
cde/programs/dthelp/parser/pass2/parser/signmsg.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* $XConsortium: signmsg.c /main/3 1995/11/08 10:58:59 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Process signon message text */
|
||||
void m_signmsg(p)
|
||||
M_WCHAR *p ;
|
||||
{
|
||||
char mb_p;
|
||||
|
||||
mb_p = MakeMByteString(p);
|
||||
m_errline(mb_p) ;
|
||||
m_free(mb_p,"multi-byte string");
|
||||
}
|
||||
22
cde/programs/dthelp/parser/pass2/parser/start.c
Normal file
22
cde/programs/dthelp/parser/pass2/parser/start.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/* $XConsortium: start.c /main/3 1995/11/08 10:59:13 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Start.c executes start-code specified in the interface. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Include generated file */
|
||||
#include "sfile.c"
|
||||
|
||||
/* Perform the m_action-th start-code in the interface */
|
||||
void m_strtcase(m_action)
|
||||
int m_action ;
|
||||
{
|
||||
(*m_stable[m_action])() ;
|
||||
}
|
||||
|
||||
17
cde/programs/dthelp/parser/pass2/parser/startdoc.c
Normal file
17
cde/programs/dthelp/parser/pass2/parser/startdoc.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* $XConsortium: startdoc.c /main/3 1995/11/08 10:59:27 rswiston $ */
|
||||
/*
|
||||
Copyright 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Default function called at start of document instance. Allows interface
|
||||
control after all entity declarations have been processed. Not needed
|
||||
in valid documents (when it is called just prior to global start-code),
|
||||
but may be useful in some applications nevertheless. */
|
||||
void m_startdoc(M_NOPAR)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
23
cde/programs/dthelp/parser/pass2/parser/string.c
Normal file
23
cde/programs/dthelp/parser/pass2/parser/string.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* $XConsortium: string.c /main/3 1995/11/08 10:59:41 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* String.c executes string-code specified in the interface. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Include generated code */
|
||||
#include "stfile.c"
|
||||
|
||||
#if defined(M_PROTO)
|
||||
void m_stcaction(M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END)
|
||||
#else
|
||||
void m_stcaction(m_string, M_START, M_END)
|
||||
M_WCHAR *m_string ;
|
||||
LOGICAL M_START ;
|
||||
LOGICAL M_END ;
|
||||
#endif
|
||||
{
|
||||
m_stackpar = m_stacktop->stparam ;
|
||||
(*m_sttable[m_stacktop->stccase])(m_string, M_START, M_END) ;
|
||||
}
|
||||
755
cde/programs/dthelp/parser/pass2/parser/struct.c
Normal file
755
cde/programs/dthelp/parser/pass2/parser/struct.c
Normal file
@@ -0,0 +1,755 @@
|
||||
/* $XConsortium: struct.c /main/3 1995/11/08 10:59:57 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Struct.c contains functions relevant to parsing document structure for
|
||||
program PARSER */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "delim.h"
|
||||
#include "context.h"
|
||||
#include "parser.h"
|
||||
#include "entext.h"
|
||||
#include "if.h"
|
||||
|
||||
/* M_checkstart tests to see if the element (or #PCDATA) indicated by VAL
|
||||
is valid input. It returns TRUE, FALSE, or M_NONCONTEXTUAL respectively
|
||||
if the element is allowed by content, not allowed, or allowed by an
|
||||
inclusion exception. */
|
||||
int m_checkstart(val)
|
||||
M_ELEMENT val ;
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
int except ;
|
||||
|
||||
/* Check for applicable exclusions */
|
||||
if (m_excluded(val)) return(FALSE) ;
|
||||
|
||||
/* Check for declared content in element currently at top of stack */
|
||||
if (m_stacktop->oldtop) {
|
||||
if (m_element[m_stacktop->element - 1].content == M_ANY) return(TRUE) ;
|
||||
if (m_element[m_stacktop->element - 1].content == M_CDATA ||
|
||||
m_element[m_stacktop->element - 1].content == M_RCDATA)
|
||||
if (! val) return(TRUE) ;
|
||||
else return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Check content model */
|
||||
if (m_transition(val, TRUE)) return(TRUE) ;
|
||||
|
||||
/* Check for inclusions */
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop ;
|
||||
stackptr = stackptr->oldtop)
|
||||
for (except = m_element[stackptr->element - 1].inptr ;
|
||||
except ;
|
||||
except = m_exception[except - 1].next)
|
||||
if (m_exception[except - 1].element == val) return(M_NONCONTEXTUAL) ;
|
||||
|
||||
/* Nothing left to try, val is not allowed */
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* M_ckend verifies that element VAL can be legally ended at the
|
||||
current state of the parse, by an end tag or NET as indicated by NEEDNET.
|
||||
If VAL is not the element at the top of the parse stack, m_ckend
|
||||
checks to see if the end of VAL can validly end nested
|
||||
elements as well. */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL m_ckend(M_ELEMENT val, LOGICAL neednet)
|
||||
#else
|
||||
LOGICAL m_ckend(val, neednet)
|
||||
M_ELEMENT val ;
|
||||
LOGICAL neednet ;
|
||||
#endif
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
M_OPENFSA *fsastack ;
|
||||
M_ANDLIST *usedand ;
|
||||
M_ANDGROUP pand ;
|
||||
M_MIN *minend ;
|
||||
M_MIN *discard ;
|
||||
|
||||
m_minend = NULL ;
|
||||
m_nextme = &m_minend ;
|
||||
/* Go down the stack, checking that each element can end until
|
||||
element val occurs */
|
||||
for (stackptr = m_stacktop ; stackptr ; stackptr = stackptr->oldtop) {
|
||||
/* If the element at stackptr has a content model, make sure each
|
||||
open fsa is in a final state and that all required submodels of
|
||||
open and-groups have occurred */
|
||||
for (fsastack = stackptr->fsastack ;
|
||||
fsastack ;
|
||||
fsastack = fsastack->oldtop) {
|
||||
if (! m_state[fsastack->current - 1].final) {
|
||||
m_freemin(m_minend, "end-tag minimization") ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
for (pand = fsastack->andgroup ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
/* Don't bother checking if optional submodel of an and-group
|
||||
has occurred */
|
||||
if (m_state[m_andgroup[pand - 1].start - 1].final) continue ;
|
||||
for (usedand = fsastack->usedand ;
|
||||
usedand ;
|
||||
usedand = usedand->next)
|
||||
if (usedand->group == pand) break ;
|
||||
if (! usedand) {
|
||||
/* Didn't find a required submodel */
|
||||
m_freemin(m_minend, "end-tag minimization") ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
} /* End for pand */
|
||||
} /* End for fsastack */
|
||||
/* Have confirmed that the element indicated by stackptr can end now */
|
||||
if (stackptr->element == val) break ;
|
||||
*m_nextme = (M_MIN *) m_malloc(sizeof(M_MIN), "end-tag minimization") ;
|
||||
(*m_nextme)->next = NULL ;
|
||||
(*m_nextme)->val = stackptr->element ;
|
||||
m_nextme = &(*m_nextme)->next ;
|
||||
} /* End for stackptr */
|
||||
if (! stackptr) {
|
||||
m_freemin(m_minend, "end-tag minimization") ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
for (minend = m_minend ; minend ; ) {
|
||||
discard = minend ;
|
||||
minend = minend->next ;
|
||||
m_free(discard, "end-tag minimization") ;
|
||||
if (m_stacktop->neednet && ! neednet) {
|
||||
M_WCHAR *wc_net;
|
||||
|
||||
wc_net = MakeWideCharString(m_net);
|
||||
m_err2("Expecting %s to end %s",
|
||||
wc_net,
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_free(wc_net,"wide character string");
|
||||
m_showcurelt() ;
|
||||
}
|
||||
if (! m_element[m_stacktop->element - 1].emin) {
|
||||
m_err1("Missing end tag for %s", m_nameofelt(m_stacktop->element)) ;
|
||||
m_showcurelt() ;
|
||||
}
|
||||
m_endtag(m_stacktop->element) ;
|
||||
}
|
||||
if (m_stacktop->neednet != neednet) {
|
||||
M_WCHAR *wc_etago, *wc_tagc, *wc_mnet, *wc_stago, *wc_net;
|
||||
|
||||
wc_etago = MakeWideCharString(m_etago);
|
||||
wc_stago = MakeWideCharString(m_stago);
|
||||
wc_tagc = MakeWideCharString(m_tagc);
|
||||
wc_net = MakeWideCharString(m_net);
|
||||
if (neednet)
|
||||
m_err4("Expecting %s%s%s instead of %s",
|
||||
wc_etago,
|
||||
m_nameofelt(m_stacktop->element),
|
||||
wc_tagc,
|
||||
wc_net) ;
|
||||
else
|
||||
m_err4("Expecting %s to end %s%s%s",
|
||||
wc_net,
|
||||
wc_stago,
|
||||
m_nameofelt(m_stacktop->element),
|
||||
wc_tagc) ;
|
||||
m_showcurelt() ;
|
||||
m_free(wc_etago,"wide character string");
|
||||
m_free(wc_stago,"wide character string");
|
||||
m_free(wc_tagc,"wide character string");
|
||||
m_free(wc_net,"wide character string");
|
||||
}
|
||||
m_endtag(val) ;
|
||||
return(TRUE) ;
|
||||
} /*end m_ckend*/
|
||||
|
||||
/* Make a copy of the stack entry at the top of the parse stack in a scratch
|
||||
area */
|
||||
M_PARSE *m_copystackelt(M_NOPAR)
|
||||
{
|
||||
M_OPENFSA *oldfsa ;
|
||||
M_OPENFSA **newfsa ;
|
||||
M_ANDLIST *oldand ;
|
||||
M_ANDLIST **newand ;
|
||||
M_PARSE *copy ;
|
||||
|
||||
copy = (M_PARSE *) m_malloc(sizeof(M_PARSE), "stack element") ;
|
||||
memcpy((char *) copy, (char *) m_stacktop, sizeof(M_PARSE)) ;
|
||||
copy->param = NULL ;
|
||||
for (oldfsa = m_stacktop->fsastack, newfsa = ©->fsastack ;
|
||||
oldfsa ;
|
||||
oldfsa = oldfsa->oldtop, newfsa = &(*newfsa)->oldtop) {
|
||||
*newfsa = (M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
|
||||
memcpy((char *) *newfsa, (char *) oldfsa, sizeof(M_OPENFSA)) ;
|
||||
for (oldand = oldfsa->usedand, newand = &(*newfsa)->usedand ;
|
||||
oldand ;
|
||||
oldand = oldand->next, newand = &(*newand)->next) {
|
||||
*newand = (M_ANDLIST *) m_malloc(sizeof(M_ANDLIST), "and list") ;
|
||||
(*newand)->group = oldand->group ;
|
||||
(*newand)->next = NULL ;
|
||||
}
|
||||
}
|
||||
return(copy) ;
|
||||
}
|
||||
|
||||
/* End of document */
|
||||
void m_done(M_NOPAR)
|
||||
{
|
||||
M_ELEMENT lastelt ;
|
||||
|
||||
while (m_stacktop->oldtop) {
|
||||
lastelt = m_stacktop->element ;
|
||||
if (! m_ckend(m_stacktop->element, FALSE)) {
|
||||
m_err1("More content expected in element %s at end of document",
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_expecting() ;
|
||||
m_showcurelt() ;
|
||||
m_frcend(m_stacktop->element) ;
|
||||
}
|
||||
else if (! m_element[lastelt - 1].emin)
|
||||
m_err1("Missing end tag for %s", m_nameofelt(lastelt)) ;
|
||||
}
|
||||
m_endcase(1) ;
|
||||
m_globes() ;
|
||||
m_exit(m_errexit) ;
|
||||
}
|
||||
|
||||
/* Process the endtag (implied, abbreviated, or explicit) for element C*/
|
||||
void m_endtag(c)
|
||||
M_ELEMENT c ;
|
||||
{
|
||||
m_endaction(c) ;
|
||||
m_pop() ;
|
||||
if (m_stacktop->intext) {
|
||||
m_curcon = POUNDCDATA ;
|
||||
if (m_netlevel) m_curcon = NETCDATA ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that the identified element is not prohibited in the current context
|
||||
by an exclusion exception */
|
||||
LOGICAL m_excluded(elt)
|
||||
M_ELEMENT elt ;
|
||||
{
|
||||
M_PARSE *stackptr ;
|
||||
int except ;
|
||||
|
||||
if (! elt) return(FALSE) ;
|
||||
for (stackptr = m_stacktop ;
|
||||
stackptr->oldtop ;
|
||||
stackptr = stackptr->oldtop)
|
||||
for (except = m_element[stackptr->element - 1].exptr ;
|
||||
except ;
|
||||
except = m_exception[except - 1].next)
|
||||
if (m_exception[except - 1].element == elt) return(TRUE) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Free the OPEN FSA substructures associated with an element on
|
||||
the parse stack */
|
||||
void m_freeFSA(stackelt)
|
||||
M_PARSE *stackelt ;
|
||||
{
|
||||
M_OPENFSA *fsastack ;
|
||||
M_ANDLIST *usedand ;
|
||||
|
||||
while (stackelt->fsastack) {
|
||||
fsastack = stackelt->fsastack ;
|
||||
if (fsastack == &m_botfsa) return ;
|
||||
while (fsastack->usedand) {
|
||||
usedand = fsastack->usedand ;
|
||||
fsastack->usedand = usedand->next ;
|
||||
m_free(usedand, "and list") ;
|
||||
}
|
||||
stackelt->fsastack = fsastack->oldtop ;
|
||||
m_free(fsastack, "FSA") ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free storage used for tentative chain of tag minimizations */
|
||||
void m_freemin(min, msg)
|
||||
M_MIN *min ;
|
||||
char *msg ;
|
||||
{
|
||||
M_MIN *discard ;
|
||||
|
||||
for ( ; min ;) {
|
||||
discard = min ;
|
||||
min = min->next ;
|
||||
m_free(discard, msg) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* M_nextand returns TRUE iff element label is allowed at the current point
|
||||
in the current content model by starting a new submodel of the and-group
|
||||
indicated by fsastack, or (if the and-group is within a seq-group) by
|
||||
continuing past the and-group */
|
||||
LOGICAL m_nextand(thisfsa, label)
|
||||
M_OPENFSA *thisfsa ;
|
||||
M_ELEMENT label ;
|
||||
{
|
||||
M_ANDLIST *newgroup ;
|
||||
M_ANDGROUP pand ;
|
||||
M_ANDLIST *plist ;
|
||||
M_OPENFSA *savefsa ;
|
||||
M_OPENFSA *fsa ;
|
||||
LOGICAL required = FALSE ;
|
||||
LOGICAL last ;
|
||||
|
||||
/* Verify currently within an and-group and in final state of this
|
||||
branch */
|
||||
if (! m_state[thisfsa->current - 1].final) return(FALSE) ;
|
||||
if (! thisfsa->oldtop) return(FALSE) ;
|
||||
savefsa = m_stacktop->fsastack ;
|
||||
|
||||
/* Check possibility of starting a new branch*/
|
||||
m_stacktop->fsastack =
|
||||
(M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
|
||||
m_stacktop->fsastack->oldtop = thisfsa->oldtop ;
|
||||
m_stacktop->fsastack->andgroup = M_NULLVAL ;
|
||||
m_stacktop->fsastack->usedand = NULL ;
|
||||
newgroup = (M_ANDLIST *) m_malloc(sizeof(M_ANDLIST), "and list") ;
|
||||
newgroup->next = thisfsa->oldtop->usedand ;
|
||||
thisfsa->oldtop->usedand = newgroup ;
|
||||
for (pand = thisfsa->oldtop->andgroup ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
for (plist = newgroup->next ; plist ; plist = plist->next)
|
||||
if (pand == plist->group) break ;
|
||||
if (! plist) {
|
||||
newgroup->group = pand ;
|
||||
m_stacktop->fsastack->current = m_andgroup[pand - 1].start ;
|
||||
if (! m_state[m_stacktop->fsastack->current - 1].final)
|
||||
required = TRUE ;
|
||||
if (m_transition(label, FALSE)) {
|
||||
for (fsa = savefsa ; TRUE ; fsa = fsa->oldtop) {
|
||||
for (plist = fsa->usedand ; plist ; plist = plist->next)
|
||||
m_free(plist, "and list") ;
|
||||
if (fsa == thisfsa) {
|
||||
m_free(fsa, "FSA") ;
|
||||
break;
|
||||
}
|
||||
m_free(fsa, "FSA") ;
|
||||
}
|
||||
return(TRUE) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Couldn't start a new branch. Restore parse stack */
|
||||
thisfsa->oldtop->usedand = newgroup->next ;
|
||||
m_free(newgroup, "and list") ;
|
||||
m_free(m_stacktop->fsastack, "FSA") ;
|
||||
m_stacktop->fsastack = savefsa ;
|
||||
|
||||
/* Have all required branches occurred? */
|
||||
if (required) return(FALSE) ;
|
||||
|
||||
/* Can we continue past this and-group in a containing seq-group? */
|
||||
m_stacktop->fsastack =
|
||||
(M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
|
||||
m_stacktop->fsastack->oldtop = thisfsa->oldtop->oldtop ;
|
||||
m_stacktop->fsastack->andgroup = M_NULLVAL ;
|
||||
m_stacktop->fsastack->usedand = NULL ;
|
||||
m_stacktop->fsastack->current = thisfsa->oldtop->current ;
|
||||
if (m_transition(label, FALSE)) {
|
||||
/* Free temporary FSA storage used to test transition */
|
||||
for (fsa = savefsa, last = FALSE ; TRUE ; fsa = fsa->oldtop) {
|
||||
for (plist = fsa->usedand ; plist ; plist = plist->next)
|
||||
m_free(plist, "and list") ;
|
||||
m_free(fsa, "FSA") ;
|
||||
if (last) break ;
|
||||
if (fsa == thisfsa) last = TRUE ;
|
||||
}
|
||||
return(TRUE) ;
|
||||
}
|
||||
m_free(m_stacktop->fsastack, "FSA") ;
|
||||
m_stacktop->fsastack = savefsa ;
|
||||
|
||||
/* Can we continue in a containing and-group? */
|
||||
if (m_nextand(thisfsa->oldtop, label)) return(TRUE) ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Pops the parse stack*/
|
||||
void m_pop(M_NOPAR)
|
||||
{
|
||||
M_PARSE *stackelt ;
|
||||
|
||||
if (! m_stacktop->oldtop) {
|
||||
m_error("Program error: attempt to pop empty stack") ;
|
||||
m_exit(TRUE) ;
|
||||
}
|
||||
|
||||
if (m_stacktop->map && m_stacktop->map != m_stacktop->oldtop->map)
|
||||
m_free(m_stacktop->map, "short reference map") ;
|
||||
m_freeparam(m_stacktop) ;
|
||||
m_freeFSA(m_stacktop) ;
|
||||
|
||||
if (m_stacktop->neednet) m_netlevel-- ;
|
||||
stackelt = m_stacktop ;
|
||||
m_stacktop = stackelt->oldtop ;
|
||||
m_free(stackelt, "stack element") ;
|
||||
}
|
||||
|
||||
/* Pushes a new item onto the parse stack, setting its element, current,
|
||||
and neednet fields as indicated by the parameters*/
|
||||
#if defined(M_PROTO)
|
||||
void m_push(M_ELEMENT elt, M_STATE current, LOGICAL need)
|
||||
#else
|
||||
void m_push(elt, current, need)
|
||||
M_ELEMENT elt ;
|
||||
M_STATE current ;
|
||||
LOGICAL need ;
|
||||
#endif
|
||||
{
|
||||
M_PARSE *newstack ;
|
||||
|
||||
m_aftereod = FALSE ;
|
||||
newstack = (M_PARSE *) m_malloc(sizeof(M_PARSE), "stack element") ;
|
||||
newstack->oldtop = m_stacktop ;
|
||||
newstack->element = elt ;
|
||||
newstack->param = NULL ;
|
||||
if (m_element[elt - 1].content == M_REGEXP) {
|
||||
newstack->fsastack = (M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
|
||||
newstack->fsastack->oldtop = NULL ;
|
||||
newstack->fsastack->current = current ;
|
||||
newstack->fsastack->andgroup = M_NULLVAL ;
|
||||
newstack->fsastack->usedand = NULL ;
|
||||
}
|
||||
else newstack->fsastack = NULL ;
|
||||
newstack->thisent = 0 ;
|
||||
newstack->neednet = need ;
|
||||
newstack->firstre = FALSE ;
|
||||
newstack->contextual = TRUE ;
|
||||
newstack->intext = FALSE ;
|
||||
newstack->linestat = M_NOTHING ;
|
||||
newstack->holdre = FALSE ;
|
||||
newstack->map = m_stacktop->map ;
|
||||
newstack->cdcase = m_stacktop->cdcase ;
|
||||
newstack->picase = m_stacktop->picase ;
|
||||
newstack->stccase = m_stacktop->stccase ;
|
||||
newstack->cdparam = m_stacktop->cdparam ;
|
||||
newstack->piparam = m_stacktop->piparam ;
|
||||
newstack->stparam = m_stacktop->stparam ;
|
||||
newstack->file = m_stacktop->file ;
|
||||
newstack->line = m_stacktop->line ;
|
||||
newstack->ifdata = NULL ;
|
||||
m_stacktop = newstack ;
|
||||
if (m_element[elt - 1].srefptr)
|
||||
m_setmap(m_element[elt - 1].srefptr,
|
||||
(LOGICAL) m_element[elt - 1].useoradd) ;
|
||||
}
|
||||
|
||||
/* Process first character of a segment of character data. The first
|
||||
character is treated differently so that if character data is not
|
||||
allowed in the current context, an error message is issued with the
|
||||
first character only and not with every character. */
|
||||
void m_strtcdata(scanval)
|
||||
int scanval ;
|
||||
{
|
||||
if (! m_strtproc(M_NULLVAL))
|
||||
if (m_whitespace((M_WCHAR) scanval)) {
|
||||
m_curcon = m_prevcon ;
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
if (m_stacktop->oldtop) {
|
||||
m_err1("Data characters not allowed at this point in %s",
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_expecting() ;
|
||||
m_showcurelt() ;
|
||||
}
|
||||
else if (! m_start) {
|
||||
m_error("Document may not start with data characters") ;
|
||||
m_expecting() ;
|
||||
}
|
||||
}
|
||||
m_start = TRUE ;
|
||||
m_textaction((M_WCHAR) scanval) ;
|
||||
m_stacktop->firstre = TRUE ;
|
||||
m_stacktop->intext = TRUE ;
|
||||
}
|
||||
|
||||
/* M_strtproc checks that the next starttag or beginning of the next
|
||||
#PCDATA segment is valid, processing omitted start and endtags as needed.
|
||||
(Since m_endtag may reset the current context if the stack is popped down
|
||||
to an element that was within #PCDATA, m_strtproc saves the current context
|
||||
and restores it after returning from the last call to m_endtag.)
|
||||
*/
|
||||
LOGICAL m_strtproc(scanval)
|
||||
M_ELEMENT scanval ;
|
||||
{
|
||||
int check ;
|
||||
M_PARSE *original ;
|
||||
int savecontext ;
|
||||
int savenet ;
|
||||
M_PARSE *savestack ;
|
||||
M_PARSE *starttagomit ;
|
||||
M_MIN *min ;
|
||||
M_MIN *discard ;
|
||||
|
||||
/* The algorithms used here involve making a copy of the stack entry
|
||||
at the top of the stack before testing for the possibility of
|
||||
start-tag omission. Values of cdparam, piparam, and stparam
|
||||
are not used while testing for markup minimization and therefore
|
||||
are not set. However, the original entry and the copy may differ
|
||||
in the accuracy of these values, so care must be taken to keep
|
||||
the version in which they are correct when the stack is manipulated
|
||||
for the final time */
|
||||
|
||||
/* Is scanval allowed without tag omission? */
|
||||
savestack = m_stacktop ;
|
||||
original = m_stacktop ;
|
||||
m_stacktop = m_copystackelt() ;
|
||||
if (check = m_checkstart(scanval)) {
|
||||
if (scanval && m_stacktop->holdre && check != M_NONCONTEXTUAL) {
|
||||
m_freeFSA(m_stacktop) ;
|
||||
m_free(m_stacktop, "stack element") ;
|
||||
m_stacktop = original ;
|
||||
m_holdproc() ;
|
||||
return(m_strtproc(scanval)) ;
|
||||
}
|
||||
m_freeFSA(m_stacktop) ;
|
||||
m_free(m_stacktop, "stack element") ;
|
||||
m_stacktop = original ;
|
||||
if (scanval && check != M_NONCONTEXTUAL) {
|
||||
m_stacktop->linestat = M_DCORCET ;
|
||||
m_stacktop->firstre = TRUE ;
|
||||
}
|
||||
m_strttag(scanval, m_scannet) ;
|
||||
if (check == M_NONCONTEXTUAL) m_stacktop->contextual = FALSE ;
|
||||
else if (scanval) m_stacktop->oldtop->intext = FALSE ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
|
||||
/* Check for start- and end-tag omission */
|
||||
savecontext = m_curcon ;
|
||||
savenet = m_netlevel ;
|
||||
m_minstart = m_minend = NULL ;
|
||||
m_nextms = &m_minstart ;
|
||||
m_nextme = &m_minend ;
|
||||
starttagomit = m_stacktop ;
|
||||
while (TRUE) {
|
||||
if (m_omitstart()) {
|
||||
if (check = m_checkstart(scanval)) break ;
|
||||
else continue ;
|
||||
}
|
||||
m_freemin(m_minstart, "start-tag minimization") ;
|
||||
m_minstart = NULL ;
|
||||
m_nextms = &m_minstart ;
|
||||
while (m_stacktop != starttagomit) m_pop() ;
|
||||
m_freeFSA(m_stacktop) ;
|
||||
m_free(m_stacktop, "stack element") ;
|
||||
m_stacktop = original ;
|
||||
if (m_omitend()) {
|
||||
original = m_stacktop->oldtop ;
|
||||
m_stacktop = m_stacktop->oldtop ;
|
||||
m_stacktop = m_copystackelt() ;
|
||||
starttagomit = m_stacktop ;
|
||||
if (check = m_checkstart(scanval)) break ;
|
||||
else continue ;
|
||||
}
|
||||
m_freemin(m_minend, "end-tag minimization") ;
|
||||
m_freemin(m_minstart, "start-tag minimization") ;
|
||||
m_stacktop = savestack ;
|
||||
m_netlevel = savenet ;
|
||||
m_curcon = savecontext ;
|
||||
return(FALSE) ;
|
||||
}
|
||||
|
||||
/* Have determined a sequence of omitted tags. Process them */
|
||||
/* Undo all stack changes that were made tentatively, so they can
|
||||
be redone with invocation of interface as appropriate */
|
||||
while (m_stacktop != starttagomit) m_pop() ;
|
||||
m_freeFSA(m_stacktop) ;
|
||||
m_free(m_stacktop, "stack element") ;
|
||||
m_stacktop = savestack ;
|
||||
m_netlevel = savenet ;
|
||||
if (m_minend) m_stacktop->holdre = FALSE ;
|
||||
else if (m_stacktop->holdre && check != M_NONCONTEXTUAL) {
|
||||
m_freemin(m_minstart, "start-tag minimization") ;
|
||||
m_holdproc() ;
|
||||
if (scanval) return(m_strtproc(scanval)) ;
|
||||
else return(TRUE) ;
|
||||
}
|
||||
for (min = m_minend ; min ;) {
|
||||
if (m_stacktop->neednet) {
|
||||
M_WCHAR *wc_net;
|
||||
|
||||
wc_net = MakeWideCharString(m_net);
|
||||
m_err2("Expecting %s to end %s",
|
||||
wc_net,
|
||||
m_nameofelt(m_stacktop->element)) ;
|
||||
m_free(wc_net,"wide character string");
|
||||
m_showcurelt() ;
|
||||
}
|
||||
if (! m_element[m_stacktop->element - 1].emin) {
|
||||
m_err1("Missing end tag for %s", m_nameofelt(m_stacktop->element)) ;
|
||||
m_showcurelt() ;
|
||||
}
|
||||
m_endtag(min->val) ;
|
||||
discard = min ;
|
||||
min = min->next ;
|
||||
m_free(discard, "end-tag minimization") ;
|
||||
}
|
||||
for (min = m_minstart ; min ;) {
|
||||
m_checkstart(min->val) ;
|
||||
m_strttag(min->val, FALSE) ;
|
||||
if (! m_element[min->val - 1].smin)
|
||||
m_err1("Missing start tag for %s", m_nameofelt(min->val)) ;
|
||||
m_stkdefaultparams() ;
|
||||
discard = min ;
|
||||
min = min->next ;
|
||||
m_free(discard, "start-tag minimization") ;
|
||||
}
|
||||
check = m_checkstart(scanval) ;
|
||||
if (scanval && check != M_NONCONTEXTUAL) {
|
||||
m_stacktop->linestat = M_DCORCET ;
|
||||
m_stacktop->firstre = TRUE ;
|
||||
}
|
||||
m_strttag(scanval, m_scannet) ;
|
||||
if (check == M_NONCONTEXTUAL) m_stacktop->contextual = FALSE ;
|
||||
else if (scanval) m_stacktop->oldtop->intext = FALSE ;
|
||||
m_curcon = savecontext ;
|
||||
if (m_element[m_stacktop->element - 1].content == M_CDATA)
|
||||
m_curcon = CDATAEL ;
|
||||
if (m_element[m_stacktop->element - 1].content == M_RCDATA) {
|
||||
m_curcon = RCDATAEL ;
|
||||
m_stacktop->thisent = m_eopencnt ;
|
||||
}
|
||||
return(TRUE) ;
|
||||
}
|
||||
|
||||
/* Processes explicit or implied start tag*/
|
||||
#if defined(M_PROTO)
|
||||
void m_strttag(M_ELEMENT val, LOGICAL net)
|
||||
#else
|
||||
void m_strttag(val, net)
|
||||
M_ELEMENT val ;
|
||||
LOGICAL net ;
|
||||
#endif
|
||||
{
|
||||
m_transition(val, TRUE) ;
|
||||
if (val) {
|
||||
m_push(val, m_element[val - 1].start, net) ;
|
||||
if (net) m_netlevel++ ;
|
||||
if (m_element[val - 1].content == M_CDATA ||
|
||||
m_element[val - 1].content == M_RCDATA) {
|
||||
m_stacktop->intext = TRUE ;
|
||||
m_curcon = m_element[val - 1].content == M_CDATA ?
|
||||
CDATAEL : RCDATAEL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns indication of whether or not parsed data characters are allowed
|
||||
(without tag minimization) in the current context. Used to distinguish
|
||||
mixed content from element content. (Assuming the definition of
|
||||
mixed content is a context where #PCDATA can occur, not that the current
|
||||
content model contains #PCDATA at some point. The former definition
|
||||
makes more sense, is used by MARKUP, and is under consideration by the
|
||||
Standards committee; the latter is the current definition in the Standard
|
||||
*/
|
||||
LOGICAL m_textpermitted(M_NOPAR)
|
||||
{
|
||||
M_ANDGROUP pand ;
|
||||
M_OPENFSA *fsastack ;
|
||||
M_ANDLIST *usedand ;
|
||||
LOGICAL morebranches = FALSE ;
|
||||
|
||||
if (! m_stacktop->oldtop) return(FALSE) ;
|
||||
/* If element has declared content (other than EMPTY), data is allowed.
|
||||
But EMPTY elements don't stay on the stack long enough to call this
|
||||
function */
|
||||
if (m_element[m_stacktop->element - 1].content != M_REGEXP) return(TRUE) ;
|
||||
/* If within #PCDATA, more text can be entered */
|
||||
if (m_stacktop->intext) return(TRUE) ;
|
||||
/* If current state emits an arc labelled #PCDATA, text can be
|
||||
entered */
|
||||
for (fsastack = m_stacktop->fsastack ;
|
||||
fsastack ;
|
||||
fsastack = fsastack->oldtop) {
|
||||
for (pand = fsastack->andgroup ;
|
||||
pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
for (usedand = fsastack->usedand ;
|
||||
usedand ;
|
||||
usedand = usedand->next)
|
||||
if (usedand->group == pand) break ;
|
||||
if (! usedand) {
|
||||
if (m_state[m_andgroup[pand - 1].start - 1].datacontent)
|
||||
return(TRUE) ;
|
||||
if (! m_state[m_andgroup[pand - 1].start - 1].final)
|
||||
morebranches = TRUE ;
|
||||
}
|
||||
}
|
||||
if (morebranches) return(FALSE) ;
|
||||
if (m_state[fsastack->current - 1].datacontent) return(TRUE) ;
|
||||
if (! m_state[fsastack->current - 1].final) return(FALSE) ;
|
||||
}
|
||||
return(FALSE) ;
|
||||
} /* End m_textpermitted() */
|
||||
|
||||
/* Returns TRUE iff LABEL allowed in the current state of the current
|
||||
element (without expanding any minimization). May result in changes
|
||||
to the stack of FSA's for this element if and-groups open or close. */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL m_transition(M_ELEMENT label, LOGICAL recur)
|
||||
#else
|
||||
LOGICAL m_transition(label, recur)
|
||||
M_ELEMENT label ;
|
||||
LOGICAL recur ;
|
||||
#endif
|
||||
{
|
||||
M_ARC parc ;
|
||||
M_OPENFSA *newfsa ;
|
||||
M_ANDGROUP pand ;
|
||||
|
||||
if (m_stacktop->oldtop &&
|
||||
m_element[m_stacktop->element - 1].content != M_REGEXP)
|
||||
return(FALSE) ;
|
||||
for (parc = m_state[m_stacktop->fsastack->current - 1].first ;
|
||||
parc ;
|
||||
parc = m_arc[parc - 1].next) {
|
||||
if (m_arc[parc - 1].group) {
|
||||
newfsa = (M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
|
||||
newfsa->oldtop = m_stacktop->fsastack ;
|
||||
newfsa->andgroup = M_NULLVAL ;
|
||||
newfsa->usedand = NULL ;
|
||||
m_stacktop->fsastack = newfsa ;
|
||||
for (pand = m_arc[parc - 1].group ; pand ;
|
||||
pand = m_andgroup[pand - 1].next) {
|
||||
newfsa->current = m_andgroup[pand - 1].start ;
|
||||
if (m_transition(label, FALSE)) {
|
||||
newfsa->oldtop->andgroup = m_arc[parc - 1].group ;
|
||||
newfsa->oldtop->usedand =
|
||||
(M_ANDLIST *) m_malloc(sizeof(M_ANDLIST), "and list") ;
|
||||
newfsa->oldtop->usedand->group = pand ;
|
||||
newfsa->oldtop->usedand->next = NULL ;
|
||||
newfsa->oldtop->current = m_arc[parc - 1].to ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
}
|
||||
m_stacktop->fsastack = newfsa->oldtop ;
|
||||
m_free(newfsa, "FSA") ;
|
||||
}
|
||||
else if (label == m_arc[parc - 1].label) {
|
||||
m_stacktop->fsastack->current = m_arc[parc - 1].to ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
} /* End for parc */
|
||||
if (recur && m_nextand(m_stacktop->fsastack, label)) return(TRUE) ;
|
||||
return(FALSE) ;
|
||||
} /* End transition */
|
||||
|
||||
266
cde/programs/dthelp/parser/pass2/parser/tex.h
Normal file
266
cde/programs/dthelp/parser/pass2/parser/tex.h
Normal file
@@ -0,0 +1,266 @@
|
||||
/* $XConsortium: tex.h /main/3 1995/11/08 11:00:13 rswiston $ */
|
||||
EXTERN char *special[256]
|
||||
#if defined(DEFINE)
|
||||
= {
|
||||
/* Char Name TeX Expansion */
|
||||
/* */
|
||||
/* 0: ^@ NUL */ 0,
|
||||
/* 1: ^A SOH */ 0,
|
||||
/* 2: ^B STX */ 0,
|
||||
/* 3: ^C ETX */ 0,
|
||||
/* 4: ^D EOT */ 0,
|
||||
/* 5: ^E ENQ */ 0,
|
||||
/* 6: ^F ACK */ 0,
|
||||
/* 7: ^G BEL */ 0,
|
||||
/* 8: ^H BS */ 0,
|
||||
/* 9: ^I HT */ 0,
|
||||
/* 10: ^J LF */ 0,
|
||||
/* 11: ^K VT */ 0,
|
||||
/* 12: ^L FF */ 0,
|
||||
/* 13: ^M CR */ 0,
|
||||
/* 14: ^N SO */ 0,
|
||||
/* 15: ^O SI */ 0,
|
||||
/* 16: ^P DLE */ 0,
|
||||
/* 17: ^Q DC1 */ 0,
|
||||
/* 18: ^R DC2 */ 0,
|
||||
/* 19: ^S DC3 */ 0,
|
||||
/* 20: ^T DC4 */ 0,
|
||||
/* 21: ^U NAK */ 0,
|
||||
/* 22: ^V SYN */ 0,
|
||||
/* 23: ^W ETB */ 0,
|
||||
/* 24: ^X CAN */ 0,
|
||||
/* 25: ^Y EM */ 0,
|
||||
/* 26: ^Z SUB */ 0,
|
||||
/* 27: ^[ ESC */ 0,
|
||||
/* 28: ^\ FS */ 0,
|
||||
/* 29: ^] GS */ 0,
|
||||
/* 30: ^^ RS */ 0,
|
||||
/* 31: ^_ US */ 0,
|
||||
/* 32: SP */ 0,
|
||||
/* 33: ! */ 0,
|
||||
/* 34: " */ 0,
|
||||
/* 35: # */ "\\#",
|
||||
/* 36: $ */ "{\\dollar}",
|
||||
/* 37: % */ "\\%",
|
||||
/* 38: & */ "\\&",
|
||||
/* 39: ' */ "{'}",
|
||||
/* 40: ( */ 0,
|
||||
/* 41: ) */ 0,
|
||||
/* 42: * */ 0,
|
||||
/* 43: + */ 0,
|
||||
/* 44: , */ 0,
|
||||
/* 45: - */ "{-}",
|
||||
/* 46: . */ 0,
|
||||
/* 47: / */ 0,
|
||||
/* 48: 0 */ 0,
|
||||
/* 49: 1 */ 0,
|
||||
/* 50: 2 */ 0,
|
||||
/* 51: 3 */ 0,
|
||||
/* 52: 4 */ 0,
|
||||
/* 53: 5 */ 0,
|
||||
/* 54: 6 */ 0,
|
||||
/* 55: 7 */ 0,
|
||||
/* 56: 8 */ 0,
|
||||
/* 57: 9 */ 0,
|
||||
/* 58: : */ 0,
|
||||
/* 59: ; */ 0,
|
||||
/* 60: < */ "{\\lthan}",
|
||||
/* 61: = */ 0,
|
||||
/* 62: > */ "{\\gthan}",
|
||||
/* 63: ? */ 0,
|
||||
/* 64: @ */ 0,
|
||||
/* 65: A */ 0,
|
||||
/* 66: B */ 0,
|
||||
/* 67: C */ 0,
|
||||
/* 68: D */ 0,
|
||||
/* 69: E */ 0,
|
||||
/* 70: F */ 0,
|
||||
/* 71: G */ 0,
|
||||
/* 72: H */ 0,
|
||||
/* 73: I */ 0,
|
||||
/* 74: J */ 0,
|
||||
/* 75: K */ 0,
|
||||
/* 76: L */ 0,
|
||||
/* 77: M */ 0,
|
||||
/* 78: N */ 0,
|
||||
/* 79: O */ 0,
|
||||
/* 80: P */ 0,
|
||||
/* 81: Q */ 0,
|
||||
/* 82: R */ 0,
|
||||
/* 83: S */ 0,
|
||||
/* 84: T */ 0,
|
||||
/* 85: U */ 0,
|
||||
/* 86: V */ 0,
|
||||
/* 87: W */ 0,
|
||||
/* 88: X */ 0,
|
||||
/* 89: Y */ 0,
|
||||
/* 90: Z */ 0,
|
||||
/* 91: [ */ 0,
|
||||
/* 92: \\ */ "{\\bslash}",
|
||||
/* 93: ] */ 0,
|
||||
/* 94: ^ */ "\\string^",
|
||||
/* 95: _ */ "{\\under}",
|
||||
/* 96: ` */ "{`}",
|
||||
/* 97: a */ 0,
|
||||
/* 98: b */ 0,
|
||||
/* 99: c */ 0,
|
||||
/* 100: d */ 0,
|
||||
/* 101: e */ 0,
|
||||
/* 102: f */ 0,
|
||||
/* 103: g */ 0,
|
||||
/* 104: h */ 0,
|
||||
/* 105: i */ 0,
|
||||
/* 106: j */ 0,
|
||||
/* 107: k */ 0,
|
||||
/* 108: l */ 0,
|
||||
/* 109: m */ 0,
|
||||
/* 110: n */ 0,
|
||||
/* 111: o */ 0,
|
||||
/* 112: p */ 0,
|
||||
/* 113: q */ 0,
|
||||
/* 114: r */ 0,
|
||||
/* 115: s */ 0,
|
||||
/* 116: t */ 0,
|
||||
/* 117: u */ 0,
|
||||
/* 118: v */ 0,
|
||||
/* 119: w */ 0,
|
||||
/* 120: x */ 0,
|
||||
/* 121: y */ 0,
|
||||
/* 122: z */ 0,
|
||||
/* 123: { */ "{\\lbrac}",
|
||||
/* 124: | */ "{\\vbar}",
|
||||
/* 125: } */ "{\\rbrac}",
|
||||
/* 126: ~ */ "\\string~",
|
||||
/* 127: DEL */ 0,
|
||||
/* 128: undefined */ 0,
|
||||
/* 129: undefined */ 0,
|
||||
/* 130: undefined */ 0,
|
||||
/* 131: undefined */ 0,
|
||||
/* 132: undefined */ 0,
|
||||
/* 133: undefined */ 0,
|
||||
/* 134: undefined */ 0,
|
||||
/* 135: undefined */ 0,
|
||||
/* 136: undefined */ 0,
|
||||
/* 137: undefined */ 0,
|
||||
/* 138: undefined */ 0,
|
||||
/* 139: undefined */ 0,
|
||||
/* 140: undefined */ 0,
|
||||
/* 141: undefined */ 0,
|
||||
/* 142: undefined */ 0,
|
||||
/* 143: undefined */ 0,
|
||||
/* 144: undefined */ 0,
|
||||
/* 145: undefined */ 0,
|
||||
/* 146: undefined */ 0,
|
||||
/* 147: undefined */ 0,
|
||||
/* 148: undefined */ 0,
|
||||
/* 149: undefined */ 0,
|
||||
/* 150: undefined */ 0,
|
||||
/* 151: undefined */ 0,
|
||||
/* 152: undefined */ 0,
|
||||
/* 153: undefined */ 0,
|
||||
/* 154: undefined */ 0,
|
||||
/* 155: undefined */ 0,
|
||||
/* 156: undefined */ 0,
|
||||
/* 157: undefined */ 0,
|
||||
/* 158: undefined */ 0,
|
||||
/* 159: undefined */ 0,
|
||||
/* 160: undefined */ 0,
|
||||
/* 161: A grave */ "\\`A",
|
||||
/* 162: A circumflex */ "\\^A",
|
||||
/* 163: E grave */ "\\`E",
|
||||
/* 164: E circumflex */ "\\^E",
|
||||
/* 165: E dieresis */ "\\\042E",
|
||||
/* 166: I circumflex */ "\\^I",
|
||||
/* 167: I dieresis */ "\\\042I",
|
||||
/* 168: acute accent */ "\\'{ }",
|
||||
/* 169: grave accent */ "\\`{ }",
|
||||
/* 170: circumflex */ "\\^{ }",
|
||||
/* 171: dieresis */ "\\\042{ }",
|
||||
/* 172: tilde */ "\\~{ }",
|
||||
/* 173: U grave */ "\\`U",
|
||||
/* 174: U circumflex */ "\\^U",
|
||||
/* 175: Italian Lira */ 0,
|
||||
/* 176: overbar */ 0,
|
||||
/* 177: Y acute */ "\\'Y",
|
||||
/* 178: y acute */ "\\'y",
|
||||
/* 179: degree */ 0,
|
||||
/* 180: C cedilla */ "\\c{C}",
|
||||
/* 181: c cedilla */ "\\c{c}",
|
||||
/* 182: N tilde */ "\\~N",
|
||||
/* 183: n tilde */ "\\~n",
|
||||
/* 184: inverted exclamation mark */ "{!`}",
|
||||
/* 185: inverted question mark */ "{?`}",
|
||||
/* 186: currency sign */ 0,
|
||||
/* 187: pound sterling */ 0,
|
||||
/* 188: Yen */ 0,
|
||||
/* 189: Section sign */ 0,
|
||||
/* 190: florin */ 0,
|
||||
/* 191: Cent sign */ 0,
|
||||
/* 192: a circumflex */ "\\^a",
|
||||
/* 193: e circumflex */ "\\^e",
|
||||
/* 194: o circumflex */ "\\^o",
|
||||
/* 195: u circumflex */ "\\^u",
|
||||
/* 196: a acute */ "\\'a",
|
||||
/* 197: e acute */ "\\'e",
|
||||
/* 198: o acute */ "\\'o",
|
||||
/* 199: u acute */ "\\'u",
|
||||
/* 200: a grave */ "\\`a",
|
||||
/* 201: e grave */ "\\`e",
|
||||
/* 202: o grave */ "\\`o",
|
||||
/* 203: u grave */ "\\`u",
|
||||
/* 204: a dieresis */ "\\\042a",
|
||||
/* 205: e dieresis */ "\\\042e",
|
||||
/* 206: o dieresis */ "\\\042o",
|
||||
/* 207: u dieresis */ "\\\042u",
|
||||
/* 208: A angstrom */ "{\\AA}",
|
||||
/* 209: i circumflex */ "{\\^\\i}",
|
||||
/* 210: O slash */ "{\\O}",
|
||||
/* 211: AE ligature */ "{\\AE}",
|
||||
/* 212: a angstrom */ "{\\aa}",
|
||||
/* 213: i acute */ "{\\'\\i}",
|
||||
/* 214: o slash */ "{\\o}",
|
||||
/* 215: ae ligature */ "{\\ae}",
|
||||
/* 216: A dieresis */ "\\\042A",
|
||||
/* 217: i grave */ "{\\`\\i}",
|
||||
/* 218: O dieresis */ "\\\042O",
|
||||
/* 219: U dieresis */ "\\\042U",
|
||||
/* 220: E acute */ "\\'E",
|
||||
/* 221: i dieresis */ "{\\\042\\i}",
|
||||
/* 222: SS ligature */ "{\\ss}",
|
||||
/* 223: O circumflex */ "\\^O",
|
||||
/* 224: A acute */ "\\'A",
|
||||
/* 225: A tilde */ "\\~A",
|
||||
/* 226: a tilde */ "\\~a",
|
||||
/* 227: Eth */ 0,
|
||||
/* 228: eth */ 0,
|
||||
/* 229: I acute */ "\\'I",
|
||||
/* 230: I grave */ "\\`I",
|
||||
/* 231: O acute */ "\\'O",
|
||||
/* 232: O grave */ "\\`O",
|
||||
/* 233: O tilde */ "\\~O",
|
||||
/* 234: o tilde */ "\\~o",
|
||||
/* 235: S caron */ "\\v{S}",
|
||||
/* 236: s caron */ "\\v{s}",
|
||||
/* 237: U acute */ "\\'U",
|
||||
/* 238: Y dieresis */ "\\\042Y",
|
||||
/* 239: y dieresis */ "\\\042y",
|
||||
/* 240: Thorn */ 0,
|
||||
/* 241: thorn */ 0,
|
||||
/* 242: undefined */ 0,
|
||||
/* 243: mu */ 0,
|
||||
/* 244: paragraph sign */ 0,
|
||||
/* 245: fraction 3/4 */ 0,
|
||||
/* 246: long dash */ 0,
|
||||
/* 247: fraction 1/4 */ 0,
|
||||
/* 248: fraction 1/2 */ 0,
|
||||
/* 249: Female ordinal */ 0,
|
||||
/* 250: Male ordinal */ 0,
|
||||
/* 251: French double open quote */ 0,
|
||||
/* 252: Solid square */ 0,
|
||||
/* 253: French double close quote */ 0,
|
||||
/* 254: Plus over minus sign */ 0,
|
||||
/* 255: undefined */ 0
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
53
cde/programs/dthelp/parser/pass2/parser/text.c
Normal file
53
cde/programs/dthelp/parser/pass2/parser/text.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/* $XConsortium: text.c /main/3 1995/11/08 11:00:29 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Text.c executes text-code specified in the interface. */
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Include generated file */
|
||||
#include "tfile.c"
|
||||
|
||||
/* When a text character occurs */
|
||||
#if defined(M_PROTO)
|
||||
void m_textaction(M_WCHAR m_textchar)
|
||||
#else
|
||||
void m_textaction(m_textchar)
|
||||
M_WCHAR m_textchar ;
|
||||
#endif
|
||||
{
|
||||
char buffer[10] ;
|
||||
char mb_re;
|
||||
M_WCHAR wc_re;
|
||||
|
||||
mb_re = M_RE;
|
||||
mbtowc(&wc_re, &mb_re, 1);
|
||||
|
||||
if (m_stacktop->holdre) {
|
||||
m_stacktop->holdre = FALSE ;
|
||||
m_textaction(wc_re) ;
|
||||
}
|
||||
if (m_cdtrace) {
|
||||
m_trace("Text character '") ;
|
||||
buffer[0] = m_textchar ;
|
||||
buffer[1] = M_EOS ;
|
||||
m_trace(buffer) ;
|
||||
m_trace("' (") ;
|
||||
sprintf(buffer, "%d", m_textchar) ;
|
||||
m_trace(buffer) ;
|
||||
m_trace(")\n") ;
|
||||
}
|
||||
if (m_tagtrace)
|
||||
m_toptstat = m_textchar == M_SPACE || m_textchar == M_TAB ?
|
||||
M_WHITESPACE : M_OTHER ;
|
||||
if (m_textchar != wc_re) m_stacktop->linestat = M_DCORCET ;
|
||||
m_stackpar = m_stacktop->cdparam ;
|
||||
(*m_ttable[m_stacktop->cdcase])(m_textchar) ;
|
||||
}
|
||||
|
||||
|
||||
24
cde/programs/dthelp/parser/pass2/parser/trace.c
Normal file
24
cde/programs/dthelp/parser/pass2/parser/trace.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* $XConsortium: trace.c /main/3 1995/11/08 11:00:43 rswiston $ */
|
||||
/*
|
||||
Copyright 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
#include "userinc.h"
|
||||
#include "globdec.h"
|
||||
|
||||
/* Write debugging trace information */
|
||||
void m_wctrace(p)
|
||||
M_WCHAR *p ;
|
||||
{
|
||||
char *mb_p;
|
||||
|
||||
mb_p = MakeMByteString(p);
|
||||
fputs(mb_p, m_outfile) ;
|
||||
m_free(mb_p,"multi-byte string");
|
||||
}
|
||||
|
||||
void m_trace(p)
|
||||
char *p ;
|
||||
{
|
||||
fputs(p, m_outfile);
|
||||
}
|
||||
15
cde/programs/dthelp/parser/pass2/parser/userinc.h
Normal file
15
cde/programs/dthelp/parser/pass2/parser/userinc.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* $XConsortium: userinc.h /main/3 1995/11/08 11:00:58 rswiston $ */
|
||||
/* Copyright 1988, 1989 Hewlett-Packard Co. */
|
||||
|
||||
/* Header files for interface code files */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
#include "dtdext.h"
|
||||
#include "parser.h"
|
||||
#include "delim.h"
|
||||
#include "entext.h"
|
||||
#include "signonx.h"
|
||||
#include "pval.h"
|
||||
#include "version.h"
|
||||
47
cde/programs/dthelp/parser/pass2/util/Imakefile
Normal file
47
cde/programs/dthelp/parser/pass2/util/Imakefile
Normal file
@@ -0,0 +1,47 @@
|
||||
XCOMM $XConsortium: Imakefile /main/3 1995/11/08 11:01:32 rswiston $
|
||||
/* Util Imakefile */
|
||||
|
||||
INCLUDES = -I.
|
||||
|
||||
LIBSRCS = \
|
||||
allwhite.c inctest.c letter.c triedump.c triepdmp.c \
|
||||
trieplk.c trierset.c upcmp8.c upstrcmp.c wchar.c
|
||||
CTXSRCS = \
|
||||
conutil.c error.c exit.c itoa.c lower.c malloc.c openchk.c \
|
||||
trie.c triecnt.c upper.c whitesp.c
|
||||
OTHERSRCS = \
|
||||
context.c emptyfil.c fclndir.c
|
||||
SRCS = $(LIBSRCS) $(CTXSRCS) $(OTHERSRCS)
|
||||
|
||||
|
||||
LIBOBJS = \
|
||||
allwhite.o inctest.o letter.o triedump.o triepdmp.o \
|
||||
trieplk.o trierset.o upcmp8.o upstrcmp.o wchar.o
|
||||
CTXOBJS = \
|
||||
conutil.o error.o exit.o itoa.o lower.o malloc.o openchk.o \
|
||||
trie.o triecnt.o upper.o whitesp.o
|
||||
OTHEROBJS = \
|
||||
context.o fclndir.o emptyfil.o
|
||||
|
||||
LOCAL_LIBRARIES = libutil.a
|
||||
|
||||
/* Don't use shared libs for hp */
|
||||
#ifdef HPArchitecture
|
||||
#if OSMajorVersion > 7
|
||||
EXTRA_LOAD_FLAGS = -Wl,-a archive
|
||||
#endif
|
||||
#endif
|
||||
|
||||
all::
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(util,$(LIBOBJS) $(CTXOBJS))
|
||||
|
||||
all:: context fclndir
|
||||
|
||||
NormalProgramTarget(context,context.o,$(LOCAL_LIBRARIES),$(LOCAL_LIBRARIES),)
|
||||
NormalProgramTarget(fclndir,fclndir.o,$(LOCAL_LIBRARIES),$(LOCAL_LIBRARIES),)
|
||||
|
||||
DependTarget()
|
||||
|
||||
depend:: $(SRCS)
|
||||
32
cde/programs/dthelp/parser/pass2/util/allwhite.c
Normal file
32
cde/programs/dthelp/parser/pass2/util/allwhite.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* $XConsortium: allwhite.c /main/3 1995/11/08 11:01:49 rswiston $ */
|
||||
/*
|
||||
Copyright 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
#include "basic.h"
|
||||
|
||||
LOGICAL m_allwhite(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_whitespace(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
/* Test if a string contains only white space characters */
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL m_allwhite(const M_WCHAR *string )
|
||||
#else
|
||||
LOGICAL m_allwhite(string)
|
||||
M_WCHAR *string ;
|
||||
#endif /* M_PROTO */
|
||||
{
|
||||
const M_WCHAR *p ;
|
||||
|
||||
for (p = string; *p ; p++)
|
||||
if (! m_whitespace(*p)) return(FALSE) ;
|
||||
return(TRUE) ;
|
||||
}
|
||||
92
cde/programs/dthelp/parser/pass2/util/basic.h
Normal file
92
cde/programs/dthelp/parser/pass2/util/basic.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* $XConsortium: basic.h /main/3 1995/11/08 11:02:02 rswiston $ */
|
||||
/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
|
||||
/* Basic.h has a few very primitive #define's used by all MARKUP programs */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* hpux protects stdio.h from multiple includes thru stdlib.h . */
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
typedef unsigned char LOGICAL;
|
||||
|
||||
/* End of String marker */
|
||||
#define M_EOS '\0'
|
||||
|
||||
/* Integer null value marker */
|
||||
#define M_NULLVAL 0
|
||||
|
||||
/* 8-bit data characters */
|
||||
typedef unsigned char M_CHAR8;
|
||||
|
||||
/* wide characters */
|
||||
typedef wchar_t M_WCHAR;
|
||||
|
||||
/* For function prototypes */
|
||||
typedef char * M_POINTER;
|
||||
#if defined(hpux) || defined(__aix) || defined(sun) || defined(USL) || defined(__uxp__)
|
||||
/* Old unix stuff
|
||||
*#define void int
|
||||
*#define M_NOPAR
|
||||
*/
|
||||
/* New Ansi style */
|
||||
#define M_PROTO
|
||||
#define M_NOPAR void
|
||||
#else
|
||||
#define M_PROTO
|
||||
#define M_NOPAR void
|
||||
#endif
|
||||
|
||||
char *MakeMByteString(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *from
|
||||
#endif
|
||||
);
|
||||
|
||||
M_WCHAR *MakeWideCharString(
|
||||
#if defined(M_PROTO)
|
||||
const char *from
|
||||
#endif
|
||||
);
|
||||
|
||||
int w_strcmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string1, const M_WCHAR *string2
|
||||
#endif
|
||||
);
|
||||
|
||||
int w_strncmp(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string1, const M_WCHAR *string2, int max
|
||||
#endif
|
||||
);
|
||||
|
||||
M_WCHAR *w_strcpy(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string1, const M_WCHAR *string2
|
||||
#endif
|
||||
);
|
||||
|
||||
M_WCHAR *w_strncpy(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string1, const M_WCHAR *string2, int max
|
||||
#endif
|
||||
);
|
||||
|
||||
int w_strlen(
|
||||
#if defined(M_PROTO)
|
||||
const M_WCHAR *string
|
||||
#endif
|
||||
);
|
||||
|
||||
M_WCHAR *w_strchr(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string, const M_WCHAR chr
|
||||
#endif
|
||||
);
|
||||
|
||||
M_WCHAR *w_strstr(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR *string1, M_WCHAR *string2
|
||||
#endif
|
||||
);
|
||||
268
cde/programs/dthelp/parser/pass2/util/chartype.h
Normal file
268
cde/programs/dthelp/parser/pass2/util/chartype.h
Normal file
@@ -0,0 +1,268 @@
|
||||
/* $XConsortium: chartype.h /main/3 1995/11/08 11:02:16 rswiston $ */
|
||||
/* Copyright (c) 1988, 1989 Hewlett-Packard Co. */
|
||||
/* This table defines the subset of the HP Roman8 character set
|
||||
supported by HP Tag. Characters defined in Roman8 but not supported
|
||||
by HP Tag are marked "(invalid)". */
|
||||
|
||||
M_CHARTYPE m_ctarray[M_CHARSETLEN]
|
||||
= {
|
||||
/* Char Name Type, Upper, Lower */
|
||||
/* 0: ^@ NUL */ M_NONNAME, 0, 0,
|
||||
/* 1: ^A SOH */ M_NONNAME, 1, 1,
|
||||
/* 2: ^B STX */ M_NONNAME, 2, 2,
|
||||
/* 3: ^C ETX */ M_NONNAME, 3, 3,
|
||||
/* 4: ^D EOT */ M_NONNAME, 4, 4,
|
||||
/* 5: ^E ENQ */ M_NONNAME, 5, 5,
|
||||
/* 6: ^F ACK */ M_NONNAME, 6, 6,
|
||||
/* 7: ^G BEL */ M_NONNAME, 7, 7,
|
||||
/* 8: ^H BS */ M_NONNAME, 8, 8,
|
||||
/* 9: ^I HT */ M_NONNAME, 9, 9,
|
||||
/* 10: ^J LF */ M_NONNAME, 10, 10,
|
||||
/* 11: ^K VT */ M_NONNAME, 11, 11,
|
||||
/* 12: ^L FF */ M_NONNAME, 12, 12,
|
||||
/* 13: ^M CR */ M_NONNAME, 13, 13,
|
||||
/* 14: ^N SO */ M_NONNAME, 14, 14,
|
||||
/* 15: ^O SI */ M_NONNAME, 15, 15,
|
||||
/* 16: ^P DLE */ M_NONNAME, 16, 16,
|
||||
/* 17: ^Q DC1 */ M_NONNAME, 17, 17,
|
||||
/* 18: ^R DC2 */ M_NONNAME, 18, 18,
|
||||
/* 19: ^S DC3 */ M_NONNAME, 19, 19,
|
||||
/* 20: ^T DC4 */ M_NONNAME, 20, 20,
|
||||
/* 21: ^U NAK */ M_NONNAME, 21, 21,
|
||||
/* 22: ^V SYN */ M_NONNAME, 22, 22,
|
||||
/* 23: ^W ETB */ M_NONNAME, 23, 23,
|
||||
/* 24: ^X CAN */ M_NONNAME, 24, 24,
|
||||
/* 25: ^Y EM */ M_NONNAME, 25, 25,
|
||||
/* 26: ^Z SUB */ M_NONNAME, 26, 26,
|
||||
/* 27: ^[ ESC */ M_NONNAME, 27, 27,
|
||||
/* 28: ^\ FS */ M_NONNAME, 28, 28,
|
||||
/* 29: ^] GS */ M_NONNAME, 29, 29,
|
||||
/* 30: ^^ RS */ M_NONNAME, 30, 30,
|
||||
/* 31: ^_ US */ M_NONNAME, 31, 31,
|
||||
/* 32: SP */ M_NONNAME, 32, 32,
|
||||
/* 33: ! */ M_NONNAME, 33, 33,
|
||||
/* 34: " */ M_NONNAME, 34, 34,
|
||||
/* 35: # */ M_NONNAME, 35, 35,
|
||||
/* 36: $ */ M_NONNAME, 36, 36,
|
||||
/* 37: % */ M_NONNAME, 37, 37,
|
||||
/* 38: & */ M_NONNAME, 38, 38,
|
||||
/* 39: ' */ M_NONNAME, 39, 39,
|
||||
/* 40: ( */ M_NONNAME, 40, 40,
|
||||
/* 41: ) */ M_NONNAME, 41, 41,
|
||||
/* 42: * */ M_NONNAME, 42, 42,
|
||||
/* 43: + */ M_NAMECHAR, 43, 43,
|
||||
/* 44: , */ M_NONNAME, 44, 44,
|
||||
/* 45: - */ M_NAMECHAR, 45, 45,
|
||||
/* 46: . */ M_NAMECHAR, 46, 46,
|
||||
/* 47: / */ M_NONNAME, 47, 47,
|
||||
/* 48: 0 */ M_DIGIT, 48, 48,
|
||||
/* 49: 1 */ M_DIGIT, 49, 49,
|
||||
/* 50: 2 */ M_DIGIT, 50, 50,
|
||||
/* 51: 3 */ M_DIGIT, 51, 51,
|
||||
/* 52: 4 */ M_DIGIT, 52, 52,
|
||||
/* 53: 5 */ M_DIGIT, 53, 53,
|
||||
/* 54: 6 */ M_DIGIT, 54, 54,
|
||||
/* 55: 7 */ M_DIGIT, 55, 55,
|
||||
/* 56: 8 */ M_DIGIT, 56, 56,
|
||||
/* 57: 9 */ M_DIGIT, 57, 57,
|
||||
/* 58: : */ M_NONNAME, 58, 58,
|
||||
/* 59: ; */ M_NONNAME, 59, 59,
|
||||
/* 60: < */ M_NONNAME, 60, 60,
|
||||
/* 61: = */ M_NONNAME, 61, 61,
|
||||
/* 62: > */ M_NONNAME, 62, 62,
|
||||
/* 63: ? */ M_NONNAME, 63, 63,
|
||||
/* 64: @ */ M_NONNAME, 64, 64,
|
||||
/* 65: A */ M_NMSTART, 65, 97,
|
||||
/* 66: B */ M_NMSTART, 66, 98,
|
||||
/* 67: C */ M_NMSTART, 67, 99,
|
||||
/* 68: D */ M_NMSTART, 68, 100,
|
||||
/* 69: E */ M_NMSTART, 69, 101,
|
||||
/* 70: F */ M_NMSTART, 70, 102,
|
||||
/* 71: G */ M_NMSTART, 71, 103,
|
||||
/* 72: H */ M_NMSTART, 72, 104,
|
||||
/* 73: I */ M_NMSTART, 73, 105,
|
||||
/* 74: J */ M_NMSTART, 74, 106,
|
||||
/* 75: K */ M_NMSTART, 75, 107,
|
||||
/* 76: L */ M_NMSTART, 76, 108,
|
||||
/* 77: M */ M_NMSTART, 77, 109,
|
||||
/* 78: N */ M_NMSTART, 78, 110,
|
||||
/* 79: O */ M_NMSTART, 79, 111,
|
||||
/* 80: P */ M_NMSTART, 80, 112,
|
||||
/* 81: Q */ M_NMSTART, 81, 113,
|
||||
/* 82: R */ M_NMSTART, 82, 114,
|
||||
/* 83: S */ M_NMSTART, 83, 115,
|
||||
/* 84: T */ M_NMSTART, 84, 116,
|
||||
/* 85: U */ M_NMSTART, 85, 117,
|
||||
/* 86: V */ M_NMSTART, 86, 118,
|
||||
/* 87: W */ M_NMSTART, 87, 119,
|
||||
/* 88: X */ M_NMSTART, 88, 120,
|
||||
/* 89: Y */ M_NMSTART, 89, 121,
|
||||
/* 90: Z */ M_NMSTART, 90, 122,
|
||||
/* 91: [ */ M_NONNAME, 91, 91,
|
||||
/* 92: \\ */ M_NONNAME, 92, 92,
|
||||
/* 93: ] */ M_NONNAME, 93, 93,
|
||||
/* 94: ^ */ M_NONNAME, 94, 94,
|
||||
/* 95: _ */ M_NONNAME, 95, 95,
|
||||
/* 96: ` */ M_NONNAME, 96, 96,
|
||||
/* 97: a */ M_NMSTART, 65, 97,
|
||||
/* 98: b */ M_NMSTART, 66, 98,
|
||||
/* 99: c */ M_NMSTART, 67, 99,
|
||||
/* 100: d */ M_NMSTART, 68, 100,
|
||||
/* 101: e */ M_NMSTART, 69, 101,
|
||||
/* 102: f */ M_NMSTART, 70, 102,
|
||||
/* 103: g */ M_NMSTART, 71, 103,
|
||||
/* 104: h */ M_NMSTART, 72, 104,
|
||||
/* 105: i */ M_NMSTART, 73, 105,
|
||||
/* 106: j */ M_NMSTART, 74, 106,
|
||||
/* 107: k */ M_NMSTART, 75, 107,
|
||||
/* 108: l */ M_NMSTART, 76, 108,
|
||||
/* 109: m */ M_NMSTART, 77, 109,
|
||||
/* 110: n */ M_NMSTART, 78, 110,
|
||||
/* 111: o */ M_NMSTART, 79, 111,
|
||||
/* 112: p */ M_NMSTART, 80, 112,
|
||||
/* 113: q */ M_NMSTART, 81, 113,
|
||||
/* 114: r */ M_NMSTART, 82, 114,
|
||||
/* 115: s */ M_NMSTART, 83, 115,
|
||||
/* 116: t */ M_NMSTART, 84, 116,
|
||||
/* 117: u */ M_NMSTART, 85, 117,
|
||||
/* 118: v */ M_NMSTART, 86, 118,
|
||||
/* 119: w */ M_NMSTART, 87, 119,
|
||||
/* 120: x */ M_NMSTART, 88, 120,
|
||||
/* 121: y */ M_NMSTART, 89, 121,
|
||||
/* 122: z */ M_NMSTART, 90, 122,
|
||||
/* 123: { */ M_NONNAME, 123, 123,
|
||||
/* 124: | */ M_NONNAME, 124, 124,
|
||||
/* 125: } */ M_NONNAME, 125, 125,
|
||||
/* 126: ~ */ M_NONNAME, 126, 126,
|
||||
/* 127: DEL */ M_NONNAME, 127, 127,
|
||||
/* 128: undefined */ M_NONNAME, 128, 128,
|
||||
/* 129: undefined */ M_NONNAME, 129, 129,
|
||||
/* 130: undefined */ M_NONNAME, 130, 130,
|
||||
/* 131: undefined */ M_NONNAME, 131, 131,
|
||||
/* 132: undefined */ M_NONNAME, 132, 132,
|
||||
/* 133: undefined */ M_NONNAME, 133, 133,
|
||||
/* 134: undefined */ M_NONNAME, 134, 134,
|
||||
/* 135: undefined */ M_NONNAME, 135, 135,
|
||||
/* 136: undefined */ M_NONNAME, 136, 136,
|
||||
/* 137: undefined */ M_NONNAME, 137, 137,
|
||||
/* 138: undefined */ M_NONNAME, 138, 138,
|
||||
/* 139: undefined */ M_NONNAME, 139, 139,
|
||||
/* 140: undefined */ M_NONNAME, 140, 140,
|
||||
/* 141: undefined */ M_NONNAME, 141, 141,
|
||||
/* 142: undefined */ M_NONNAME, 142, 142,
|
||||
/* 143: undefined */ M_NONNAME, 143, 143,
|
||||
/* 144: undefined */ M_NONNAME, 144, 144,
|
||||
/* 145: undefined */ M_NONNAME, 145, 145,
|
||||
/* 146: undefined */ M_NONNAME, 146, 146,
|
||||
/* 147: undefined */ M_NONNAME, 147, 147,
|
||||
/* 148: undefined */ M_NONNAME, 148, 148,
|
||||
/* 149: undefined */ M_NONNAME, 149, 149,
|
||||
/* 150: undefined */ M_NONNAME, 150, 150,
|
||||
/* 151: undefined */ M_NONNAME, 151, 151,
|
||||
/* 152: undefined */ M_NONNAME, 152, 152,
|
||||
/* 153: undefined */ M_NONNAME, 153, 153,
|
||||
/* 154: undefined */ M_NONNAME, 154, 154,
|
||||
/* 155: undefined */ M_NONNAME, 155, 155,
|
||||
/* 156: undefined */ M_NONNAME, 156, 156,
|
||||
/* 157: undefined */ M_NONNAME, 157, 157,
|
||||
/* 158: undefined */ M_NONNAME, 158, 158,
|
||||
/* 159: undefined */ M_NONNAME, 159, 159,
|
||||
/* 160: undefined */ M_NONNAME, 160, 160,
|
||||
/* 161: A grave */ M_NMSTART, 161, 200,
|
||||
/* 162: A circumflex */ M_NMSTART, 162, 192,
|
||||
/* 163: E grave */ M_NMSTART, 163, 201,
|
||||
/* 164: E circumflex */ M_NMSTART, 164, 193,
|
||||
/* 165: E dieresis */ M_NMSTART, 165, 205,
|
||||
/* 166: I circumflex */ M_NMSTART, 166, 209,
|
||||
/* 167: I dieresis */ M_NMSTART, 167, 221,
|
||||
/* 168: acute accent */ M_NONNAME, 168, 168,
|
||||
/* 169: grave accent */ M_NONNAME, 169, 169,
|
||||
/* 170: circumflex */ M_NONNAME, 170, 170,
|
||||
/* 171: dieresis */ M_NONNAME, 171, 171,
|
||||
/* 172: tilde */ M_NONNAME, 172, 172,
|
||||
/* 173: U grave */ M_NMSTART, 173, 203,
|
||||
/* 174: U circumflex */ M_NMSTART, 174, 195,
|
||||
/* 175: Italian Lira (invalid) */ M_NONNAME, 175, 175,
|
||||
/* 176: overbar (invalid) */ M_NONNAME, 176, 176,
|
||||
/* 177: Y acute */ M_NMSTART, 177, 178,
|
||||
/* 178: y acute */ M_NMSTART, 177, 178,
|
||||
/* 179: degree (invalid) */ M_NONNAME, 179, 179,
|
||||
/* 180: C cedilla */ M_NMSTART, 180, 181,
|
||||
/* 181: c cedilla */ M_NMSTART, 180, 181,
|
||||
/* 182: N tilde */ M_NMSTART, 182, 183,
|
||||
/* 183: n tilde */ M_NMSTART, 182, 183,
|
||||
/* 184: inverted exclamation mark */ M_NONNAME, 184, 184,
|
||||
/* 185: inverted question mark */ M_NONNAME, 185, 185,
|
||||
/* 186: currency sign (invalid) */ M_NONNAME, 186, 186,
|
||||
/* 187: pound sterling (invalid) */ M_NONNAME, 187, 187,
|
||||
/* 188: Yen */ M_NONNAME, 188, 188,
|
||||
/* 189: Section sign (invalid) */ M_NONNAME, 189, 189,
|
||||
/* 190: florin (invalid) */ M_NONNAME, 190, 190,
|
||||
/* 191: Cent sign (invalid) */ M_NONNAME, 191, 191,
|
||||
/* 192: a circumflex */ M_NMSTART, 162, 192,
|
||||
/* 193: e circumflex */ M_NMSTART, 164, 193,
|
||||
/* 194: o circumflex */ M_NMSTART, 223, 194,
|
||||
/* 195: u circumflex */ M_NMSTART, 174, 195,
|
||||
/* 196: a acute */ M_NMSTART, 224, 196,
|
||||
/* 197: e acute */ M_NMSTART, 220, 197,
|
||||
/* 198: o acute */ M_NMSTART, 231, 198,
|
||||
/* 199: u acute */ M_NMSTART, 237, 199,
|
||||
/* 200: a grave */ M_NMSTART, 161, 200,
|
||||
/* 201: e grave */ M_NMSTART, 163, 201,
|
||||
/* 202: o grave */ M_NMSTART, 232, 202,
|
||||
/* 203: u grave */ M_NMSTART, 173, 203,
|
||||
/* 204: a dieresis */ M_NMSTART, 216, 204,
|
||||
/* 205: e dieresis */ M_NMSTART, 165, 205,
|
||||
/* 206: o dieresis */ M_NMSTART, 218, 206,
|
||||
/* 207: u dieresis */ M_NMSTART, 219, 207,
|
||||
/* 208: A angstrom */ M_NMSTART, 208, 212,
|
||||
/* 209: i circumflex */ M_NMSTART, 166, 209,
|
||||
/* 210: O slash */ M_NMSTART, 210, 214,
|
||||
/* 211: AE ligature */ M_NMSTART, 211, 215,
|
||||
/* 212: a angstrom */ M_NMSTART, 208, 212,
|
||||
/* 213: i acute */ M_NMSTART, 229, 213,
|
||||
/* 214: o slash */ M_NMSTART, 210, 214,
|
||||
/* 215: ae ligature */ M_NMSTART, 211, 215,
|
||||
/* 216: A dieresis */ M_NMSTART, 216, 204,
|
||||
/* 217: i grave */ M_NMSTART, 230, 217,
|
||||
/* 218: O dieresis */ M_NMSTART, 218, 206,
|
||||
/* 219: U dieresis */ M_NMSTART, 219, 207,
|
||||
/* 220: E acute */ M_NMSTART, 220, 197,
|
||||
/* 221: i dieresis */ M_NMSTART, 167, 221,
|
||||
/* 222: SS ligature */ M_NMSTART, 222, 222,
|
||||
/* 223: O circumflex */ M_NMSTART, 223, 194,
|
||||
/* 224: A acute */ M_NMSTART, 224, 196,
|
||||
/* 225: A tilde */ M_NMSTART, 225, 226,
|
||||
/* 226: a tilde */ M_NMSTART, 225, 226,
|
||||
/* 227: Eth (invalid) */ M_NMSTART, 227, 228,
|
||||
/* 228: eth (invalid) */ M_NMSTART, 227, 228,
|
||||
/* 229: I acute */ M_NMSTART, 229, 213,
|
||||
/* 230: I grave */ M_NMSTART, 230, 217,
|
||||
/* 231: O acute */ M_NMSTART, 231, 198,
|
||||
/* 232: O grave */ M_NMSTART, 232, 202,
|
||||
/* 233: O tilde */ M_NMSTART, 233, 234,
|
||||
/* 234: o tilde */ M_NMSTART, 233, 234,
|
||||
/* 235: S caron */ M_NMSTART, 235, 236,
|
||||
/* 236: s caron */ M_NMSTART, 235, 236,
|
||||
/* 237: U acute */ M_NMSTART, 237, 199,
|
||||
/* 238: Y dieresis */ M_NMSTART, 238, 239,
|
||||
/* 239: y dieresis */ M_NMSTART, 238, 239,
|
||||
/* 240: Thorn (invalid) */ M_NMSTART, 240, 241,
|
||||
/* 241: thorn (invalid) */ M_NMSTART, 240, 241,
|
||||
/* 242: undefined */ M_NONNAME, 242, 242,
|
||||
/* 243: mu (invalid) */ M_NONNAME, 243, 243,
|
||||
/* 244: paragraph sign (invalid) */ M_NONNAME, 244, 244,
|
||||
/* 245: fraction 3/4 (invalid) */ M_NONNAME, 245, 245,
|
||||
/* 246: long dash (invalid) */ M_NONNAME, 246, 246,
|
||||
/* 247: fraction 1/4 (invalid) */ M_NONNAME, 247, 247,
|
||||
/* 248: fraction 1/2 (invalid) */ M_NONNAME, 248, 248,
|
||||
/* 249: Female ordinal (invalid) */ M_NONNAME, 249, 249,
|
||||
/* 250: Male ordinal (invalid) */ M_NONNAME, 250, 250,
|
||||
/* 251: French double open quote(invalid) */ M_NONNAME, 251, 251,
|
||||
/* 252: Solid square (invalid) */ M_NONNAME, 252, 252,
|
||||
/* 253: French double close quote(invalid) */ M_NONNAME, 253, 253,
|
||||
/* 254: Plus over minus sign(invalid)*/ M_NONNAME, 254, 254,
|
||||
/* 255: undefined */ M_NONNAME, 255, 255,
|
||||
} ;
|
||||
|
||||
|
||||
63
cde/programs/dthelp/parser/pass2/util/common.h
Normal file
63
cde/programs/dthelp/parser/pass2/util/common.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* $XConsortium: common.h /main/6 1996/07/31 13:34:28 cde-hp $ */
|
||||
/*
|
||||
Copyright (c) 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Common.h contains definitions common to programs BUILD, ELTDEF, and PARSER.
|
||||
Its purpose is to insure that limits, such as the maximum length of an SGML
|
||||
name, are the same for all programs.
|
||||
*/
|
||||
|
||||
#define M_MARKUP
|
||||
|
||||
/* White-space characters */
|
||||
#define M_RE '\n'
|
||||
#define M_SPACE ' '
|
||||
#define M_TAB '\t'
|
||||
|
||||
/* Maximum length of a default parameter value */
|
||||
#define M_LITLEN 1024
|
||||
|
||||
/* Maximum length of an element name */
|
||||
#define M_NAMELEN 64
|
||||
|
||||
/* M_NONNAME, M_NMSTART, M_NAMECHAR, and M_DIGIT are used to indicate
|
||||
which characters can appear within element names*/
|
||||
#define M_NONNAME 0
|
||||
#define M_NMSTART 1
|
||||
#define M_NAMECHAR 2
|
||||
#define M_DIGIT 3
|
||||
|
||||
/* Number of characters in the character set */
|
||||
#define M_CHARSETLEN 256
|
||||
|
||||
/* Structure for entities */
|
||||
typedef struct m_entity M_ENTITY ;
|
||||
struct m_entity {
|
||||
unsigned char type ;
|
||||
unsigned char wheredef ;
|
||||
M_WCHAR *content ;
|
||||
M_WCHAR *name ;
|
||||
#if defined(BUILDEXTERN) || defined(ELTEXTERN)
|
||||
int index ;
|
||||
M_ENTITY *next ;
|
||||
#endif
|
||||
#if ! defined(BUILDEXTERN)
|
||||
int codeindex ;
|
||||
#endif
|
||||
} ;
|
||||
|
||||
/* Declarations for character types */
|
||||
typedef struct {
|
||||
LOGICAL type ;
|
||||
/* Must be same type as EOF */
|
||||
int upper ;
|
||||
int lower ;
|
||||
} M_CHARTYPE ;
|
||||
|
||||
|
||||
#define m_ischar(x) ((int) (x) >= 0 && (int) (x) < M_CHARSETLEN)
|
||||
#define m_cttype(x) (m_ischar(x) ? m_ctarray[x].type : M_NONNAME)
|
||||
#define m_ctupper(x) (m_ischar(x) ? m_ctarray[x].upper : x)
|
||||
#define m_ctlower(x) (m_ischar(x) ? m_ctarray[x].lower : x)
|
||||
#define m_ctdigit(x) (m_ischar(x) ? m_ctarray[x].type == M_DIGIT : FALSE)
|
||||
247
cde/programs/dthelp/parser/pass2/util/cont.h
Normal file
247
cde/programs/dthelp/parser/pass2/util/cont.h
Normal file
@@ -0,0 +1,247 @@
|
||||
/* $XConsortium: cont.h /main/3 1995/11/08 11:02:46 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Cont.h is the primary include file for program CONTEXT. */
|
||||
|
||||
#if defined(CONTDEF)
|
||||
#define CONTEXTERN
|
||||
#define CONTINIT(a) = a
|
||||
#else
|
||||
#define CONTEXTERN extern
|
||||
#define CONTINIT(a)
|
||||
#endif
|
||||
|
||||
void countdown(
|
||||
#if defined(M_PROTO)
|
||||
M_TRIE *parent, int *count
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumpdlmptr(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumpnode(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL *first, FILE *file, M_TRIE *trieptr, int *count, void (*proc)
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void dumptree(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL sparse
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void enterdelim(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_error(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_err1(
|
||||
#if defined(M_PROTO)
|
||||
char *text, char *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void getcode(
|
||||
#if defined(M_PROTO)
|
||||
int n
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void getcolon(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int getContext(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL getdname(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void inccon(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void incdelim(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void loaddelim(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_lower(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void main(
|
||||
#if defined(M_PROTO)
|
||||
int argc, char **argv
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void *m_malloc(
|
||||
#if defined(M_PROTO)
|
||||
int size, char *msg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void nextcon(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL sparse
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void m_openchk(
|
||||
#if defined(M_PROTO)
|
||||
FILE **ptr, char *name, char *mode
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void printval(
|
||||
#if defined(M_PROTO)
|
||||
FILE *file, M_TRIE *value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void prtctxt(
|
||||
#if defined(M_PROTO)
|
||||
int column, int value
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int readchar(
|
||||
#if defined(M_PROTO)
|
||||
LOGICAL cap
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void skiptoend(
|
||||
#if defined(M_PROTO)
|
||||
M_NOPAR
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void unread(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
int m_upper(
|
||||
#if defined(M_PROTO)
|
||||
int c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning(
|
||||
#if defined(M_PROTO)
|
||||
char *text
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning1(
|
||||
#if defined(M_PROTO)
|
||||
char *text, char *arg
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void warning2(
|
||||
#if defined(M_PROTO)
|
||||
char *text, char *arg1, char *arg2
|
||||
#endif
|
||||
) ;
|
||||
|
||||
LOGICAL m_whitespace(
|
||||
#if defined(M_PROTO)
|
||||
M_WCHAR c
|
||||
#endif
|
||||
) ;
|
||||
|
||||
|
||||
#define NOMORE -1
|
||||
|
||||
/* Increase by 10 percent */
|
||||
#define m_plus10p(x) (x + (x > 10 ? x / 10 : 1))
|
||||
|
||||
CONTEXTERN int NUMCON CONTINIT(100) ;
|
||||
#define CNAMELEN 12
|
||||
#define DNAMELEN 12
|
||||
#define DELIMLEN 25
|
||||
CONTEXTERN int NUMDELIM CONTINIT(100) ;
|
||||
|
||||
#define contype ccount <= 255 ? "unsigned char" : "int"
|
||||
|
||||
CONTEXTERN LOGICAL m_heapchk CONTINIT(FALSE) ;
|
||||
CONTEXTERN LOGICAL m_malftrace CONTINIT(FALSE) ;
|
||||
|
||||
#define ENDIFSTRING "}\n#endif\n ;\n"
|
||||
CONTEXTERN char endif[sizeof(ENDIFSTRING)] CONTINIT(ENDIFSTRING) ;
|
||||
|
||||
CONTEXTERN LOGICAL casestarted ;
|
||||
CONTEXTERN LOGICAL errexit CONTINIT(FALSE) ;
|
||||
|
||||
CONTEXTERN FILE *delim ;
|
||||
CONTEXTERN FILE *context ;
|
||||
CONTEXTERN FILE *fcase, *cdat, *ddat, *m_errfile ;
|
||||
|
||||
CONTEXTERN M_TRIE delimtrie ;
|
||||
|
||||
CONTEXTERN M_TRIE **contree ;
|
||||
CONTEXTERN int *xtransit ;
|
||||
#define transit(i,j) xtransit[i * NUMDELIM + j]
|
||||
|
||||
CONTEXTERN M_WCHAR **contexts ;
|
||||
CONTEXTERN int ccount CONTINIT(0) ;
|
||||
|
||||
CONTEXTERN M_WCHAR dname[DNAMELEN + 1] ;
|
||||
CONTEXTERN M_WCHAR dstring[DELIMLEN + 1] ;
|
||||
CONTEXTERN int dcount CONTINIT(0) ;
|
||||
|
||||
CONTEXTERN struct dstruct {
|
||||
int count ;
|
||||
M_WCHAR *string ;
|
||||
} *dstruct ;
|
||||
CONTEXTERN LOGICAL withdelim ;
|
||||
CONTEXTERN LOGICAL loading ;
|
||||
CONTEXTERN int curdelim ;
|
||||
|
||||
CONTEXTERN char **dlmptr ;
|
||||
|
||||
CONTEXTERN LOGICAL first CONTINIT(TRUE) ;
|
||||
CONTEXTERN int maxd CONTINIT(0) ;
|
||||
|
||||
CONTEXTERN int m_line CONTINIT(1) ;
|
||||
|
||||
CONTEXTERN int nonzero CONTINIT(0) ;
|
||||
224
cde/programs/dthelp/parser/pass2/util/context.c
Normal file
224
cde/programs/dthelp/parser/pass2/util/context.c
Normal file
@@ -0,0 +1,224 @@
|
||||
/* $XConsortium: context.c /main/3 1995/11/08 11:03:02 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/*
|
||||
Context.c contains the main procedure for program CONTEXT.
|
||||
|
||||
CONTEXT builds scanning and parsing tables for a simple
|
||||
state-transition recognizer. Input consists of two files, delimiter
|
||||
declarations in file "delim.dat" and state tables with corresponding
|
||||
actions in file "context.dat". If a parameter is present on the
|
||||
command line, a sparse matrix technique is used to encode some of the
|
||||
output arrays.
|
||||
|
||||
Data lines in "delim.dat" contain the name of the delimiter followed
|
||||
by the text of the delimiter (one or more non-white space
|
||||
characters). The delimiter name must begin in the first column.
|
||||
Lines with white-space in the first column are considered comments.
|
||||
|
||||
Data in "context.dat" consists of free-form multi-line declarations.
|
||||
Each declaration is terminated by a semi-colon. It begins with the
|
||||
name of a token followed by any number of pairs of contexts (parser
|
||||
states). The context pairs are separated by a colon and may
|
||||
optionally be followed by some C code enclosed in braces. In each
|
||||
pair, the first context is one in which the delimiter is recognized,
|
||||
the second is the state that will result from an occurrence of the
|
||||
delimiter in the first context. If code is specified, it is to be
|
||||
executed by the parser when the delimiter occurs in the first context
|
||||
of the pair. If successive pairs of contexts are separated by a
|
||||
comma, code which follows is common to all the pairs.
|
||||
|
||||
The tokens specified in "context.dat" can either be delimiters defined in
|
||||
"delim.dat" or other tokens (e.g., number, name, end_of_file) that will
|
||||
be recognized by the user-defined scanner.
|
||||
|
||||
For example, suppose "delim.dat" contains the line
|
||||
|
||||
grpo (
|
||||
|
||||
and "context.dat" includes
|
||||
|
||||
grpo element:namegroup
|
||||
content:model {openmod() ;}
|
||||
excon:openex
|
||||
pcon:type ;
|
||||
|
||||
name namegroup:namesep {eltname() ;}
|
||||
model:connector,
|
||||
model2:connector
|
||||
{storemod(nstring) ;}
|
||||
|
||||
These declarations specify that the "grpo" delimiter is "(" and is
|
||||
recognized in contexts "element", "content", "excon", and "pcon".
|
||||
Procedure openmod() is called when "grpo" occurs in "content" and,
|
||||
beyond the state change, no code is executed in other contexts when
|
||||
"grpo" occurs. The "name" token is valid in contexts "namegroup",
|
||||
"model", and "model2"; in the first, the context is set to "namesep"
|
||||
and procedure eltname() is called, in the last two, the context is
|
||||
set to "connector" and storemod(nstring) is called.
|
||||
|
||||
The program has several output files: case.c, delim.h, context.h, and
|
||||
error. Case.c contains nested switch statements to execute the code
|
||||
specified with the context transitions. Delim.h contains C
|
||||
declarations related to delimiters; context.h has declarations
|
||||
related to contexts. Programs that include delim.h should define
|
||||
M_DELIMDEF for definition form of the declarations and not define it
|
||||
for the declaration form. Programs that include context.h should
|
||||
define M_CONDEF analogously.
|
||||
|
||||
The program numbers the delimiter names and the contexts as
|
||||
encountered and outputs corresponding #define instructions with all
|
||||
letters in the names forced to uppercase to delim.h and context.h.
|
||||
In addition, an array named for each delimiter (with all letters
|
||||
forced to lowercase) is initialized to the delimiter text. The first
|
||||
declaration in the above example, for instance, would result in the
|
||||
following lines written to delim.h:
|
||||
|
||||
#define GRPO 1
|
||||
M_DELIMEXTERN char grpo[] M_DELIMINIT("(") ;
|
||||
|
||||
These lines would be written to context.h:
|
||||
|
||||
#define ELEMENT 1
|
||||
#define NAMEGROUP 2
|
||||
#define CONTENT 3
|
||||
#define MODEL 4
|
||||
#define EXCON 5
|
||||
#define OPENEX 6
|
||||
#define PCON 7
|
||||
#define TYPE 8
|
||||
#define NAMESEP 9
|
||||
#define CONNECTOR 10
|
||||
#define MODEL2 11
|
||||
|
||||
Delim.h also contains an array, m_dlmptr, which contains pointers to the
|
||||
names of all the defined delimiters. In addition, delim.h contains the
|
||||
declaration of a tree representation of the delimiters allowed in each
|
||||
context. Internally, the program represents the delimiter strings with a
|
||||
tree. The children of the root of this tree represent the set of characters
|
||||
with which delimiters can start. Children of other nodes represent
|
||||
characters that can follow the character of their parent. Leaf nodes
|
||||
are associated with the null character, indicating the end of a
|
||||
delimiter. A path from the root to a leaf thus represents a valid
|
||||
delimiter.
|
||||
|
||||
The form in which the tree is represented within this program is not
|
||||
quite the same as the output data structure. In the latter, each
|
||||
element consists of a flag called 'more' indicating whether it is the last
|
||||
child of its parent; a character, called 'symbol'; and an integer,
|
||||
called 'index'. All sons of a node are stored in adjacent elements
|
||||
ordered in increaing value of their 'symbol' fields. 'Symbol'
|
||||
contains the character associated with the node (0 if the node is a
|
||||
leaf node), with the sign bit turned on if the node is the last child
|
||||
of its parent. 'Index' contains the array index of the first son of
|
||||
the node, if the node is not a leaf. If the node is a leaf, 'index'
|
||||
is the number of the represented delimiter (i.e., 1 for "grpo" in the
|
||||
above example).
|
||||
|
||||
As the tree is constructed, it is not feasible to store brothers in adjacent
|
||||
elements, so the internal data structure is different. It contains a 'next'
|
||||
field which points to the first brother of a given node. Because the 'next'
|
||||
field can be used to detect the last child of a parent, it is not necessary
|
||||
to use the sign bit of 'symbol' to indicate this special case.
|
||||
|
||||
Two other arrays are written to context.h. Contree[i] points to the root
|
||||
of the delimiter tree for the ith context within the array tree whose
|
||||
declaration is in delim.h; nextcon[i][j] indicates the state
|
||||
resulting from an occurrence of delimiter j+1 in state i+1. Finally,
|
||||
a #define of MAXD to the length of the longest delimiter is written to
|
||||
delim.h.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "chartype.h"
|
||||
#define CONTDEF 1
|
||||
#include "cont.h"
|
||||
|
||||
/* Main procedure */
|
||||
void main(argc, argv)
|
||||
int argc ;
|
||||
char **argv ;
|
||||
{
|
||||
int n ;
|
||||
|
||||
m_openchk(&delim, "delim.h", "w") ;
|
||||
m_openchk(&context, "context.h", "w") ;
|
||||
m_openchk(&fcase, "case.c", "w") ;
|
||||
m_openchk(&cdat, "context.dat", "r") ;
|
||||
m_openchk(&ddat, "delim.dat", "r") ;
|
||||
m_openchk(&m_errfile, "error", "w") ;
|
||||
fputs(" switch(m_token) {\n", fcase) ; /* keep the "}" balanced */
|
||||
|
||||
fputs("#if defined(M_DELIMDEF)\n", delim) ;
|
||||
fputs("#define M_DELIMEXTERN\n", delim) ;
|
||||
fputs("#define M_DELIMINIT(a) = a\n", delim) ;
|
||||
fputs("#else\n", delim) ;
|
||||
fputs("#define M_DELIMEXTERN extern\n", delim) ;
|
||||
fputs("#define M_DELIMINIT(a)\n", delim) ;
|
||||
fputs("#endif\n\n", delim) ;
|
||||
|
||||
fputs("#if defined(M_CONDEF)\n", context) ;
|
||||
fputs("#define M_CONEXTERN\n", context) ;
|
||||
fputs("#else\n", context) ;
|
||||
fputs("#define M_CONEXTERN extern\n", context) ;
|
||||
fputs("#endif\n\n", context) ;
|
||||
|
||||
contree = (M_TRIE **) calloc(NUMCON, sizeof(M_TRIE *)) ;
|
||||
xtransit = (int *) calloc(NUMCON * NUMDELIM, sizeof(int)) ;
|
||||
contexts = (M_WCHAR **) calloc(NUMCON, sizeof(char *)) ;
|
||||
dlmptr = (char**) calloc(NUMDELIM, sizeof(char*)) ;
|
||||
|
||||
loaddelim() ;
|
||||
while (getdname())
|
||||
{
|
||||
casestarted = FALSE ;
|
||||
while ((n = getContext()) >= 0)
|
||||
{
|
||||
if (withdelim) enterdelim(n) ;
|
||||
getcolon() ;
|
||||
if (transit(n, curdelim))
|
||||
{
|
||||
if (! withdelim)
|
||||
{
|
||||
char *mb_dname, *mb_contexts;
|
||||
|
||||
mb_dname = MakeMByteString(dname);
|
||||
mb_contexts = MakeMByteString(contexts[n]);
|
||||
warning2(
|
||||
"Duplicate assignment to token \"%s\" in context \"%s\"",
|
||||
mb_dname,
|
||||
mb_contexts) ;
|
||||
m_free(mb_dname,"multi-byte string");
|
||||
m_free(mb_contexts,"multi-byte string");
|
||||
}
|
||||
}
|
||||
transit(n, curdelim) = getContext() + 1 ;
|
||||
getcode(n) ;
|
||||
}
|
||||
if (casestarted)
|
||||
{
|
||||
fprintf(fcase, " default:\n break ;\n") ;
|
||||
/* keep the "{" balanced */
|
||||
fprintf(fcase, " }\n break ;\n") ;
|
||||
}
|
||||
}
|
||||
/* keep the "{" balanced */
|
||||
fprintf(fcase, " default:\n break ;\n }\n") ;
|
||||
fprintf(context, "#define MAXD %d\n", maxd) ;
|
||||
dumptree((LOGICAL) (argc > 1)) ;
|
||||
fprintf(stderr, "NUMCON set to %d\n", NUMCON) ;
|
||||
fprintf(stderr, "NUMDELIM set to %d\n", NUMDELIM) ;
|
||||
exit(errexit) ;
|
||||
}
|
||||
652
cde/programs/dthelp/parser/pass2/util/conutil.c
Normal file
652
cde/programs/dthelp/parser/pass2/util/conutil.c
Normal file
@@ -0,0 +1,652 @@
|
||||
/* $XConsortium: conutil.c /main/3 1995/11/08 11:03:16 rswiston $ */
|
||||
/*
|
||||
Copyright 1986 Tandem Computers Incorporated.
|
||||
This product and information is proprietary of Tandem Computers Incorporated.
|
||||
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
|
||||
*/
|
||||
|
||||
/* Conutil has utility procedures for program CONTEXT. */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
#include "trie.h"
|
||||
|
||||
#include "cont.h"
|
||||
|
||||
/* Output declaration of dlmptr */
|
||||
void dumpdlmptr(M_NOPAR)
|
||||
{
|
||||
int n;
|
||||
|
||||
fprintf(delim, "M_DELIMEXTERN M_WCHAR *m_dlmptr[%d];\n", dcount+1);
|
||||
fprintf(delim, "M_DELIMEXTERN char *mb_dlmptr[%d]\n", dcount+1);
|
||||
fprintf(delim, "#if defined(M_DELIMDEF)\n = {\n");
|
||||
for (n = 0 ; n < dcount ; n++) {
|
||||
if (n) fputs(",\n", delim);
|
||||
fprintf(delim, " %s", dlmptr[n]);
|
||||
}
|
||||
fprintf(delim, endif);
|
||||
}
|
||||
|
||||
/* Output the generated data structures */
|
||||
#if defined(M_PROTO)
|
||||
void dumptree(LOGICAL sparse)
|
||||
#else
|
||||
void dumptree(sparse)
|
||||
LOGICAL sparse;
|
||||
#endif
|
||||
{
|
||||
int i, count = 0;
|
||||
|
||||
for (i = 0 ; i < ccount ; i++)
|
||||
if (contree[i])
|
||||
countdown(contree[i], &count);
|
||||
fprintf(delim,
|
||||
"M_DELIMEXTERN M_PTRIE m_delimtrie[%d]\n#if defined(M_DELIMDEF)\n = {\n",
|
||||
count);
|
||||
fprintf(context,
|
||||
"M_CONEXTERN int m_contree[%d]\n#if defined(M_CONDEF)\n = {\n ",
|
||||
ccount);
|
||||
|
||||
count = 0;
|
||||
for (i = 0 ; i < ccount ; i++) {
|
||||
if (contree[i]) {
|
||||
fprintf(context, "%d", count + 1);
|
||||
dumpnode(&first, delim, contree[i], &count, (void *)printval);
|
||||
}
|
||||
else fprintf(context, "0");
|
||||
if (i < ccount - 1) fprintf(context, ",\n ");
|
||||
}
|
||||
fprintf(delim, endif);
|
||||
fprintf(context, endif);
|
||||
nextcon(sparse);
|
||||
}
|
||||
|
||||
/* Enter a delimiter into the delimiter tree for a particular context */
|
||||
void enterdelim(n)
|
||||
int n;
|
||||
{
|
||||
if (! contree[n])
|
||||
{
|
||||
contree[n] = m_gettrienode();
|
||||
}
|
||||
|
||||
if (m_ntrtrie(dstruct->string,
|
||||
contree[n],
|
||||
(void *) (unsigned long) dstruct->count))
|
||||
{
|
||||
char *mb_dstring, *mb_contexts;
|
||||
|
||||
mb_dstring = MakeMByteString(dstring);
|
||||
mb_contexts = MakeMByteString(contexts[n]);
|
||||
dcount--;
|
||||
warning2("Duplicate assignment to delimiter \"%s\" in context \"%s\"",
|
||||
mb_dstring,
|
||||
mb_contexts);
|
||||
m_free(mb_dstring,"multi-byte string");
|
||||
m_free(mb_contexts,"multi-byte string");
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the code to be executed with a given state transition */
|
||||
void getcode(n)
|
||||
int n;
|
||||
{
|
||||
int c ; /* c is int instead of char for use with ungetc */
|
||||
int nested = 1;
|
||||
LOGICAL comment = FALSE;
|
||||
char *mb_context;
|
||||
M_WCHAR wlb = 0, wcm, wnl, wsl, wst;
|
||||
|
||||
|
||||
if (!wlb)
|
||||
{
|
||||
mbtowc(&wlb, "{", 1); /* keep the "}" balanced */
|
||||
mbtowc(&wcm, ",", 1);
|
||||
mbtowc(&wnl, "\n", 1);
|
||||
mbtowc(&wsl, "/", 1);
|
||||
mbtowc(&wst, "*", 1);
|
||||
}
|
||||
|
||||
while (m_whitespace((M_WCHAR) (c = readchar(FALSE))));
|
||||
if (c != wlb && c != wcm)
|
||||
{
|
||||
unread(c);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! casestarted)
|
||||
{
|
||||
char *mb_dname;
|
||||
|
||||
mb_dname = MakeMByteString(dname);
|
||||
casestarted = TRUE;
|
||||
fprintf(fcase, " case %s:\n", mb_dname);
|
||||
fprintf(fcase, " switch (m_prevcon) {\n") ; /* balance the } */
|
||||
m_free(mb_dname,"multi-byte string");
|
||||
}
|
||||
|
||||
mb_context = MakeMByteString(contexts[n]);
|
||||
fprintf(fcase, " case %s:\n", mb_context);
|
||||
m_free(mb_context,"multi-byte string");
|
||||
|
||||
if (c == wcm) return;
|
||||
|
||||
fprintf(fcase, "/* line %d \"context.dat\" */\n", m_line);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
char mb_c[32]; /* arbitrarily large */
|
||||
int length;
|
||||
|
||||
c = readchar(FALSE);
|
||||
if (c == EOF)
|
||||
{
|
||||
warning("Unexpected EOF");
|
||||
exit(TRUE);
|
||||
}
|
||||
|
||||
length = wctomb(mb_c, c);
|
||||
mb_c[length] = 0;
|
||||
if (length == 1)
|
||||
{
|
||||
switch (mb_c[0])
|
||||
{
|
||||
case '{':
|
||||
if (! comment) nested++;
|
||||
break;
|
||||
case '}':
|
||||
if (! comment)
|
||||
if (! --nested)
|
||||
{
|
||||
fprintf(fcase,"\n break ;\n");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
if (! comment)
|
||||
{
|
||||
fprintf(fcase, "/");
|
||||
c = readchar(FALSE);
|
||||
if (c == wst) comment = TRUE;
|
||||
length = wctomb(mb_c, c);
|
||||
mb_c[length] = 0;
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
if (comment)
|
||||
{
|
||||
fprintf(fcase, "*");
|
||||
c = readchar(FALSE);
|
||||
if (c == wsl) comment = FALSE;
|
||||
length = wctomb(mb_c, c);
|
||||
mb_c[length] = 0;
|
||||
}
|
||||
} /* End case */
|
||||
}
|
||||
fprintf(fcase, "%s", mb_c);
|
||||
#if 0
|
||||
if (c == wnl)
|
||||
fprintf(fcase, "#line %d \"context.dat\"\n", m_line);
|
||||
#endif
|
||||
} /* End while */
|
||||
} /* End proc getcode() */
|
||||
|
||||
/* Read the colon separating the two states in a transition pair */
|
||||
void getcolon(M_NOPAR)
|
||||
{
|
||||
int c ; /* c is int instead of char for use with ungetc */
|
||||
M_WCHAR wcl;
|
||||
char unexp[32]; /* arbitraily large */
|
||||
int length;
|
||||
|
||||
mbtowc(&wcl, ":", 1);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
c = readchar(FALSE);
|
||||
if (! m_whitespace((M_WCHAR) c)) break;
|
||||
}
|
||||
if (c != wcl)
|
||||
{
|
||||
length = wctomb(unexp, (M_WCHAR) c);
|
||||
unexp[length] = 0;
|
||||
warning1("Expecting : instead of '%s'\n", unexp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read a context name from an input line */
|
||||
int getContext(M_NOPAR)
|
||||
{
|
||||
M_WCHAR name[CNAMELEN + 1];
|
||||
int c ; /* c is int instead of char for use with ungetc */
|
||||
int i = 0;
|
||||
M_WCHAR wsm = 0, wcl, wcm;
|
||||
char *mb_name;
|
||||
|
||||
if (!wsm)
|
||||
{
|
||||
mbtowc(&wsm, ";", 1);
|
||||
mbtowc(&wcl, ":", 1);
|
||||
mbtowc(&wcm, ",", 1);
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
c = readchar(TRUE);
|
||||
if (c == EOF) return(NOMORE);
|
||||
*name = (M_WCHAR) c;
|
||||
if (*name == wsm) return(NOMORE);
|
||||
if (! m_whitespace(*name)) break;
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
i++;
|
||||
if (i >= CNAMELEN)
|
||||
{
|
||||
while (! m_whitespace((M_WCHAR) (c = readchar(TRUE)))
|
||||
&& c != wcl
|
||||
&& c != wcm
|
||||
&& c != EOF
|
||||
&& c != wsm);
|
||||
unread(c);
|
||||
break;
|
||||
}
|
||||
c = readchar(TRUE);
|
||||
if (m_whitespace((M_WCHAR) c) ||
|
||||
c == wsm ||
|
||||
c == wcl ||
|
||||
c == wcm ||
|
||||
c == EOF)
|
||||
{
|
||||
unread(c);
|
||||
break;
|
||||
}
|
||||
name[i] = (M_WCHAR) c;
|
||||
}
|
||||
name[i] = M_EOS;
|
||||
|
||||
for (i = 0 ; i < ccount ; i++)
|
||||
if (! w_strcmp(name, contexts[i])) return(i);
|
||||
|
||||
inccon() ;
|
||||
i = w_strlen(name) + 1;
|
||||
contexts[ccount - 1] = (M_WCHAR *) m_malloc(i, "context name");
|
||||
memcpy(contexts[ccount - 1], name, i * sizeof(M_WCHAR));
|
||||
|
||||
mb_name = MakeMByteString(name);
|
||||
fprintf(context, "#define %s %d\n", mb_name, ccount);
|
||||
m_free(mb_name,"multi-byte string");
|
||||
|
||||
return(ccount - 1);
|
||||
}
|
||||
|
||||
/* Read a delimiter name from the input line */
|
||||
LOGICAL getdname(M_NOPAR)
|
||||
{
|
||||
int c;
|
||||
M_WCHAR *p;
|
||||
|
||||
/* Skip leading blanks */
|
||||
while (TRUE)
|
||||
{
|
||||
c = readchar(TRUE);
|
||||
if (c == EOF) return(FALSE);
|
||||
if (! m_whitespace((M_WCHAR) c)) break;
|
||||
}
|
||||
for (p = dname;
|
||||
! m_whitespace((M_WCHAR) c) && c != EOF;
|
||||
c = readchar(TRUE))
|
||||
{
|
||||
if (p - dname >= DNAMELEN)
|
||||
{
|
||||
while (! m_whitespace((M_WCHAR) c) && c != EOF) c = readchar(TRUE);
|
||||
break;
|
||||
}
|
||||
*p++ = (M_WCHAR) c;
|
||||
}
|
||||
*p = M_EOS;
|
||||
if (dstruct = (struct dstruct *) m_lookfortrie(dname, &delimtrie))
|
||||
{
|
||||
withdelim = TRUE;
|
||||
curdelim = dstruct->count - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *mb_dname;
|
||||
|
||||
curdelim = dcount;
|
||||
incdelim();
|
||||
withdelim = FALSE;
|
||||
mb_dname = MakeMByteString(dname);
|
||||
fprintf(delim, "#define %s %d\n", mb_dname, dcount);
|
||||
m_free(mb_dname,"multi-byte string");
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* Out of context space. Increase. */
|
||||
void inccon(M_NOPAR)
|
||||
{
|
||||
M_TRIE **newtrie = NULL;
|
||||
int *newtransit = NULL;
|
||||
M_WCHAR **newcontexts = NULL;
|
||||
int trysize;
|
||||
int i, j;
|
||||
|
||||
if (ccount < NUMCON) {
|
||||
ccount++;
|
||||
return;
|
||||
}
|
||||
trysize = m_plus10p(NUMCON);
|
||||
newtrie = (M_TRIE **) calloc(trysize, sizeof(M_TRIE *));
|
||||
newtransit = (int *) calloc(trysize * NUMDELIM, sizeof(int));
|
||||
newcontexts = (M_WCHAR **) calloc(trysize, sizeof(M_WCHAR *));
|
||||
if (! newtrie || ! newtransit || ! newcontexts) {
|
||||
trysize = NUMCON + 1;
|
||||
if (newtrie) free((M_POINTER) newtrie);
|
||||
if (newtransit) free((M_POINTER) newtransit);
|
||||
if (newcontexts) free((M_POINTER) newcontexts);
|
||||
newtrie = (M_TRIE **) calloc(trysize, sizeof(M_TRIE *));
|
||||
newtransit = (int *) calloc(trysize * NUMDELIM, sizeof(int));
|
||||
newcontexts = (M_WCHAR **) calloc(trysize, sizeof(M_WCHAR *));
|
||||
}
|
||||
if (! newtrie || ! newtransit || ! newcontexts) {
|
||||
m_error("Out of memory for contexts");
|
||||
exit(TRUE);
|
||||
}
|
||||
for (i = 0 ; i < ccount ; i++)
|
||||
for (j = 0 ; j < dcount ; j++)
|
||||
newtransit[i * NUMDELIM + j] = transit(i, j);
|
||||
NUMCON = trysize;
|
||||
free((M_POINTER) xtransit);
|
||||
xtransit = newtransit;
|
||||
memcpy((M_POINTER) newtrie, (M_POINTER) contree,
|
||||
ccount * sizeof(M_TRIE **));
|
||||
memcpy((M_POINTER) newcontexts, (M_POINTER) contexts,
|
||||
ccount * sizeof(M_WCHAR **));
|
||||
free((M_POINTER) contree);
|
||||
free((M_POINTER) contexts);
|
||||
contree = newtrie;
|
||||
contexts = newcontexts;
|
||||
ccount++;
|
||||
}
|
||||
|
||||
/* Increase delimiter space. */
|
||||
void incdelim(M_NOPAR)
|
||||
{
|
||||
int *newtransit = NULL;
|
||||
char **newdlm = NULL;
|
||||
int trysize;
|
||||
int i, j;
|
||||
|
||||
if (dcount < NUMDELIM)
|
||||
{
|
||||
dcount++;
|
||||
return;
|
||||
}
|
||||
|
||||
trysize = m_plus10p(NUMDELIM);
|
||||
newtransit = (int *) calloc(NUMCON * trysize, sizeof(int));
|
||||
if (loading) newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *));
|
||||
if (! newtransit || (loading && ! newdlm))
|
||||
{
|
||||
trysize = NUMDELIM + 1;
|
||||
newtransit = (int *) calloc(NUMCON * trysize, sizeof(int));
|
||||
if (loading) newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *));
|
||||
}
|
||||
if (! newtransit || (loading && ! newdlm))
|
||||
{
|
||||
m_error("Out of memory for delimiters");
|
||||
exit(TRUE);
|
||||
}
|
||||
for (i = 0 ; i < ccount ; i++)
|
||||
for (j = 0 ; j < dcount ; j++)
|
||||
newtransit[i * trysize + j] = transit(i, j);
|
||||
free((M_POINTER) xtransit);
|
||||
if (loading)
|
||||
{
|
||||
memcpy((M_POINTER) newdlm, (M_POINTER) dlmptr, dcount * sizeof(M_TRIE **));
|
||||
free((M_POINTER) dlmptr);
|
||||
dlmptr = newdlm;
|
||||
}
|
||||
NUMDELIM = trysize;
|
||||
xtransit = newtransit;
|
||||
dcount++;
|
||||
}
|
||||
|
||||
/* Read delimiter definitions from delim.dat */
|
||||
void loaddelim(M_NOPAR)
|
||||
{
|
||||
int c;
|
||||
M_WCHAR *p;
|
||||
int i;
|
||||
M_WCHAR wnl;
|
||||
char *mb_dname, *mb_dstring;
|
||||
|
||||
mbtowc(&wnl, "\n", 1);
|
||||
|
||||
loading = TRUE;
|
||||
while ((c = getc(ddat)) != EOF)
|
||||
{
|
||||
/* Skip leading white space */
|
||||
if (c == wnl) continue;
|
||||
if (m_whitespace((M_WCHAR) c))
|
||||
{
|
||||
while ((c = getc(ddat)) != wnl)
|
||||
if (c == EOF) return;
|
||||
continue;
|
||||
}
|
||||
/* Delimiter name into dname */
|
||||
for (p = dname ; ! m_whitespace((M_WCHAR) c) ; c = getc(ddat))
|
||||
{
|
||||
if (c == EOF)
|
||||
{
|
||||
warning("Unexpected EOF");
|
||||
exit(TRUE);
|
||||
}
|
||||
if (p - dname >= DNAMELEN)
|
||||
{
|
||||
while (! m_whitespace((M_WCHAR) c) && c != EOF) c = getc(ddat);
|
||||
if (c == EOF)
|
||||
{
|
||||
warning("Unexpected EOF");
|
||||
exit(TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
*p++ = m_upper(c);
|
||||
}
|
||||
*p = M_EOS;
|
||||
/* Skip intervening white space */
|
||||
while (m_whitespace((M_WCHAR) c) && c != EOF) c = getc(ddat);
|
||||
if (c == EOF)
|
||||
{
|
||||
warning("Unexpected EOF");
|
||||
exit(TRUE);
|
||||
}
|
||||
/* Delimiter string into dstring */
|
||||
for (p = dstring;
|
||||
! m_whitespace((M_WCHAR) c) && c != EOF;
|
||||
c = getc(ddat))
|
||||
{
|
||||
if (p - dstring >= DELIMLEN)
|
||||
{
|
||||
m_error("Delimiter string too long");
|
||||
exit(TRUE);
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
*p = M_EOS;
|
||||
if (w_strlen(dstring) > maxd) maxd = w_strlen(dstring);
|
||||
/* Write definitions to output file. Save data for later. */
|
||||
incdelim();
|
||||
dstruct = (struct dstruct *)
|
||||
m_malloc(sizeof(struct dstruct), "delimiter structure");
|
||||
dstruct->string = (M_WCHAR *) m_malloc(w_strlen(dstring) + 1, "delimiter");
|
||||
w_strcpy(dstruct->string, dstring);
|
||||
dstruct->count = dcount;
|
||||
|
||||
mb_dname = MakeMByteString(dname);
|
||||
fprintf(delim, "#define %s %d\n", mb_dname, dcount);
|
||||
m_free(mb_dname,"multi-byte string");
|
||||
|
||||
for (i = 0 ; dname[i] ; i++)
|
||||
dname[i] = m_lower(dname[i]);
|
||||
mb_dname = MakeMByteString(dname);
|
||||
|
||||
mb_dstring = MakeMByteString(dstring);
|
||||
fprintf(delim,
|
||||
"M_DELIMEXTERN char %s[%d] M_DELIMINIT(\"",
|
||||
mb_dname,
|
||||
strlen(mb_dstring) + 1);
|
||||
|
||||
for (p = dstring ; *p ; p++)
|
||||
{
|
||||
char *pc;
|
||||
char mb_p[32]; /* arbitrarily large */
|
||||
int length, i;
|
||||
|
||||
length = wctomb(mb_p, *p);
|
||||
mb_p[length] = 0;
|
||||
|
||||
pc = mb_p;
|
||||
while (*pc)
|
||||
{
|
||||
if (*pc == '"' || *pc == '\\') putc('\\', delim);
|
||||
putc(*pc, delim);
|
||||
pc++;
|
||||
}
|
||||
}
|
||||
fputs("\") ;\n", delim);
|
||||
|
||||
dlmptr[dcount - 1] = MakeMByteString(dname);
|
||||
if (m_ntrtrie(dname, &delimtrie, dstruct))
|
||||
m_err1("Duplicate definition of %s", mb_dname);
|
||||
while (c != wnl)
|
||||
{
|
||||
if (c == EOF) break;
|
||||
c = getc(ddat);
|
||||
}
|
||||
m_free(mb_dname,"multi-byte string");
|
||||
m_free(mb_dstring,"multi-byte string");
|
||||
}
|
||||
dumpdlmptr();
|
||||
loading = FALSE;
|
||||
}
|
||||
|
||||
/* Output transition matrix */
|
||||
#if defined(M_PROTO)
|
||||
void nextcon(LOGICAL sparse)
|
||||
#else
|
||||
void nextcon(sparse)
|
||||
LOGICAL sparse;
|
||||
#endif
|
||||
{
|
||||
int i, j;
|
||||
int firstinrow;
|
||||
|
||||
if (sparse) {
|
||||
for (i = 0 ; i < ccount ; i++) {
|
||||
for (j = 0 ; j < dcount ; j++)
|
||||
if (transit(i, j)) nonzero++;
|
||||
nonzero++;
|
||||
}
|
||||
fprintf(delim,
|
||||
"M_DELIMEXTERN struct {\n %s context ;\n %s nextcon ;\n",
|
||||
contype, contype);
|
||||
fprintf(delim, " } m_trnsit [%d]\n", nonzero);
|
||||
|
||||
nonzero = 0;
|
||||
fprintf(delim, "#if defined(M_DELIMDEF)\n = {\n");
|
||||
fprintf(context, "M_CONEXTERN int m_trnsptr[%d]\n", ccount);
|
||||
fprintf(context, "#if defined(M_CONDEF)\n = {\n");
|
||||
for (i = 0 ; i < ccount ; i++) {
|
||||
firstinrow = 0;
|
||||
for (j = 0 ; j < dcount ; j++) {
|
||||
if (! transit(i, j)) continue;
|
||||
prtctxt(j, transit(i, j));
|
||||
if (! firstinrow) firstinrow = nonzero;
|
||||
}
|
||||
prtctxt(0, 0);
|
||||
if (i > 0) fprintf(context, ",\n");
|
||||
fprintf(context, " %d", firstinrow);
|
||||
}
|
||||
fprintf(delim, endif);
|
||||
fprintf(context, endif);
|
||||
}
|
||||
else {
|
||||
fprintf(context,
|
||||
"M_CONEXTERN %s m_nextcon[%d][%d]\n#if defined(M_CONDEF)\n = {\n",
|
||||
contype, ccount, dcount);
|
||||
for (i = 0 ; i < ccount ; i++) {
|
||||
fprintf(context, " {\n");
|
||||
for (j = 0 ; j < dcount ; j++) {
|
||||
fprintf(context, " %d", transit(i, j));
|
||||
if (j < dcount - 1) fprintf(context, ",\n");
|
||||
}
|
||||
fprintf(context, "}");
|
||||
if (i < ccount - 1) fprintf(context, ",");
|
||||
fprintf(context, "\n");
|
||||
}
|
||||
fprintf(context, endif);
|
||||
}
|
||||
}
|
||||
|
||||
/* If sparse matrix output option, generate a single element of transit
|
||||
array */
|
||||
void prtctxt(column, value)
|
||||
int column, value;
|
||||
{
|
||||
static LOGICAL first = TRUE;
|
||||
|
||||
if (! first) fprintf(delim, ",\n");
|
||||
first = FALSE;
|
||||
fprintf(delim, " %d, %d", column, value);
|
||||
nonzero++;
|
||||
}
|
||||
|
||||
|
||||
/* Read the next input character */
|
||||
#if defined(M_PROTO)
|
||||
int readchar(LOGICAL cap)
|
||||
#else
|
||||
int readchar(cap)
|
||||
LOGICAL cap;
|
||||
#endif
|
||||
{
|
||||
int c;
|
||||
M_WCHAR wnl;
|
||||
|
||||
mbtowc(&wnl, "\n", 1);
|
||||
|
||||
c = mb_getwc(cdat); /* use mb_getwc so we read multi-byte chars */
|
||||
if (cap && c != EOF) c = m_upper(c);
|
||||
|
||||
if (c == wnl) m_line++;
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
/* Called by utility procedure m_error() -- has content in other programs
|
||||
that use m_error() */
|
||||
void skiptoend(M_NOPAR)
|
||||
{
|
||||
}
|
||||
|
||||
/* Return a character to the input stream for re-reading */
|
||||
void unread(c)
|
||||
int c;
|
||||
{
|
||||
M_WCHAR wnl;
|
||||
|
||||
mbtowc(&wnl, "\n", 1);
|
||||
|
||||
ungetc(c, cdat);
|
||||
if (c == wnl) m_line--;
|
||||
}
|
||||
81
cde/programs/dthelp/parser/pass2/util/dtddef.h
Normal file
81
cde/programs/dthelp/parser/pass2/util/dtddef.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* $XConsortium: dtddef.h /main/3 1995/11/08 11:03:31 rswiston $ */
|
||||
/* Copyright (c) 1988, 1989 Hewlett-Packard Co. */
|
||||
/* Dtddef.h contains definitions relevant to document-type
|
||||
definitions */
|
||||
|
||||
typedef int M_ELEMENT ;
|
||||
typedef int M_ARC ;
|
||||
typedef int M_STATE ;
|
||||
typedef int M_ANDGROUP ;
|
||||
|
||||
/* Possible element content types */
|
||||
#define M_REGEXP 0
|
||||
#define M_ANY 1
|
||||
#define M_NONE 2
|
||||
#define M_CDATA 3
|
||||
#define M_RCDATA 4
|
||||
|
||||
typedef struct{
|
||||
int enptr, start, content, inptr, exptr, parptr, parcount, srefptr ;
|
||||
unsigned int smin : 1, emin : 1, useoradd : 1 ;
|
||||
} M_ELTSTRUCT ;
|
||||
|
||||
typedef struct {
|
||||
int paramname, type, kwlist, deftype ;
|
||||
M_WCHAR *defval ;
|
||||
} M_PARAMETER ;
|
||||
/* Possible parameter default types */
|
||||
#define M_NAMEDEF 0
|
||||
#define M_CURRENT 1
|
||||
#define M_REQUIRED 2
|
||||
#define M_NULLDEF 3
|
||||
#define M_CHANGEDCUR 4
|
||||
|
||||
/* Possible parameter types */
|
||||
#define M_KEYWORD 0
|
||||
#define M_ID 1
|
||||
#define M_IDRF 2
|
||||
#define M_IDRFS 3
|
||||
#define M_NAMEPAR 4
|
||||
#define M_NAMES 5
|
||||
#define M_NMTOKEN 6
|
||||
#define M_NMSTOKEN 7
|
||||
#define M_NUMBER 8
|
||||
#define M_NUMS 9
|
||||
#define M_NUTOKEN 10
|
||||
#define M_NUSTOKEN 11
|
||||
#define M_CDATT 12
|
||||
#define M_ENTATT 13
|
||||
|
||||
typedef struct {
|
||||
int sref ;
|
||||
int entity ;
|
||||
int next ;
|
||||
} M_SREF ;
|
||||
|
||||
typedef struct {
|
||||
unsigned final : 1, datacontent : 1 ;
|
||||
unsigned first : 14 ;
|
||||
} M_STATESTRUCT ;
|
||||
|
||||
typedef struct {
|
||||
M_STATE start ;
|
||||
M_ANDGROUP next ;
|
||||
} M_ANDSTRUCT ;
|
||||
|
||||
typedef struct {
|
||||
M_ELEMENT element ;
|
||||
int next ;
|
||||
} M_EXCEPTION ;
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned label : 15;
|
||||
unsigned optional : 1;
|
||||
int minim ;
|
||||
M_ANDGROUP group ;
|
||||
M_STATE to ;
|
||||
M_ARC next ;
|
||||
} M_ARCSTRUCT ;
|
||||
|
||||
|
||||
46
cde/programs/dthelp/parser/pass2/util/dtdext.h
Normal file
46
cde/programs/dthelp/parser/pass2/util/dtdext.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* $XConsortium: dtdext.h /main/3 1995/11/08 11:03:45 rswiston $ */
|
||||
/* Copyright (c) 1988, 1989 Hewlett-Packard Co. */
|
||||
/* Dtdext.h contains the dtd-independent external forms of
|
||||
declarations relevant to document-type definitions. The
|
||||
definition form of these declarations is contained in files
|
||||
dtd.h and arc.h generated by BUILD. */
|
||||
|
||||
|
||||
#include "dtddef.h"
|
||||
|
||||
extern M_PTRIE m_entree[] ;
|
||||
|
||||
extern M_WCHAR m_ename[] ;
|
||||
|
||||
extern int m_elcount ;
|
||||
extern M_ELTSTRUCT m_element[] ;
|
||||
|
||||
extern M_WCHAR m_keyword[] ;
|
||||
|
||||
extern M_WCHAR m_defval[] ;
|
||||
|
||||
extern struct {
|
||||
int keyword, next ;
|
||||
} m_ptype[] ;
|
||||
|
||||
extern M_PARAMETER m_parameter[] ;
|
||||
|
||||
extern M_WCHAR m_pname[] ;
|
||||
|
||||
extern M_PTRIE m_maptree[] ;
|
||||
|
||||
extern M_PTRIE m_sreftree[] ;
|
||||
|
||||
extern int m_map[] ;
|
||||
|
||||
extern M_SREF m_sref[] ;
|
||||
|
||||
extern M_STATESTRUCT m_state[] ;
|
||||
|
||||
extern M_ANDSTRUCT m_andgroup[] ;
|
||||
|
||||
extern M_EXCEPTION m_exception[] ;
|
||||
|
||||
extern M_ARCSTRUCT m_arc[] ;
|
||||
|
||||
|
||||
27
cde/programs/dthelp/parser/pass2/util/emptyfil.c
Normal file
27
cde/programs/dthelp/parser/pass2/util/emptyfil.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* $XConsortium: emptyfil.c /main/3 1995/11/08 11:04:00 rswiston $ */
|
||||
/* Copyright (c) 1988, 1989 Hewlett-Packard Co. */
|
||||
/* Creates a file with nothing in it */
|
||||
#include <stdio.h>
|
||||
#if defined(MSDOS)
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include "basic.h"
|
||||
|
||||
void main(
|
||||
#if defined(M_PROTO)
|
||||
int argc, char **argv
|
||||
#endif
|
||||
) ;
|
||||
|
||||
void main(argc, argv)
|
||||
int argc ;
|
||||
char **argv ;
|
||||
{
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: emptyfil filename\n") ;
|
||||
exit(1) ;
|
||||
}
|
||||
if (! fopen(argv[1], "w"))
|
||||
fprintf(stderr, "Unable to open %s\n", argv[1]) ;
|
||||
return 0;
|
||||
}
|
||||
21
cde/programs/dthelp/parser/pass2/util/entdef.h
Normal file
21
cde/programs/dthelp/parser/pass2/util/entdef.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* $XConsortium: entdef.h /main/3 1995/11/08 11:04:14 rswiston $ */
|
||||
/* Copyright (c) 1988, 1989 Hewlett-Packard Co. */
|
||||
/* Entdef.h contains definitions relevant to entities */
|
||||
|
||||
#define M_GENERAL 0
|
||||
#define M_SYSTEM 1
|
||||
#define M_STARTTAG 2
|
||||
#define M_ENDTAG 3
|
||||
#define M_MD 4
|
||||
#define M_MS 5
|
||||
#define M_PI 6
|
||||
#define M_CDATAENT 7
|
||||
#define M_SDATA 8
|
||||
#define M_CODEPI 9
|
||||
#define M_CODESDATA 10
|
||||
|
||||
#define M_DBUILD 1
|
||||
#define M_DELTDEF 2
|
||||
#define M_DPARSER 3
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user