home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / pascal2c / trans.h < prev    next >
C/C++ Source or Header  |  1992-08-04  |  82KB  |  1,891 lines

  1. /* "p2c", a Pascal to C translator, version 1.20.
  2.    Copyright (C) 1989, 1990, 1991 Free Software Foundation.
  3.    Author: Dave Gillespie.
  4.    Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
  5.  
  6.    #######################################################################
  7.    #                                                                     #
  8.    #  08-04-1992                                                         #
  9.    #                                                                     #
  10.    #  Modified by Bernt Karasch for OS/2 v 2.0 (gcc/emx and nmake)       #
  11.    #  (Internet : hermann.gies@ruba.rz.ruhr-uni-bochum.dbp.de            #
  12.    #   Snailmail: Ruhr-Universitaet Bochum, Institut fuer Mineralogie,   #
  13.    #              Herrn Bernt Karasch, Universitaetsstrasse 150,         #
  14.    #              W-4630 Bochum 1, Federal Republic of Germany)          #
  15.    #                                                                     #
  16.    #  Modifications marked with ### BK                                   #
  17.    #                                                                     #
  18.    #######################################################################
  19.  
  20. This program is free software; you can redistribute it and/or modify
  21. it under the terms of the GNU General Public License as published by
  22. the Free Software Foundation (any version).
  23.  
  24. This program is distributed in the hope that it will be useful,
  25. but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27. GNU General Public License for more details.
  28.  
  29. You should have received a copy of the GNU General Public License
  30. along with this program; see the file COPYING.  If not, write to
  31. the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  32.  
  33.  
  34.  
  35.  
  36. #ifdef __STDC__
  37. # define PP(x)  x             /* use true prototypes */
  38. # define PV()   (void)
  39. # define Anyptr void
  40. # define __CAT__(a,b)a##b
  41. #else
  42. # define PP(x)  ()            /* use old-style declarations */
  43. # define PV()   ()
  44. # define Anyptr char
  45. # define __ID__(a)a
  46. # define __CAT__(a,b)__ID__(a)b
  47. #endif
  48.  
  49. #define Static                /* For debugging purposes */
  50.  
  51.  
  52.  
  53. #include <stdio.h>
  54.  
  55.  
  56. /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
  57.    or -DBSD=1 for BSD systems. */
  58.  
  59. #ifdef M_XENIX
  60. # define BSD 0
  61. #endif
  62.  
  63. #ifdef FILE       /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
  64. # ifndef BSD
  65. #  define BSD 1
  66. # endif
  67. #endif
  68.  
  69. #ifdef BSD
  70. # if !BSD
  71. #  undef BSD
  72. # endif
  73. #endif
  74.  
  75.  
  76. #ifdef __STDC__
  77. # include <stddef.h>
  78. # include <stdlib.h>
  79. # include <limits.h>
  80. #else
  81. # ifndef BSD
  82. #  include <malloc.h>
  83. #  include <memory.h>
  84. #  include <values.h>
  85. # endif
  86. # define EXIT_SUCCESS 0
  87. # define EXIT_FAILURE 1
  88. # define CHAR_BIT 8
  89. # define LONG_MAX (((unsigned long)~0L) >> 1)
  90. # define LONG_MIN (- LONG_MAX - 1)
  91. #endif
  92.  
  93.  
  94.  
  95. #if defined(BSD) && !defined(__STDC__)
  96. # include <strings.h>
  97. # define memcpy(a,b,n) bcopy(b,a,n)
  98. # define memcmp(a,b,n) bcmp(a,b,n)
  99. char *malloc(), *realloc();
  100. #else
  101. # include <string.h>
  102. #endif
  103.  
  104. #include <ctype.h>
  105.  
  106.  
  107. #ifdef __GNUC__      /* Fast, in-line version of strcmp */
  108. # define strcmp(a,b) ({ char *_aa = (a), *_bb = (b); int _diff;  \
  109.             for (;;) {    \
  110.                 if (!*_aa && !*_bb) { _diff = 0; break; }   \
  111.                             if (*_aa++ != *_bb++)    \
  112.                 { _diff = _aa[-1] - _bb[-1]; break; }   \
  113.             } _diff; })
  114. #endif
  115.  
  116.  
  117. #if defined(HASDUMPS) && defined(define_globals)
  118. # define DEFDUMPS
  119. #endif
  120.  
  121.  
  122.  
  123. /* Constants */
  124.  
  125. #undef MININT      /* we want the Pascal definitions, not the local C definitions */
  126. #undef MAXINT
  127.  
  128. #define MININT     0x80000000
  129. #define MAXINT     0x7fffffff
  130.  
  131.  
  132. #ifndef EXIT_SUCCESS
  133. # define EXIT_SUCCESS  0
  134. # define EXIT_FAILURE  1
  135. #endif
  136.  
  137.  
  138. #ifndef P2C_HOME
  139. # ifdef citPWS
  140. /* ### BK #  define    P2C_HOME        "/lib/p2c" */
  141. #  define    P2C_HOME        "\\emx\\p2c"
  142. # else
  143. /* ### BK #  define    P2C_HOME        "/usr/local/p2c"      sounds reasonable... */
  144. #  define    P2C_HOME        "\\emx\\p2c"     /* sounds reasonable... */
  145. # endif
  146. #endif
  147.  
  148. #ifdef define_globals
  149. char *p2c_home = P2C_HOME;
  150. #else
  151. extern char *p2c_home;
  152. #endif
  153.  
  154. #define P2C_VERSION  "1.20"
  155.  
  156.  
  157.  
  158.  
  159. /* Types */
  160.  
  161. #ifdef __STDC__
  162. typedef void *anyptr;
  163. #else
  164. typedef char *anyptr;
  165. #endif
  166.  
  167. typedef unsigned char uchar;
  168.  
  169.  
  170.  
  171. /* Ought to rearrange token assignments at the next full re-compile */
  172.  
  173. typedef enum E_token {
  174.     TOK_NONE,
  175.  
  176.     /* reserved words */
  177.     TOK_AND, TOK_ARRAY, TOK_BEGIN, TOK_CASE, TOK_CONST,
  178.     TOK_DIV, TOK_DO, TOK_DOWNTO, TOK_ELSE, TOK_END,
  179.     TOK_FILE, TOK_FOR, TOK_FUNCTION, TOK_GOTO, TOK_IF,
  180.     TOK_IN, TOK_LABEL, TOK_MOD, TOK_NIL, TOK_NOT,
  181.     TOK_OF, TOK_OR, TOK_PACKED, TOK_PROCEDURE, TOK_PROGRAM,
  182.     TOK_RECORD, TOK_REPEAT, TOK_SET, TOK_THEN, TOK_TO,
  183.     TOK_TYPE, TOK_UNTIL, TOK_VAR, TOK_WHILE, TOK_WITH,
  184.  
  185.     /* symbols */
  186.     TOK_DOLLAR, TOK_STRLIT, TOK_LPAR, TOK_RPAR, TOK_STAR,
  187.     TOK_PLUS, TOK_COMMA, TOK_MINUS, TOK_DOT, TOK_DOTS,
  188.     TOK_SLASH, TOK_INTLIT, TOK_REALLIT, TOK_COLON, TOK_ASSIGN,
  189.     TOK_SEMI, TOK_NE, TOK_LT, TOK_GT, TOK_LE, TOK_GE,
  190.     TOK_EQ, TOK_LBR, TOK_RBR, TOK_HAT,
  191.     TOK_INCLUDE, TOK_ENDIF,
  192.     TOK_IDENT, TOK_MININT, TOK_EOF,
  193.  
  194.     /* C symbols */
  195.     TOK_ARROW, TOK_AMP, TOK_VBAR, TOK_BANG,
  196.     TOK_TWIDDLE, TOK_PERC, TOK_QM,
  197.     TOK_LTLT, TOK_GTGT, TOK_EQEQ, TOK_BANGEQ,
  198.     TOK_PLPL, TOK_MIMI, TOK_ANDAND, TOK_OROR,
  199.     TOK_LBRACE, TOK_RBRACE, TOK_CHARLIT,
  200.  
  201.     /* HP Pascal tokens */
  202.     TOK_ANYVAR, TOK_EXPORT, TOK_IMPLEMENT, TOK_IMPORT, TOK_MODULE,
  203.     TOK_OTHERWISE, TOK_RECOVER, TOK_TRY,
  204.  
  205.     /* Turbo Pascal tokens */
  206.     TOK_SHL, TOK_SHR, TOK_XOR, TOK_INLINE, TOK_ABSOLUTE,
  207.     TOK_INTERRUPT, TOK_ADDR, TOK_HEXLIT,
  208.  
  209.     /* Oregon Software Pascal tokens */
  210.     TOK_ORIGIN, TOK_INTFONLY,
  211.  
  212.     /* VAX Pascal tokens */
  213.     TOK_REM, TOK_VALUE, TOK_VARYING, TOK_OCTLIT, TOK_COLONCOLON,
  214.     TOK_STARSTAR,
  215.  
  216.     /* Modula-2 tokens */
  217.     TOK_BY, TOK_DEFINITION, TOK_ELSIF, TOK_FROM, TOK_LOOP,
  218.     TOK_POINTER, TOK_QUALIFIED, TOK_RETURN,
  219.  
  220.     /* UCSD Pascal tokens */
  221.     TOK_SEGMENT,
  222.  
  223.     TOK_LAST
  224. } Token;
  225.  
  226. #ifdef define_globals
  227. char *toknames[(int)TOK_LAST] = { "",
  228.     "AND", "ARRAY", "BEGIN", "CASE", "CONST",
  229.     "DIV", "DO", "DOWNTO", "ELSE", "END",
  230.     "FILE", "FOR", "FUNCTION", "GOTO", "IF",
  231.     "IN", "LABEL", "MOD", "NIL", "NOT",
  232.     "OF", "OR", "PACKED", "PROCEDURE", "PROGRAM",
  233.     "RECORD", "REPEAT", "SET", "THEN", "TO",
  234.     "TYPE", "UNTIL", "VAR", "WHILE", "WITH",
  235.  
  236.     "a '$'", "a string literal", "a '('", "a ')'", "a '*'",
  237.     "a '+'", "a comma", "a '-'", "a '.'", "'..'",
  238.     "a '/'", "an integer", "a real number", "a colon", "a ':='",
  239.     "a semicolon", "a '<>'", "a '<'", "a '>'", "a '<='", "a '>='",
  240.     "an '='", "a '['", "a ']'", "a '^'",
  241.     "an \"include\" file", "$end$",
  242.     "an identifier", "an integer", "end of file",
  243.  
  244.     "an '->'", "an '&'", "a '|'", "a '!'", 
  245.     "a '~'", "a '%'", "a '?'",
  246.     "a '<<'", "a '>>'", "a '=='", "a '!='",
  247.     "a '++'", "a '--'", "a '&&'", "a '||'",
  248.     "a '{'", "a '}'", "a character literal",
  249.  
  250.     "ANYVAR", "EXPORT", "IMPLEMENT", "IMPORT", "MODULE",
  251.     "OTHERWISE", "RECOVER", "TRY",
  252.  
  253.     "SHL", "SHR", "XOR", "INLINE", "ABSOLUTE",
  254.     "INTERRUPT", "an '@'", "a hex integer",
  255.  
  256.     "ORIGIN", "INTF-ONLY",
  257.  
  258.     "REM", "VALUE", "VARYING", "an octal integer", "a '::'",
  259.     "a '**'",
  260.  
  261.     "BY", "DEFINITION", "ELSIF", "FROM", "LOOP",
  262.     "POINTER", "QUALIFIED", "RETURN",
  263.  
  264.     "SEGMENT"
  265. } ;
  266. #else
  267. extern char *toknames[];
  268. #endif /*define_globals*/
  269.  
  270. typedef struct S_strlist {
  271.     struct S_strlist *next;
  272.     long value;
  273.     char s[1];
  274. } Strlist;
  275.  
  276.  
  277.  
  278. typedef struct S_value {
  279.     struct S_type *type;
  280.     long i;
  281.     char *s;
  282. } Value;
  283.  
  284.  
  285.  
  286. /* "Symbol" notes:
  287.  *
  288.  * The symbol table is used for several things.  Mainly it records all
  289.  * identifiers in the Pascal program (normally converted to upper case).
  290.  * Also used for recording certain properties about C and Pascal names.
  291.  *
  292.  * The symbol table is a hash table of binary trees.
  293.  */
  294.  
  295. #define AVOIDNAME  0x1         /* Avoid this name in C code */
  296. #define WARNNAME   0x2           /* Warn if using this name in C code */
  297. #define AVOIDGLOB  0x4           /* Avoid C name except private to module */
  298. #define NOSIDEEFF  0x8           /* Function by this name has no side effects */
  299. #define STRUCTF    0x10           /* Function by this name is a StructFunction */
  300. #define STRLAPF    0x20           /* Function by this name is a StrlapFunction */
  301. #define LEAVEALONE 0x40           /* Do not use custom handler for function */
  302. #define DETERMF    0x80           /* Function by this name is Deterministic */
  303. #define FMACREC    0x100       /* Used by FieldMacro stuff */
  304. #define AVOIDFIELD 0x200       /* Avoid this name as a struct field name */
  305. #define NEEDSTATIC 0x400       /* This name must be declared static */
  306. #define KWPOSS     0x800       /* This word may be a keyword */
  307. #define FUNCBREAK  0x7000      /* Line breaking flags (see sys.p2crc) */
  308. # define FALLBREAK  0x1000     /*  Break at all commas if at any */
  309. # define FSPCARG1   0x2000     /*  First argument is special */
  310. # define FSPCARG2   0x3000     /*  First two arguments are special */
  311. # define FSPCARG3   0x4000     /*  First three arguments are special */
  312. #define WARNLIBR   0x8000      /* Warn for all uses of this library function */
  313. #define FWDPARAM   0x10000     /* Was a param name for forward-declared func */
  314. #define SSYNONYM   0x20000     /* Symbol is a synonym for another */
  315.  
  316. typedef struct S_symbol {
  317.     struct S_symbol *left;     /* Left pointer in binary tree */
  318.     struct S_symbol *right;    /* Right pointer in binary tree */
  319.     struct S_meaning *mbase;   /* First normal meaning for this symbol */
  320.     struct S_meaning *fbase;   /* First record-field meaning for this symbol */
  321.     Strlist *symbolnames;      /* List of NameOf's for this name */
  322.     long flags;               /* (above) */
  323.     Token kwtok;           /* Token, if symbol is a keyword */
  324.     char name[1];              /* Pascal name (actually variable-sized) */
  325. } Symbol;
  326.  
  327.  
  328.  
  329. /* "Meaning" notes:
  330.  *
  331.  * This represents one meaning of a symbol (see below).  Meanings are
  332.  * organized in a tree of contexts (i.e., scopes), and also in linked
  333.  * lists of meanings per symbol.  Fields described in the following are
  334.  * undefined for kinds where they are not listed.  Other fields are
  335.  * defined in all kinds of meanings.
  336.  *
  337.  * MK_MODULE:  Program, module, or unit.
  338.  *    mp->anyvarflag = 1 if main program, 0 if module.
  339.  *    mp->cbase => First meaning in module's context.
  340.  *
  341.  * MK_CONST:  Pascal CONST.
  342.  *    mp->type => Type of constant, same as mp->constdefn->type & mp->val.type.
  343.  *    mp->anyvarflag = 1 if FoldConstants was true when defined.
  344.  *    mp->constdefn => Expression for the value of the constant.
  345.  *    mp->val = Value of the const, if can be evaluated, else val.type is NULL.
  346.  *    mp->xnext => Next constant in enumeration, else NULL.
  347.  *    mp->isreturn = 1 if constant was declared as a macro (with #define).
  348.  *
  349.  * MK_TYPE:  Pascal type name.
  350.  *    mp->type => Type which name represents.
  351.  *
  352.  * MK_VAR:  Normal variable.
  353.  *    mp->type => Type of variable.
  354.  *    mp->constdefn => Initializer for variable, else NULL.
  355.  *    mp->varstructflag = 1 if variable is in parent function's varstruct.
  356.  *    mp->isforward = 1 if should be declared static.
  357.  *    mp->isfunction = 1 if should be declared extern.
  358.  *    mp->namedfile = 1 if this file variable has a shadow file-name variable.
  359.  *    mp->bufferedfile = 1 if this file variable has a shadow buffer variable.
  360.  *    mp->val.s => name format string if temporary var, else NULL.
  361.  *
  362.  * MK_VARREF:  Variable always referenced through a pointer.
  363.  *    mp->type => Type "pointer to T" where T is type of variable.
  364.  *    mp->constdefn => Initializer for the pointer, else NULL.
  365.  *    (Others same as for MK_VAR.)
  366.  *
  367.  * MK_VARMAC:  Variable which has a VarMacro.
  368.  *    mp->type => Type of variable.
  369.  *    mp->constdefn => Expression for VarMacro definition.
  370.  *    (Others same as for MK_VAR.)
  371.  *
  372.  * MK_SPVAR:  Special variable.
  373.  *    mp->handler => C function to parse and translate the special variable.
  374.  *
  375.  * MK_FIELD:  Record/struct field name.
  376.  *    mp->ctx, cbase = unused (unlike other meanings).
  377.  *    mp->cnext => Next field in record or variant.
  378.  *    mp->type => Type of field (base type if a bit-field).
  379.  *    mp->rectype => Type of containing record.
  380.  *    mp->constdefn => Expression for definition if FieldMacro, else NULL.
  381.  *    mp->val.i = Number of bits if bit-field, or 0 if normal field.
  382.  *    mp->val.type => True type of bit-field, else same as mp->type.
  383.  *    mp->isforward = 1 if tag field for following variant, else 0.
  384.  *    mp->namedfile = 1 if this file field has a shadow file-name field.
  385.  *    mp->bufferedfile = 1 if this file field has a shadow buffer field.
  386.  *
  387.  * MK_VARIANT:  Header for variant record case.
  388.  *    mp->ctx => First field in variant (unlike other meanings).
  389.  *    mp->cbase = unused (unlike other meanings).
  390.  *    mp->cnext => Next variant in record (or next sub-variant in variant).
  391.  *    mp->rectype => Type of containing record.
  392.  *    mp->val = Tag value of variant.
  393.  *
  394.  * MK_LABEL:  Statement label.
  395.  *    mp->val.i => Case number if used by non-local gotos, else -1.
  396.  *    mp->xnext => MK_VAR representing associated jmp_buf variable.
  397.  *    (All optional fields are unused.)
  398.  *
  399.  * MK_FUNCTION:  Procedure or function.
  400.  *    mp->type => TK_FUNCTION type.
  401.  *    mp->cbase => First meaning in procedure's context (when isfunction is 1,
  402.  *           this will always be the return-value meaning.)
  403.  *    mp->val.i => Body of the function (cast to Stmt *).
  404.  *    mp->constdefn => Expression for definition if FuncMacro, else NULL.
  405.  *    mp->handler => C function to adjust parse tree if predefined, else NULL.
  406.  *    mp->isfunction = 1 if function, 0 if procedure.
  407.  *    mp->isforward = 1 if function has been declared forward.
  408.  *    mp->varstructflag = 1 if function has a varstruct.
  409.  *    mp->needvarstruct = 1 if no varstruct yet but may need one.
  410.  *    mp->namedfile = 1 if function should be declared "inline".
  411.  *
  412.  * MK_SPECIAL:  Special, irregular built-in function.
  413.  *    mp->handler => C function to parse and translate the special function.
  414.  *    mp->constdefn => Expression for definition if FuncMacro, else NULL.
  415.  *    mp->isfunction = 1 if function, 0 if procedure.
  416.  *
  417.  * MK_PARAM:  Procedure or function parameter, or function return value.
  418.  *    mp->type => Type of parameter.
  419.  *    mp->isreturn = 1 if a function return value (not on parameter list).
  420.  *    mp->xnext => Next parameter of function.
  421.  *    mp->fakeparam = 1 if a fake parameter (e.g., conformant array size).
  422.  *    mp->othername => Name of true param if this one is a local copy.
  423.  *    mp->rectype => Type of true param if this one is a local copy.
  424.  *             If a normal copy param, will be "pointer to" mp->type.
  425.  *             If copied for varstruct reasons, will be same as mp->type.
  426.  *    mp->varstructflag = 1 if variable is in parent function's varstruct.
  427.  *
  428.  * MK_VARPARAM:  VAR parameter, or StructFunction return value.
  429.  *    mp->type => Type "pointer to T" where T is type of parameter.
  430.  *    mp->anyvarflag = 1 if no type checking is to be applied to parameter.
  431.  *    mp->isreturn = 1 if a StructFunction return value (will be first param).
  432.  *    (Others same as for MK_PARAM.)
  433.  *
  434.  * MK_VARPARAM with mp->type == tp_anyptr:  Turbo "typeless var" parameter.
  435.  *    mp->type = tp_anyptr.
  436.  *    mp->anyvarflag = 1.
  437.  *    (Others same as for MK_PARAM.)
  438.  *
  439.  * MK_VARPARAM with mp->type == tp_strptr:  HP Pascal "var s:string" parameter.
  440.  *    mp->type = tp_strptr.
  441.  *    mp->anyvarflag = 1 if a separate "strmax" parameter is passed.
  442.  *    (Others same as for MK_PARAM.)
  443.  *
  444.  * MK_SYNONYM:  Meaning which should be treated as identical to another.
  445.  *    mp->xnext => Actual meaning to be used.
  446.  *
  447.  */
  448.  
  449. enum meaningkind {
  450.     MK_NONE, MK_SPECIAL,
  451.     MK_MODULE, MK_FUNCTION, MK_CONST, MK_VAR, MK_TYPE,
  452.     MK_FIELD, MK_LABEL, MK_VARIANT,
  453.     MK_PARAM, MK_VARPARAM, MK_VARREF, MK_VARMAC,
  454.     MK_SPVAR, MK_SYNONYM,
  455.     MK_LAST
  456. } ;
  457.  
  458. #ifdef DEFDUMPS
  459. char *meaningkindnames[(int)MK_LAST] = {
  460.     "MK_NONE", "MK_SPECIAL",
  461.     "MK_MODULE", "MK_FUNCTION", "MK_CONST", "MK_VAR", "MK_TYPE",
  462.     "MK_FIELD", "MK_LABEL", "MK_VARIANT",
  463.     "MK_PARAM", "MK_VARPARAM", "MK_VARREF", "MK_VARMAC",
  464.     "MK_SPVAR", "MK_SYNONYM"
  465. } ;
  466. #endif /*DEFDUMPS*/
  467.  
  468. typedef struct S_meaning {
  469.     struct S_meaning *snext;   /* Next meaning for this symbol */
  470.     struct S_meaning *cnext;   /* Next meaning in this meaning's context */
  471.     struct S_meaning *cbase;   /* First meaning in this context */
  472.     struct S_meaning *ctx;     /* Context of this meaning */
  473.     struct S_meaning *xnext;   /* (above) */
  474.     struct S_meaning *dtype;   /* Declared type name, if any */
  475.     struct S_symbol *sym;      /* Symbol of which this is a meaning */
  476.     struct S_type *type;       /* (above) */
  477.     struct S_type *rectype;    /* (above) */
  478.     struct S_expr *constdefn;  /* (above) */
  479.     enum meaningkind kind;     /* Kind of meaning */
  480.     unsigned needvarstruct:1,  /* (above) */
  481.              varstructflag:1,  /* (above) */
  482.              wasdeclared:1,    /* Declaration has been written for meaning */
  483.              istemporary:1,    /* Is a temporary variable */
  484.              isforward:1,      /* (above) */
  485.              isfunction:1,     /* (above) */
  486.              anyvarflag:1,     /* (above) */
  487.              isactive:1,       /* Meaning is currently in scope */
  488.              exported:1,       /* Meaning is visible outside this module */
  489.              warnifused:1,     /* WarnNames was 1 when meaning was declared */
  490.              dumped:1,           /* Has been dumped (for debugging) */
  491.              isreturn:1,       /* (above) */
  492.              fakeparam:1,      /* (above) */
  493.              namedfile:1,      /* (above) */
  494.              bufferedfile:1,   /* (above) */
  495.              volatilequal:1,   /* Object has C "volatile" qualifier */
  496.              constqual:1,      /* Object has C "const" qualifier */
  497.              dummy17:1, dummy18:1, dummy19:1, 
  498.          dummy20:1, dummy21:1, dummy22:1, dummy23:1, dummy24:1, dummy25:1, 
  499.          dummy26:1, dummy27:1, dummy28:1, dummy29:1, dummy30:1, dummy31:1;
  500.     Value val;               /* (above) */
  501.     int refcount;           /* Number of references to meaning in program */
  502.     char *name;               /* Print name (i.e., C name) of the meaning */
  503.     char *othername;           /* (above) */
  504.     struct S_expr *(*handler)();   /* Custom translator for procedure */
  505.     Strlist *comments;           /* Comments associated with meaning */
  506. } Meaning;
  507.  
  508.  
  509.  
  510. /* "Type" notes:
  511.  *
  512.  * This struct represents a data type.  Types are stored in a strange
  513.  * cross between Pascal and C semantics.  (This usually works out okay.)
  514.  *
  515.  * TK_INTEGER:  Base integer type.
  516.  *    The following types are TK_INTEGER:
  517.  *        tp_integer, tp_unsigned, tp_int, tp_uint, tp_sint.
  518.  *    All other integer types are represented by subranges.
  519.  *    tp->smin => Minimum value for integer.
  520.  *    tp->smax => Maximum value for integer.
  521.  *
  522.  * TK_CHAR:  Base character type.
  523.  *    The following types are TK_CHAR:  tp_char, tp_schar, tp_uchar.
  524.  *    All other character types are represented by subranges.
  525.  *    tp->smin => Minimum value for character.
  526.  *    tp->smax => Maximum value for character.
  527.  *
  528.  * TK_BOOLEAN:  Boolean type.
  529.  *    The only TK_BOOLEAN type is tp_boolean.
  530.  *    tp->smin => "False" expression.
  531.  *    tp->smax => "True" expression.
  532.  *
  533.  * TK_REAL:  Real types.
  534.  *    The only TK_REAL types are tp_real, tp_longreal, and/or the SINGLE type.
  535.  *
  536.  * TK_VOID:  C "void" type.
  537.  *    The only TK_VOID type is tp_void.
  538.  *
  539.  * TK_SUBR:  Subrange of ordinal type.
  540.  *    tp->basetype => a TK_INTEGER, TK_CHAR, TK_BOOLEAN, or TK_ENUM type.
  541.  *    tp->smin => Minimum ordinal value for subrange.
  542.  *    tp->smax => Maximum ordinal value for subrange.
  543.  *
  544.  * TK_ENUM:  Enumerated type.
  545.  *    tp->fbase => First enumeration constant.
  546.  *    tp->smin => Minimum value (zero).
  547.  *    tp->smax => Maximum value (number of choices minus 1).
  548.  *
  549.  * TK_POINTER:  Pointer type.
  550.  *    tp->basetype => Base type of pointer.
  551.  *    tp->smin => EK_NAME for type if not-yet-resolved forward; else NULL.
  552.  *    tp->fbase => Actual type name for tp->basetype, or NULL.
  553.  *    Only one pointer type is ever generated for a given other type;
  554.  *    each tp->pointertype points back to that type if it has been generated.
  555.  *
  556.  * TK_STRING:  Pascal string or VARYING OF CHAR type.
  557.  *    tp->basetype => tp_char.
  558.  *    tp->indextype => TK_SUBR from 0 to maximum string length.
  559.  *    tp->structdefd = 1 if type is for a conformant VARYING OF CHAR parameter.
  560.  *
  561.  * TK_RECORD:  Pascal record/C struct type.
  562.  *    tp->fbase => First field in record.
  563.  *    tp->structdefd = 1 if struct type has been declared in output.
  564.  *
  565.  * TK_ARRAY with smax == NULL:  Normal array type.
  566.  *    tp->basetype => Element type of array.
  567.  *    tp->indextype => Index type (usually a TK_SUBR).
  568.  *    tp->smin => Integer constant if SkipIndices was used, else NULL.
  569.  *    tp->smax = NULL.
  570.  *    tp->structdefd = 1 if type is for a conformant array parameter.
  571.  *    tp->fbase => Actual type name for tp->basetype, or NULL.
  572.  *
  573.  * TK_ARRAY with smax != NULL:  Large packed array type.
  574.  *    tp->basetype => Element type of C array (tp_ubyte/tp_sbyte/tp_sshort).
  575.  *    tp->indextype => Index type (usually a TK_SUBR).
  576.  *    tp->smin => Integer constant if SkipIndices was used, else NULL.
  577.  *    tp->smax => EK_TYPENAME for element type of Pascal array.
  578.  *    tp->escale = log-base-two of number of bits per packed element, else 0.
  579.  *    tp->issigned = 1 if packed array elements are signed, 0 if unsigned.
  580.  *    tp->structdefd = 1 if type is for a conformant array parameter.
  581.  *    tp->fbase => Actual type name for tp->basetype, or NULL.
  582.  *
  583.  * TK_SMALLARRAY:  Packed array fitting within a single integer.
  584.  *    (Same as for packed TK_ARRAY.)
  585.  *
  586.  * TK_SET:  Normal set type.
  587.  *    tp->basetype => tp_integer.
  588.  *    tp->indextype => Element type of the set.
  589.  *
  590.  * TK_SMALLSET:  Set fitting within a single integer.
  591.  *    (Same as for TK_SET.)
  592.  *
  593.  * TK_FILE:  File type (corresponds to C "FILE" type).
  594.  *    tp->basetype => Type of file elements, or tp_abyte if UCSD untyped file.
  595.  *    A Pascal "file" variable is represented as a TK_POINTER to a TK_FILE.
  596.  *
  597.  * TK_BIGFILE:  File type with attached buffers and name.
  598.  *    tp->basetype => Type of file elements, or tp_abyte if UCSD untyped file.
  599.  *    A Pascal "file" variable is represented directly as a TK_BIGFILE.
  600.  *
  601.  * TK_FUNCTION:  Procedure or procedure-pointer type.
  602.  *    tp->basetype => Return type of function, or tp_void if procedure.
  603.  *    tp->issigned = 1 if type has a generic static link.
  604.  *    tp->fbase => First argument (or StructFunction return buffer pointer).
  605.  *
  606.  * TK_PROCPTR:  Procedure pointer with static link.
  607.  *    tp->basetype => TK_FUNCTION type.
  608.  *    tp->fbase => Internal Meaning struct associated with basetype.
  609.  *    tp->escale = Value of StaticLinks when type was declared.
  610.  *
  611.  * TK_CPROCPTR:  Procedure pointer without static link.
  612.  *    tp->basetype => TK_FUNCTION type.
  613.  *    tp->fbase => Internal Meaning struct associated with basetype.
  614.  *    tp->escale = Value of StaticLinks = 0.
  615.  *
  616.  * TK_SPECIAL:  Special strange data type.
  617.  *    Only TK_SPECIAL type at present is tp_jmp_buf.
  618.  *
  619.  */
  620.  
  621. enum typekind {
  622.     TK_NONE,
  623.     TK_INTEGER, TK_CHAR, TK_BOOLEAN, TK_REAL, TK_VOID,
  624.     TK_SUBR, TK_ENUM, TK_POINTER, TK_STRING,
  625.     TK_RECORD, TK_ARRAY, TK_SET, TK_FILE, TK_FUNCTION,
  626.     TK_PROCPTR, TK_SMALLSET, TK_SMALLARRAY, TK_CPROCPTR,
  627.     TK_SPECIAL, TK_BIGFILE,
  628.     TK_LAST
  629. } ;
  630.  
  631. #ifdef DEFDUMPS
  632. char *typekindnames[(int)TK_LAST] = {
  633.     "TK_NONE",
  634.     "TK_INTEGER", "TK_CHAR", "TK_BOOLEAN", "TK_REAL", "TK_VOID",
  635.     "TK_SUBR", "TK_ENUM", "TK_POINTER", "TK_STRING",
  636.     "TK_RECORD", "TK_ARRAY", "TK_SET", "TK_FILE", "TK_FUNCTION",
  637.     "TK_PROCPTR", "TK_SMALLSET", "TK_SMALLARRAY", "TK_CPROCPTR",
  638.     "TK_SPECIAL", "TK_BIGFILE"
  639. } ;
  640. #endif /*DEFDUMPS*/
  641.  
  642. typedef struct S_type {
  643.     enum typekind kind;        /* Kind of type */
  644.     struct S_type *basetype;   /* (above) */
  645.     struct S_type *indextype;  /* (above) */
  646.     struct S_type *pointertype; /* Pointer to this type */
  647.     struct S_meaning *meaning; /* Name of this type, if any */
  648.     struct S_meaning *fbase;   /* (above) */
  649.     struct S_expr *smin;       /* (above) */
  650.     struct S_expr *smax;       /* (above) */
  651.     unsigned issigned:1,       /* (above) */
  652.              dumped:1,         /* Has been dumped (for debugging) */
  653.              structdefd:1,     /* (above) */
  654.              preserved:1;      /* Declared with preservetypes = 1 */
  655.     short escale;              /* (above) */
  656. } Type;
  657.  
  658.  
  659. /* "Expr" notes:
  660.  *
  661.  * Expression trees generally reflect C notation and semantics.  For example,
  662.  * EK_ASSIGN is not generated for string arguments; these would get an
  663.  * EK_BICALL to strcpy instead.
  664.  *
  665.  * The data type of each expression node is stored in its "val.type" field.
  666.  * The rest of the "val" field is used only when shown below.
  667.  * The "nargs" field always contains the number of arguments; the "args"
  668.  * array is allocated to that size and will contain non-NULL Expr pointers.
  669.  *
  670.  * EK_EQ, EK_NE, EK_LT, EK_GT, EK_LE, EK_GE:  Relational operators.
  671.  *    ep->nargs = 2.
  672.  *
  673.  * EK_PLUS:  Addition.
  674.  *    ep->nargs >= 2.
  675.  *
  676.  * EK_NEG:  Negation.
  677.  *    ep->nargs = 1.
  678.  *
  679.  * EK_TIMES:  Multiplication.
  680.  *    ep->nargs >= 2.
  681.  *
  682.  * EK_DIVIDE:  Real division.
  683.  *    ep->nargs = 2.
  684.  *
  685.  * EK_DIV:  Integer division.
  686.  *    ep->nargs = 2.
  687.  *
  688.  * EK_MOD:  Integer modulo (C "%" operator).
  689.  *    ep->nargs = 2.
  690.  *
  691.  * EK_OR, EK_AND:  Logical operators (C "&&" and "||").
  692.  *    ep->nargs = 2.
  693.  *
  694.  * EK_NOT:  Logical NOT (C "!" operator).
  695.  *    ep->nargs = 1.
  696.  *
  697.  * EK_BAND, EK_BOR, EK_BXOR:  Bitwise operators (C "&", "|", "^").
  698.  *    ep->nargs = 2.
  699.  *
  700.  * EK_BNOT:  Bitwise NOT (C "~" operator).
  701.  *    ep->nargs = 1.
  702.  *
  703.  * EK_LSH, EK_RSH:  Shift operators.
  704.  *    ep->nargs = 2.
  705.  *
  706.  * EK_HAT:  Pointer dereference.
  707.  *    ep->nargs = 1.
  708.  *
  709.  * EK_INDEX:  Array indexing.
  710.  *    ep->nargs = 2.
  711.  *
  712.  * EK_CAST:  "Soft" type cast, change data type retaining value.
  713.  *    ep->type => New data type.
  714.  *    ep->nargs = 1.
  715.  *
  716.  * EK_ACTCAST:  "Active" type cast, performs a computation as result of cast.
  717.  *    ep->type => New data type.
  718.  *    ep->nargs = 1.
  719.  *
  720.  * EK_LITCAST:  Literal type cast.
  721.  *    ep->nargs = 2.
  722.  *    ep->args[0] => EK_TYPENAME expression for name of new data type.
  723.  *    ep->args[1] => Argument of cast.
  724.  *
  725.  * EK_DOT:  Struct field extraction.
  726.  *    ep->nargs = 1.  (Only one of the following will be nonzero:)
  727.  *    ep->val.i => MK_FIELD being extracted (cast to Meaning *), else 0.
  728.  *    ep->val.s => Literal name of field being extracted, else NULL.
  729.  *
  730.  * EK_COND:  C conditional expression.
  731.  *    ep->nargs = 3.
  732.  *    ep->args[0] => Condition expression.
  733.  *    ep->args[1] => "Then" expression.
  734.  *    ep->args[2] => "Else" expression.
  735.  *
  736.  * EK_ADDR:  Address-of operator.
  737.  *    ep->nargs = 1.
  738.  *
  739.  * EK_SIZEOF:  Size-of operator.
  740.  *    ep->nargs = 1.
  741.  *    ep->args[0] => Argument expression, may be EK_TYPENAME.
  742.  *
  743.  * EK_CONST:  Literal constant.
  744.  *    ep->nargs = 0 or 1.
  745.  *    ep->val = Value of constant.
  746.  *    ep->args[0] => EK_NAME of printf format string for constant, if any.
  747.  *
  748.  * EK_LONGCONST:  Literal constant, type "long int".
  749.  *    (Same as for EK_CONST.)
  750.  *
  751.  * EK_VAR:  Variable name.
  752.  *    ep->nargs = 0.
  753.  *    ep->val.i => Variable being referenced (cast to Meaning *).
  754.  *
  755.  * EK_ASSIGN:  Assignment operator.
  756.  *    ep->nargs = 2.
  757.  *    ep->args[0] => Destination l-value expression.
  758.  *    ep->args[1] => Source expression.
  759.  *
  760.  * EK_POSTINC, EK_POSTDEC:  Post-increment/post-decrement operators.
  761.  *    ep->nargs = 1.
  762.  *
  763.  * EK_MACARG:  Placeholder for argument in expression for FuncMacro, etc.
  764.  *    ep->nargs = 0.
  765.  *    ep->val.i = Code selecting which argument.
  766.  *
  767.  * EK_CHECKNIL:  Null-pointer check.
  768.  *    ep->nargs = 1.
  769.  *
  770.  * EK_BICALL:  Call to literal function name.
  771.  *    ep->val.s => Name of function.
  772.  *
  773.  * EK_STRUCTCONST:  Structured constant.
  774.  *    ep->nargs = Number of elements in constant.
  775.  *    (Note:  constdefn points to an EK_CONST whose val.i points to this.)
  776.  *
  777.  * EK_STRUCTOF:  Repeated element in structured constant.
  778.  *    ep->nargs = 1.
  779.  *    ep->val.i = Number of repetitions.
  780.  *
  781.  * EK_COMMA:  C comma operator.
  782.  *    ep->nargs >= 2.
  783.  *
  784.  * EK_NAME:  Literal variable name.
  785.  *    ep->nargs = 0.
  786.  *    ep->val.s => Name of variable.
  787.  *
  788.  * EK_CTX:  Name of a context, with static links.
  789.  *    ep->nargs = 0.
  790.  *    ep->val.i => MK_FUNCTION or MK_MODULE to name (cast to Meaning *).
  791.  *
  792.  * EK_SPCALL:  Special function call.
  793.  *    ep->nargs = 1 + number of arguments to function.
  794.  *    ep->args[0] => Expression which is the function to call.
  795.  *
  796.  * EK_TYPENAME:  Type name.
  797.  *    ep->nargs = 0.
  798.  *    ep->val.type => Type whose name should be printed.
  799.  *
  800.  * EK_FUNCTION:  Normal function call.
  801.  *    ep->val.i => MK_FUNCTION being called (cast to Meaning *).
  802.  *
  803.  */
  804.  
  805. enum exprkind {
  806.     EK_EQ, EK_NE, EK_LT, EK_GT, EK_LE, EK_GE,
  807.     EK_PLUS, EK_NEG, EK_TIMES, EK_DIVIDE,
  808.     EK_DIV, EK_MOD,
  809.     EK_OR, EK_AND, EK_NOT,
  810.     EK_BAND, EK_BOR, EK_BXOR, EK_BNOT, EK_LSH, EK_RSH,
  811.     EK_HAT, EK_INDEX, EK_CAST, EK_DOT, EK_COND,
  812.     EK_ADDR, EK_SIZEOF, EK_ACTCAST,
  813.     EK_CONST, EK_VAR, EK_FUNCTION,
  814.     EK_ASSIGN, EK_POSTINC, EK_POSTDEC, EK_CHECKNIL,
  815.     EK_MACARG, EK_BICALL, EK_STRUCTCONST, EK_STRUCTOF,
  816.     EK_COMMA, EK_LONGCONST, EK_NAME, EK_CTX, EK_SPCALL,
  817.     EK_LITCAST, EK_TYPENAME,
  818.     EK_LAST
  819. } ;
  820.  
  821. #ifdef DEFDUMPS
  822. char *exprkindnames[(int)EK_LAST] = {
  823.     "EK_EQ", "EK_NE", "EK_LT", "EK_GT", "EK_LE", "EK_GE",
  824.     "EK_PLUS", "EK_NEG", "EK_TIMES", "EK_DIVIDE",
  825.     "EK_DIV", "EK_MOD",
  826.     "EK_OR", "EK_AND", "EK_NOT",
  827.     "EK_BAND", "EK_BOR", "EK_BXOR", "EK_BNOT", "EK_LSH", "EK_RSH",
  828.     "EK_HAT", "EK_INDEX", "EK_CAST", "EK_DOT", "EK_COND",
  829.     "EK_ADDR", "EK_SIZEOF", "EK_ACTCAST",
  830.     "EK_CONST", "EK_VAR", "EK_FUNCTION",
  831.     "EK_ASSIGN", "EK_POSTINC", "EK_POSTDEC", "EK_CHECKNIL",
  832.     "EK_MACARG", "EK_BICALL", "EK_STRUCTCONST", "EK_STRUCTOF",
  833.     "EK_COMMA", "EK_LONGCONST", "EK_NAME", "EK_CTX", "EK_SPCALL",
  834.     "EK_LITCAST", "EK_TYPENAME"
  835. } ;
  836. #endif /*DEFDUMPS*/
  837.  
  838. typedef struct S_expr {
  839.     enum exprkind kind;
  840.     short nargs;
  841.     Value val;
  842.     struct S_expr *args[1];    /* (Actually, variable-sized) */
  843. } Expr;
  844.  
  845.  
  846.  
  847. /* "Stmt" notes.
  848.  *
  849.  * Statements form linked lists along the "next" pointers.
  850.  * All other pointers are NULL and unused unless shown below.
  851.  *
  852.  * SK_ASSIGN:  Assignment or function call (C expression statement).
  853.  *    sp->exp1 => Expression to be evaluated.
  854.  *
  855.  * SK_RETURN:  C "return" statement.
  856.  *    sp->exp1 => Value to return, else NULL.
  857.  *
  858.  * SK_CASE:  C "switch" statement.
  859.  *    sp->exp1 => Switch selector expression.
  860.  *    sp->stm1 => List of SK_CASELABEL statements, followed by list of
  861.  *          statements that make up the "default:" clause.
  862.  *
  863.  * SK_CASELABEL:  C "case" label.
  864.  *    sp->exp1 => Case value.
  865.  *    sp->stm1 => List of SK_CASELABELs labelling the same clause, followed
  866.  *                by list of statements in that clause.
  867.  *
  868.  * SK_CASECHECK:  Case-value-range-error, occurs in "default:" clause.
  869.  *
  870.  * SK_IF:  C "if" statement.
  871.  *    sp->exp1 => Conditional expression.
  872.  *    sp->exp2 => Constant expression, "1" if this "if" should be else-if'd
  873.  *          on to parent "if".  NULL => follow ElseIf parameter.
  874.  *    sp->stm1 => "Then" clause.
  875.  *    sp->stm2 => "Else" clause.
  876.  *
  877.  * SK_FOR:  C "for" statement.
  878.  *    sp->exp1 => Initialization expression (may be NULL).
  879.  *    sp->exp2 => Conditional expression (may be NULL).
  880.  *    sp->exp3 => Iteration expression (may be NULL).
  881.  *    sp->stm1 => Loop body.
  882.  *
  883.  * SK_REPEAT:  C "do-while" statement.
  884.  *    sp->exp1 => Conditional expression (True = continue loop).
  885.  *    sp->stm1 => Loop body.
  886.  *
  887.  * SK_WHILE:  C "while" statement.
  888.  *    sp->exp1 => Conditional expression.
  889.  *    sp->stm1 => Loop body.
  890.  *
  891.  * SK_BREAK:  C "break" statement.
  892.  *
  893.  * SK_CONTINUE:  C "continue" statement.
  894.  *
  895.  * SK_TRY:  HP Pascal TRY-RECOVER statement.
  896.  *    sp->exp1->val.i = Global serial number of the TRY statement.
  897.  *    sp->exp2 = Non-NULL if must generate a label for RECOVER block.
  898.  *    sp->stm1 => TRY block.
  899.  *    sp->stm2 => RECOVER block.
  900.  *
  901.  * SK_GOTO:  C "goto" statement.
  902.  *    sp->exp1 => EK_NAME for the label number or name.
  903.  *
  904.  * SK_LABEL:  C statement label.
  905.  *    sp->exp1 => EK_NAME for the label number of name.
  906.  *
  907.  * SK_HEADER:  Function/module header.
  908.  *    sp->exp1 => EK_VAR pointing to MK_FUNCTION or MK_MODULE.
  909.  *    (This always comes first in a context's statement list.)
  910.  *
  911.  * SK_BODY:  Body of function/module.
  912.  *    sp->stm1 => SK_HEADER that begins the body.
  913.  *    (This exists only during fixblock.)
  914.  *
  915.  */
  916.  
  917. enum stmtkind {
  918.     SK_ASSIGN, SK_RETURN,
  919.     SK_CASE, SK_CASELABEL, SK_IF,
  920.     SK_FOR, SK_REPEAT, SK_WHILE, SK_BREAK, SK_CONTINUE,
  921.     SK_TRY, SK_GOTO, SK_LABEL,
  922.     SK_HEADER, SK_CASECHECK, SK_BODY,
  923.     SK_LAST
  924. } ;
  925.  
  926. #ifdef DEFDUMPS
  927. char *stmtkindnames[(int)SK_LAST] = {
  928.     "SK_ASSIGN", "SK_RETURN",
  929.     "SK_CASE", "SK_CASELABEL", "SK_IF",
  930.     "SK_FOR", "SK_REPEAT", "SK_WHILE", "SK_BREAK", "SK_CONTINUE",
  931.     "SK_TRY", "SK_GOTO", "SK_LABEL",
  932.     "SK_HEADER", "SK_CASECHECK", "SK_BODY"
  933. } ;
  934. #endif /*DEFDUMPS*/
  935.  
  936. typedef struct S_stmt {
  937.     enum stmtkind kind;
  938.     struct S_stmt *next, *stm1, *stm2;
  939.     struct S_expr *exp1, *exp2, *exp3;
  940.     long serial;
  941. } Stmt;
  942.  
  943.  
  944.  
  945. /* Flags for out_declarator(): */
  946.  
  947. #define ODECL_CHARSTAR      0x1
  948. #define ODECL_FREEARRAY     0x2
  949. #define ODECL_FUNCTION      0x4
  950. #define ODECL_HEADER        0x8
  951. #define ODECL_FORWARD       0x10
  952. #define ODECL_DECL        0x20
  953. #define ODECL_NOPRES        0x40
  954.  
  955.  
  956. /* Flags for fixexpr(): */
  957.  
  958. #define ENV_EXPR    0       /* return value needed */
  959. #define ENV_STMT    1       /* return value ignored */
  960. #define ENV_BOOL    2       /* boolean return value needed */
  961.  
  962.  
  963. /* Flags for defmacro(): */
  964. #define MAC_VAR     0       /* VarMacro */
  965. #define MAC_CONST   1       /* ConstMacro */
  966. #define MAC_FIELD   2       /* FieldMacro */
  967. #define MAC_FUNC    3       /* FuncMacro */
  968.  
  969. #define FMACRECname  "<rec>"
  970.  
  971.  
  972. /* Kinds of comment lines: */
  973. #define CMT_SHIFT   24
  974. #define CMT_MASK    ((1L<<CMT_SHIFT)-1)
  975. #define CMT_KMASK   ((1<<(32-CMT_SHIFT))-1)
  976. #define CMT_DONE    0       /* comment that has already been printed */
  977. #define CMT_PRE     1       /* comment line preceding subject */
  978. #define CMT_POST    2       /* comment line following subject */
  979. #define CMT_TRAIL   4       /* comment at end of line of code */
  980. #define CMT_ONBEGIN 6       /* comment on "begin" of procedure */
  981. #define CMT_ONEND   7       /* comment on "end" of procedure */
  982. #define CMT_ONELSE  8       /* comment on "else" keyword */
  983. #define CMT_NOT     256     /* negation of above, for searches */
  984.  
  985. #ifdef define_globals
  986. char *CMT_NAMES[] = { "DONE", "PRE", "POST", "3", "TRAIL", "5",
  987.                       "BEGIN", "END", "ELSE" };
  988. #else
  989. extern char *CMT_NAMES[];
  990. #endif
  991.  
  992. #define getcommentkind(cmt)  (((cmt)->value >> CMT_SHIFT) & CMT_KMASK)
  993.  
  994.  
  995. /* Kinds of operator line-breaking: */
  996. #define BRK_LEFT     0x1
  997. #define BRK_RIGHT    0x2
  998. #define BRK_LPREF    0x4
  999. #define BRK_RPREF    0x8
  1000. #define BRK_ALLNONE  0x10
  1001. #define BRK_HANG     0x20
  1002.  
  1003.  
  1004.  
  1005.  
  1006. /* Translation parameters: */
  1007.  
  1008. #ifdef define_parameters
  1009. # define extern
  1010. #endif /* define_parameters */
  1011.  
  1012. extern enum {
  1013.     UNIX_ANY, UNIX_BSD, UNIX_SYSV
  1014. } which_unix;
  1015.  
  1016. extern enum {
  1017.     LANG_HP, LANG_UCSD, LANG_TURBO, LANG_OREGON, LANG_VAX,
  1018.     LANG_MODULA, LANG_MPW, LANG_BERK
  1019. } which_lang;
  1020.  
  1021. extern short debug, tokentrace, quietmode, cmtdebug, copysource;
  1022. extern int nobanner, showprogress, maxerrors;
  1023. extern short hpux_lang, integer16, doublereals, pascalenumsize;
  1024. extern short needsignedbyte, unsignedchar, importall;
  1025. extern short nestedcomments, pascalsignif, pascalcasesens;
  1026. extern short dollar_idents, ignorenonalpha, modula2;
  1027. extern short ansiC, cplus, signedchars, signedfield, signedshift;
  1028. extern short hassignedchar, voidstar, symcase, ucconsts, csignif;
  1029. extern short copystructs, usevextern, implementationmodules;
  1030. extern short useAnyptrMacros, usePPMacros;
  1031. extern short sprintf_value;
  1032. extern char codefnfmt[40], modulefnfmt[40], logfnfmt[40];
  1033. extern char headerfnfmt[40], headerfnfmt2[40], includefnfmt[40];
  1034. extern char selfincludefmt[40];
  1035. extern char constformat[40], moduleformat[40], functionformat[40];
  1036. extern char varformat[40], fieldformat[40], typeformat[40];
  1037. extern char enumformat[40], symbolformat[40];
  1038. extern char p2c_h_name[40], exportsymbol[40], export_symbol[40];
  1039. extern char externalias[40];
  1040. extern char memcpyname[40], sprintfname[40];
  1041. extern char roundname[40], divname[40], modname[40], remname[40];
  1042. extern char strposname[40], strcicmpname[40];
  1043. extern char strsubname[40], strdeletename[40], strinsertname[40];
  1044. extern char strmovename[40], strpadname[40];
  1045. extern char strltrimname[40], strrtrimname[40], strrptname[40];
  1046. extern char absname[40], oddname[40], evenname[40], swapname[40];
  1047. extern char mallocname[40], freename[40], freervaluename[40];
  1048. extern char randrealname[40], randintname[40], randomizename[40];
  1049. extern char skipspacename[40], readlnname[40], freopenname[40];
  1050. extern char eofname[40], eolnname[40], fileposname[40], maxposname[40];
  1051. extern char setunionname[40], setintname[40], setdiffname[40];
  1052. extern char setinname[40], setaddname[40], setaddrangename[40];
  1053. extern char setremname[40];
  1054. extern char setequalname[40], subsetname[40], setxorname[40];
  1055. extern char setcopyname[40], setexpandname[40], setpackname[40];
  1056. extern char getbitsname[40], clrbitsname[40], putbitsname[40];
  1057. extern char declbufname[40], declbufncname[40];
  1058. extern char resetbufname[40], setupbufname[40];
  1059. extern char getfbufname[40], chargetfbufname[40], arraygetfbufname[40];
  1060. extern char putfbufname[40], charputfbufname[40], arrayputfbufname[40];
  1061. extern char getname[40], chargetname[40], arraygetname[40];
  1062. extern char putname[40], charputname[40], arrayputname[40];
  1063. extern char eofbufname[40], fileposbufname[40];
  1064. extern char storebitsname[40], signextname[40];
  1065. extern char filenotfoundname[40], filenotopenname[40];
  1066. extern char filewriteerrorname[40], badinputformatname[40], endoffilename[40];
  1067. extern short strcpyleft;
  1068. extern char language[40], target[40];
  1069. extern int sizeof_char, sizeof_short, sizeof_integer, sizeof_pointer, 
  1070.            sizeof_double, sizeof_float, sizeof_enum, sizeof_int, sizeof_long;
  1071. extern short size_t_long;
  1072. extern int setbits, defaultsetsize, seek_base, integerwidth, realwidth;
  1073. extern short quoteincludes, expandincludes, collectnest;
  1074. extern int phystabsize, intabsize, linewidth, maxlinewidth;
  1075. extern int majorspace, minorspace, functionspace, minfuncspace;
  1076. extern int casespacing, caselimit;
  1077. extern int returnlimit, breaklimit, continuelimit;
  1078. extern short nullstmtline, shortcircuit, shortopt, usecommas, elseif;
  1079. extern short usereturns, usebreaks, infloopstyle, reusefieldnames;
  1080. extern short bracesalways, braceline, bracecombine, braceelse, braceelseline;
  1081. extern short newlinefunctions;
  1082. extern short eatcomments, spitcomments, spitorphancomments;
  1083. extern short commentafter, blankafter;
  1084. extern int tabsize, blockindent, bodyindent, argindent;
  1085. extern int switchindent, caseindent, labelindent;
  1086. extern int openbraceindent, closebraceindent;
  1087. extern int funcopenindent, funccloseindent;
  1088. extern int structindent, structinitindent, extrainitindent;
  1089. extern int constindent, commentindent, bracecommentindent, commentoverindent;
  1090. extern int declcommentindent;
  1091. extern int minspacing, minspacingthresh;
  1092. extern int extraindent, bumpindent;
  1093. extern double overwidepenalty, overwideextrapenalty;
  1094. extern double commabreakpenalty, commabreakextrapenalty;
  1095. extern double assignbreakpenalty, assignbreakextrapenalty;
  1096. extern double specialargbreakpenalty;
  1097. extern double opbreakpenalty, opbreakextrapenalty, exhyphenpenalty;
  1098. extern double logbreakpenalty, logbreakextrapenalty;
  1099. extern double relbreakpenalty, relbreakextrapenalty;
  1100. extern double morebreakpenalty, morebreakextrapenalty;
  1101. extern double parenbreakpenalty, parenbreakextrapenalty;
  1102. extern double qmarkbreakpenalty, qmarkbreakextrapenalty;
  1103. extern double wrongsidepenalty, earlybreakpenalty, extraindentpenalty;
  1104. extern double bumpindentpenalty, nobumpindentpenalty;
  1105. extern double indentamountpenalty, sameindentpenalty;
  1106. extern double showbadlimit;
  1107. extern long maxalts;
  1108. extern short breakbeforearith, breakbeforerel, breakbeforelog;
  1109. extern short breakbeforedot, breakbeforeassign;
  1110. extern short for_allornone;
  1111. extern short extraparens, breakparens, returnparens;
  1112. extern short variablearrays, initpacstrings, stararrays;
  1113. extern short spaceexprs, spacefuncs, spacecommas, implicitzero, starindex;
  1114. extern int casetabs;
  1115. extern short starfunctions, mixfields, alloczeronil, postincrement;
  1116. extern short mixvars, mixtypes, mixinits, nullcharconst, castnull, addindex;
  1117. extern short highcharints, highcharbits, hasstaticlinks;
  1118. extern short mainlocals, storefilenames, addrstdfiles, readwriteopen;
  1119. extern short charfiletext, messagestderr, literalfilesflag, structfilesflag;
  1120. extern short printfonly, mixwritelns, usegets, newlinespace, binarymode;
  1121. extern char openmode[40], filenamefilter[40];
  1122. extern short atan2flag, div_po2, mod_po2, assumebits, assumesigns;
  1123. extern short fullstrwrite, fullstrread, whilefgets, buildreads, buildwrites;
  1124. extern short foldconsts, foldstrconsts, charconsts, useconsts, useundef;
  1125. extern short elimdeadcode, offsetforloops, forevalorder;
  1126. extern short smallsetconst, bigsetconst, lelerange, unsignedtrick;
  1127. extern short useisalpha, useisspace, usestrncmp;
  1128. extern short casecheck, arraycheck, rangecheck, nilcheck, malloccheck;
  1129. extern short checkfileopen, checkfileisopen, checkfilewrite;
  1130. extern short checkreadformat, checkfileeof, checkstdineof, checkfileseek;
  1131. extern short squeezesubr, useenum, enumbyte, packing, packsigned, keepnulls;
  1132. extern short compenums, formatstrings, alwayscopyvalues;
  1133. extern short use_static, var_static, void_args, prototypes, fullprototyping;
  1134. extern short procptrprototypes, promote_enums;
  1135. extern short preservetypes, preservepointers, preservestrings;
  1136. extern short castargs, castlongargs, promoteargs, fixpromotedargs;
  1137. extern short varstrings, varfiles, copystructfuncs;
  1138. extern long skipindices;
  1139. extern short stringleaders;
  1140. extern int stringceiling, stringdefault, stringtrunclimit, longstringsize;
  1141. extern short warnnames, warnmacros;
  1142. extern Strlist *importfrom, *importdirs, *includedirs, *includefrom;
  1143. extern Strlist *librfiles, *bufferedfiles, *unbufferedfiles;
  1144. extern Strlist *externwords, *cexternwords;
  1145. extern Strlist *varmacros, *constmacros, *fieldmacros;
  1146. extern Strlist *funcmacros, *funcmacroargs, *nameoflist;
  1147. extern Strlist *specialmallocs, *specialfrees, *specialsizeofs;
  1148. extern Strlist *initialcalls, *eatnotes, *literalfiles, *structfiles;
  1149.  
  1150. extern char fixedcomment[40], permanentcomment[40], interfacecomment[40];
  1151. extern char embedcomment[40],  skipcomment[40], noskipcomment[40];
  1152. extern char signedcomment[40], unsignedcomment[40];
  1153.  
  1154. extern char name_RETV[40], name_STRMAX[40], name_LINK[40];
  1155. extern char name_COPYPAR[40], name_TEMP[40], name_DUMMY[40];
  1156. extern char name_LOC[40], name_VARS[40], name_STRUCT[40];
  1157. extern char name_FAKESTRUCT[40], name_AHIGH[40], name_ALOW[40];
  1158. extern char name_UNION[40], name_VARIANT[40], name_LABEL[40], name_LABVAR[40];
  1159. extern char name_WITH[40], name_FOR[40], name_ENUM[40];
  1160. extern char name_PTR[40], name_STRING[40], name_SET[40];
  1161. extern char name_PROCEDURE[40], name_MAIN[40], name_UNITINIT[40];
  1162. extern char name_HSYMBOL[40], name_GSYMBOL[40];
  1163. extern char name_SETBITS[40], name_UCHAR[40], name_SCHAR[40];
  1164. extern char name_BOOLEAN[40], name_TRUE[40], name_FALSE[40], name_NULL[40];
  1165. extern char name_ESCAPECODE[40], name_IORESULT[40];
  1166. extern char name_ARGC[40], name_ARGV[40];
  1167. extern char name_ESCAPE[40], name_ESCIO[40], name_CHKIO[40], name_SETIO[40];
  1168. extern char name_OUTMEM[40], name_CASECHECK[40], name_NILCHECK[40];
  1169. extern char name_FNSIZE[40], name_FNVAR[40];
  1170. extern char alternatename1[40], alternatename2[40], alternatename[40];
  1171.  
  1172.  
  1173. #ifndef define_parameters
  1174. extern
  1175. #endif
  1176. struct rcstruct {
  1177.     char kind;
  1178.     char chgmode;
  1179.     char *name;
  1180.     anyptr ptr;
  1181.     long def;
  1182. } rctable[]
  1183. #ifdef define_parameters
  1184.    = {
  1185.     'S', 'R', "DEBUG",           (anyptr) &debug,             0,
  1186.     'I', 'R', "SHOWPROGRESS",    (anyptr) &showprogress,      0,
  1187.     'S', 'V', "TOKENTRACE",      (anyptr) &tokentrace,        0,
  1188.     'S', 'V', "QUIET",           (anyptr) &quietmode,         0,
  1189.     'S', 'V', "COPYSOURCE",      (anyptr) ©source,        0,
  1190.     'I', 'R', "MAXERRORS",     (anyptr) &maxerrors,          0,
  1191.     'X', ' ', "INCLUDE",         (anyptr) NULL,               2,
  1192.  
  1193. /* INPUT LANGUAGE */
  1194.     'U', 'T', "LANGUAGE",        (anyptr)  language,         40,
  1195.     'S', 'V', "MODULA2",         (anyptr) &modula2,          -1,
  1196.     'S', 'T', "INTEGER16",       (anyptr) &integer16,        -1,
  1197.     'S', 'T', "DOUBLEREALS",     (anyptr) &doublereals,      -1,
  1198.     'S', 'V', "UNSIGNEDCHAR",    (anyptr) &unsignedchar,     -1,
  1199.     'S', 'V', "NEEDSIGNEDBYTE",  (anyptr) &needsignedbyte,    0,
  1200.     'S', 'V', "PASCALENUMSIZE",  (anyptr) &pascalenumsize,   -1,
  1201.     'S', 'V', "NESTEDCOMMENTS",  (anyptr) &nestedcomments,   -1,
  1202.     'S', 'V', "IMPORTALL",       (anyptr) &importall,        -1,
  1203.     'S', 'V', "IMPLMODULES",     (anyptr) &implementationmodules, -1,
  1204.     'A', 'V', "EXTERNWORDS",     (anyptr) &externwords,          0,
  1205.     'A', 'V', "CEXTERNWORDS",     (anyptr) &cexternwords,      0,
  1206.     'S', 'V', "PASCALSIGNIF",    (anyptr) &pascalsignif,     -1,
  1207.     'S', 'V', "PASCALCASESENS",  (anyptr) &pascalcasesens,   -1,
  1208.     'S', 'V', "DOLLARIDENTS",    (anyptr) &dollar_idents,    -1,
  1209.     'S', 'V', "IGNORENONALPHA",  (anyptr) &ignorenonalpha,   -1,
  1210.     'I', 'V', "SEEKBASE",        (anyptr) &seek_base,        -1,
  1211.     'I', 'R', "INPUTTABSIZE",    (anyptr) &intabsize,         8,
  1212.  
  1213. /* TARGET LANGUAGE */
  1214.     'S', 'T', "ANSIC",           (anyptr) &ansiC,            -1,
  1215.     'S', 'T', "C++",             (anyptr) &cplus,            -1,
  1216.     'S', 'T', "VOID*",           (anyptr) &voidstar,         -1,
  1217.     'S', 'T', "HASSIGNEDCHAR",   (anyptr) &hassignedchar,    -1,
  1218.     'S', 'V', "CASTNULL",        (anyptr) &castnull,         -1,
  1219.     'S', 'V', "COPYSTRUCTS",     (anyptr) ©structs,      -1,
  1220.     'S', 'V', "VARIABLEARRAYS",  (anyptr) &variablearrays,   -1,
  1221.     'S', 'V', "INITPACSTRINGS",  (anyptr) &initpacstrings,   -1,
  1222.     'S', 'V', "REUSEFIELDNAMES", (anyptr) &reusefieldnames,   1,
  1223.     'S', 'V', "USEVEXTERN",      (anyptr) &usevextern,        1,
  1224.     'S', 'V', "CSIGNIF",         (anyptr) &csignif,          -1,
  1225.     'S', 'V', "USEANYPTRMACROS", (anyptr) &useAnyptrMacros,  -1,
  1226.     'S', 'V', "USEPPMACROS",     (anyptr) &usePPMacros,      -1,
  1227.  
  1228. /* TARGET MACHINE */
  1229.     'U', 'T', "TARGET",          (anyptr)  target,           40,
  1230.     'S', 'T', "SIGNEDCHAR",      (anyptr) &signedchars,      -1,
  1231.     'S', 'T', "SIGNEDFIELD",     (anyptr) &signedfield,      -1,
  1232.     'S', 'T', "SIGNEDSHIFT",     (anyptr) &signedshift,      -1,
  1233.     'I', 'T', "CHARSIZE",        (anyptr) &sizeof_char,       0,
  1234.     'I', 'T', "SHORTSIZE",       (anyptr) &sizeof_short,      0,
  1235.     'I', 'T', "INTSIZE",         (anyptr) &sizeof_int,        0,
  1236.     'I', 'T', "LONGSIZE",        (anyptr) &sizeof_long,       0,
  1237.     'I', 'T', "PTRSIZE",         (anyptr) &sizeof_pointer,    0,
  1238.     'I', 'T', "DOUBLESIZE",      (anyptr) &sizeof_double,     0,
  1239.     'I', 'T', "FLOATSIZE",       (anyptr) &sizeof_float,      0,
  1240.     'I', 'T', "ENUMSIZE",        (anyptr) &sizeof_enum,       0,
  1241.     'S', 'T', "SIZE_T_LONG",     (anyptr) &size_t_long,      -1,
  1242.  
  1243. /* BRACES */
  1244.     'S', 'V', "NULLSTMTLINE",    (anyptr) &nullstmtline,      0,
  1245.     'S', 'V', "BRACESALWAYS",    (anyptr) &bracesalways,     -1,
  1246.     'S', 'V', "BRACELINE",       (anyptr) &braceline,        -1,
  1247.     'S', 'V', "BRACECOMBINE",    (anyptr) &bracecombine,      0,
  1248.     'S', 'V', "BRACEELSE",       (anyptr) &braceelse,         0,
  1249.     'S', 'V', "BRACEELSELINE",   (anyptr) &braceelseline,     0,
  1250.     'S', 'V', "ELSEIF",          (anyptr) &elseif,           -1,
  1251.     'S', 'V', "NEWLINEFUNCS",    (anyptr) &newlinefunctions,  0,
  1252.  
  1253. /* INDENTATION */
  1254.     'I', 'R', "PHYSTABSIZE",     (anyptr) &phystabsize,       8,
  1255.     'D', 'R', "INDENT",          (anyptr) &tabsize,           2,
  1256.     'D', 'R', "BLOCKINDENT",     (anyptr) &blockindent,       0,
  1257.     'D', 'R', "BODYINDENT",      (anyptr) &bodyindent,        0,
  1258.     'D', 'R', "FUNCARGINDENT",   (anyptr) &argindent,      1000,
  1259.     'D', 'R', "OPENBRACEINDENT", (anyptr) &openbraceindent,   0,
  1260.     'D', 'R', "CLOSEBRACEINDENT",(anyptr) &closebraceindent,  0,
  1261.     'D', 'R', "FUNCOPENINDENT",  (anyptr) &funcopenindent,    0,
  1262.     'D', 'R', "FUNCCLOSEINDENT", (anyptr) &funccloseindent,   0,
  1263.     'D', 'R', "SWITCHINDENT",    (anyptr) &switchindent,      0,
  1264.     'D', 'R', "CASEINDENT",      (anyptr) &caseindent,       -2,
  1265.     'D', 'R', "LABELINDENT",     (anyptr) &labelindent,    1000,
  1266.     'D', 'R', "STRUCTINDENT",    (anyptr) &structindent,      0,
  1267.     'D', 'R', "STRUCTINITINDENT",(anyptr) &structinitindent,  0,
  1268.     'D', 'R', "EXTRAINITINDENT", (anyptr) &extrainitindent,   2,
  1269.     'I', 'R', "EXTRAINDENT",     (anyptr) &extraindent,       2,
  1270.     'I', 'R', "BUMPINDENT",      (anyptr) &bumpindent,        1,
  1271.     'D', 'R', "CONSTINDENT",     (anyptr) &constindent,    1024,
  1272.     'D', 'R', "COMMENTINDENT",   (anyptr) &commentindent,     3,
  1273.     'D', 'R', "BRACECOMMENTINDENT",(anyptr)&bracecommentindent, 2,
  1274.     'D', 'R', "DECLCOMMENTINDENT",(anyptr)&declcommentindent, -999,
  1275.     'D', 'R', "COMMENTOVERINDENT",(anyptr)&commentoverindent, 4,  /*1000*/
  1276.     'I', 'R', "MINSPACING",      (anyptr) &minspacing,        2,
  1277.     'I', 'R', "MINSPACINGTHRESH",(anyptr) &minspacingthresh, -1,
  1278.  
  1279. /* LINE BREAKING */
  1280.     'I', 'R', "LINEWIDTH",       (anyptr) &linewidth,        78,
  1281.     'I', 'R', "MAXLINEWIDTH",    (anyptr) &maxlinewidth,     90,
  1282.     'R', 'V', "OVERWIDEPENALTY",       (anyptr) &overwidepenalty,         2500,
  1283.     'R', 'V', "OVERWIDEEXTRAPENALTY",  (anyptr) &overwideextrapenalty,     100,
  1284.     'R', 'V', "COMMABREAKPENALTY",     (anyptr) &commabreakpenalty,       1000,
  1285.     'R', 'V', "COMMABREAKEXTRAPENALTY",(anyptr) &commabreakextrapenalty,   500,
  1286.     'R', 'V', "ASSIGNBREAKPENALTY",    (anyptr) &assignbreakpenalty,      5000,
  1287.     'R', 'V', "ASSIGNBREAKEXTRAPENALTY",(anyptr)&assignbreakextrapenalty, 3000,
  1288.     'R', 'V', "SPECIALARGBREAKPENALTY",(anyptr) &specialargbreakpenalty,   500,
  1289.     'R', 'V', "OPBREAKPENALTY",        (anyptr) &opbreakpenalty,          2500,
  1290.     'R', 'V', "OPBREAKEXTRAPENALTY",   (anyptr) &opbreakextrapenalty,     2000,
  1291.     'R', 'V', "LOGBREAKPENALTY",       (anyptr) &logbreakpenalty,          500,
  1292.     'R', 'V', "LOGBREAKEXTRAPENALTY",  (anyptr) &logbreakextrapenalty,     100,
  1293.     'R', 'V', "RELBREAKPENALTY",       (anyptr) &relbreakpenalty,         2000,
  1294.     'R', 'V', "RELBREAKEXTRAPENALTY",  (anyptr) &relbreakextrapenalty,    1000,
  1295.     'R', 'V', "EXHYPHENPENALTY",       (anyptr) &exhyphenpenalty,         1000,
  1296.     'R', 'V', "MOREBREAKPENALTY",      (anyptr) &morebreakpenalty,        -500,
  1297.     'R', 'V', "MOREBREAKEXTRAPENALTY", (anyptr) &morebreakextrapenalty,   -300,
  1298.     'R', 'V', "QMARKBREAKPENALTY",     (anyptr) &qmarkbreakpenalty,       5000,
  1299.     'R', 'V', "QMARKBREAKEXTRAPENALTY",(anyptr) &qmarkbreakextrapenalty,  3000,
  1300.     'R', 'V', "PARENBREAKPENALTY",     (anyptr) &parenbreakpenalty,       2500,
  1301.     'R', 'V', "PARENBREAKEXTRAPENALTY",(anyptr) &parenbreakextrapenalty,  1000,
  1302.     'R', 'V', "WRONGSIDEPENALTY",      (anyptr) &wrongsidepenalty,        1000,
  1303.     'R', 'V', "EARLYBREAKPENALTY",     (anyptr) &earlybreakpenalty,        100,
  1304.     'R', 'V', "EXTRAINDENTPENALTY",    (anyptr) &extraindentpenalty,      3000,
  1305.     'R', 'V', "BUMPINDENTPENALTY",     (anyptr) &bumpindentpenalty,       1000,
  1306.     'R', 'V', "NOBUMPINDENTPENALTY",   (anyptr) &nobumpindentpenalty,     2500,
  1307.     'R', 'V', "INDENTAMOUNTPENALTY",   (anyptr) &indentamountpenalty,       50,
  1308.     'R', 'V', "SAMEINDENTPENALTY",     (anyptr) &sameindentpenalty,        500,
  1309.     'R', 'V', "SHOWBADLIMIT",          (anyptr) &showbadlimit,            -120,
  1310.     'L', 'R', "MAXLINEBREAKTRIES", (anyptr) &maxalts,      5000,
  1311.     'G', 'V', "ALLORNONEBREAK",  (anyptr)  NULL,             FALLBREAK,
  1312.     'G', 'V', "ONESPECIALARG",   (anyptr)  NULL,             FSPCARG1,
  1313.     'G', 'V', "TWOSPECIALARGS",  (anyptr)  NULL,             FSPCARG2,
  1314.     'G', 'V', "THREESPECIALARGS",(anyptr)  NULL,             FSPCARG3,
  1315.     'B', 'V', "BREAKARITH",      (anyptr) &breakbeforearith,  BRK_RIGHT,
  1316.     'B', 'V', "BREAKREL",        (anyptr) &breakbeforerel,    BRK_RIGHT,
  1317.     'B', 'V', "BREAKLOG",        (anyptr) &breakbeforelog,    BRK_RIGHT,
  1318.     'B', 'V', "BREAKDOT",        (anyptr) &breakbeforedot,    BRK_RIGHT,
  1319.     'B', 'V', "BREAKASSIGN",     (anyptr) &breakbeforeassign, BRK_RIGHT,
  1320.     'S', 'V', "FOR_ALLORNONE",   (anyptr) &for_allornone,     1,
  1321.  
  1322. /* COMMENTS AND BLANK LINES */
  1323.     'S', 'V', "NOBANNER",        (anyptr) &nobanner,          0,
  1324.     'S', 'V', "EATCOMMENTS",     (anyptr) &eatcomments,       0,
  1325.     'S', 'V', "SPITCOMMENTS",    (anyptr) &spitcomments,      0,
  1326.     'S', 'V', "SPITORPHANCOMMENTS",(anyptr)&spitorphancomments, 0,
  1327.     'S', 'V', "COMMENTAFTER",    (anyptr) &commentafter,     -1,
  1328.     'S', 'V', "BLANKAFTER",      (anyptr) &blankafter,        1,
  1329.     'A', 'V', "EATNOTES",        (anyptr) &eatnotes,          0,
  1330.  
  1331. /* SPECIAL COMMENTS */
  1332.     'C', 'V', "FIXEDCOMMENT",    (anyptr)  fixedcomment,     40,
  1333.     'C', 'V', "PERMANENTCOMMENT",(anyptr)  permanentcomment, 40,
  1334.     'C', 'V', "INTERFACECOMMENT",(anyptr)  interfacecomment, 40,
  1335.     'C', 'V', "EMBEDCOMMENT",    (anyptr)  embedcomment,     40,
  1336.     'C', 'V', "SKIPCOMMENT",     (anyptr)  skipcomment,      40,
  1337.     'C', 'V', "NOSKIPCOMMENT",   (anyptr)  noskipcomment,    40,
  1338.     'C', 'V', "SIGNEDCOMMENT",   (anyptr)  signedcomment,    40,
  1339.     'C', 'V', "UNSIGNEDCOMMENT", (anyptr)  unsignedcomment,  40,
  1340.  
  1341. /* STYLISTIC OPTIONS */
  1342.     'I', 'V', "MAJORSPACING",    (anyptr) &majorspace,        2,
  1343.     'I', 'V', "MINORSPACING",    (anyptr) &minorspace,        1,
  1344.     'I', 'V', "FUNCSPACING",     (anyptr) &functionspace,     2,
  1345.     'I', 'V', "MINFUNCSPACING",  (anyptr) &minfuncspace,      1,
  1346.     'S', 'V', "EXTRAPARENS",     (anyptr) &extraparens,      -1,
  1347.     'S', 'V', "BREAKADDPARENS",  (anyptr) &breakparens,      -1,
  1348.     'S', 'V', "RETURNPARENS",    (anyptr) &returnparens,     -1,
  1349.     'S', 'V', "SPACEEXPRS",      (anyptr) &spaceexprs,       -1,
  1350.     'S', 'V', "SPACEFUNCS",     (anyptr) &spacefuncs,          0,
  1351.     'S', 'V', "SPACECOMMAS",     (anyptr) &spacecommas,          1,
  1352.     'S', 'V', "IMPLICITZERO",    (anyptr) &implicitzero,     -1,
  1353.     'S', 'V', "STARINDEX",       (anyptr) &starindex,        -1,
  1354.     'S', 'V', "ADDINDEX",        (anyptr) &addindex,         -1,
  1355.     'S', 'V', "STARARRAYS",      (anyptr) &stararrays,        1,
  1356.     'S', 'V', "STARFUNCTIONS",   (anyptr) &starfunctions,    -1,
  1357.     'S', 'V', "POSTINCREMENT",   (anyptr) &postincrement,     1,
  1358.     'S', 'V', "MIXVARS",         (anyptr) &mixvars,          -1,
  1359.     'S', 'V', "MIXTYPES",        (anyptr) &mixtypes,         -1,
  1360.     'S', 'V', "MIXFIELDS",       (anyptr) &mixfields,        -1,
  1361.     'S', 'V', "MIXINITS",        (anyptr) &mixinits,         -1,
  1362.     'S', 'V', "MAINLOCALS",      (anyptr) &mainlocals,        1,
  1363.     'S', 'V', "NULLCHAR",        (anyptr) &nullcharconst,     1,
  1364.     'S', 'V', "HIGHCHARINT",     (anyptr) &highcharints,      1,
  1365.     'I', 'V', "CASESPACING",     (anyptr) &casespacing,       1,
  1366.     'D', 'V', "CASETABS",        (anyptr) &casetabs,       1000,
  1367.     'I', 'V', "CASELIMIT",       (anyptr) &caselimit,         9,
  1368.     'S', 'V', "USECOMMAS",       (anyptr) &usecommas,        -1,
  1369.     'S', 'V', "USERETURNS",      (anyptr) &usereturns,        1,
  1370.     'I', 'V', "RETURNLIMIT",     (anyptr) &returnlimit,       3,
  1371.     'S', 'V', "USEBREAKS",       (anyptr) &usebreaks,         1,
  1372.     'I', 'V', "BREAKLIMIT",      (anyptr) &breaklimit,        2,
  1373.     'I', 'V', "CONTINUELIMIT",   (anyptr) &continuelimit,     5,
  1374.     'S', 'V', "INFLOOPSTYLE",    (anyptr) &infloopstyle,      0,
  1375.  
  1376. /* NAMING CONVENTIONS */
  1377.     'C', 'V', "CODEFILENAME",    (anyptr)  codefnfmt,        40,
  1378.     'C', 'V', "MODULEFILENAME",  (anyptr)  modulefnfmt,      40,
  1379.     'C', 'V', "HEADERFILENAME",  (anyptr)  headerfnfmt,      40,
  1380.     'C', 'V', "HEADERFILENAME2", (anyptr)  headerfnfmt2,     40,
  1381.     'C', 'V', "SELFINCLUDENAME", (anyptr)  selfincludefmt,   40,
  1382.     'C', 'V', "LOGFILENAME",     (anyptr)  logfnfmt,         40,
  1383.     'C', 'V', "INCLUDEFILENAME", (anyptr)  includefnfmt,     40,
  1384.     'S', 'V', "SYMCASE",         (anyptr) &symcase,          -1,
  1385.     'C', 'V', "SYMBOLFORMAT",    (anyptr)  symbolformat,     40,
  1386.     'C', 'V', "CONSTFORMAT",     (anyptr)  constformat,      40,
  1387.     'C', 'V', "MODULEFORMAT",    (anyptr)  moduleformat,     40,
  1388.     'C', 'V', "FUNCTIONFORMAT",  (anyptr)  functionformat,   40,
  1389.     'C', 'V', "VARFORMAT",       (anyptr)  varformat,        40,
  1390.     'C', 'V', "FIELDFORMAT",     (anyptr)  fieldformat,      40,
  1391.     'C', 'V', "TYPEFORMAT",      (anyptr)  typeformat,       40,
  1392.     'C', 'V', "ENUMFORMAT",      (anyptr)  enumformat,       40,
  1393.     'C', 'V', "RETURNVALUENAME", (anyptr)  name_RETV,        40,
  1394.     'C', 'V', "UNITINITNAME",    (anyptr)  name_UNITINIT,    40,
  1395.     'C', 'V', "HSYMBOLNAME",     (anyptr)  name_HSYMBOL,     40,
  1396.     'C', 'V', "GSYMBOLNAME",     (anyptr)  name_GSYMBOL,     40,
  1397.     'C', 'V', "STRINGMAXNAME",   (anyptr)  name_STRMAX,      40,
  1398.     'C', 'V', "ARRAYMINNAME",    (anyptr)  name_ALOW,        40,
  1399.     'C', 'V', "ARRAYMAXNAME",    (anyptr)  name_AHIGH,       40,
  1400.     'C', 'V', "COPYPARNAME",     (anyptr)  name_COPYPAR,     40,
  1401.     'C', 'V', "STATICLINKNAME",  (anyptr)  name_LINK,        40,
  1402.     'C', 'V', "LOCALVARSSTRUCT", (anyptr)  name_LOC,         40,
  1403.     'C', 'V', "LOCALVARSNAME",   (anyptr)  name_VARS,        40,
  1404.     'C', 'V', "FWDSTRUCTNAME",   (anyptr)  name_STRUCT,      40,
  1405.     'C', 'V', "ENUMLISTNAME",    (anyptr)  name_ENUM,        40,
  1406.     'C', 'V', "UNIONNAME",       (anyptr)  name_UNION,       40,
  1407.     'C', 'V', "UNIONPARTNAME",   (anyptr)  name_VARIANT,     40,
  1408.     'C', 'V', "FAKESTRUCTNAME",  (anyptr)  name_FAKESTRUCT,  40,
  1409.     'C', 'V', "LABELNAME",       (anyptr)  name_LABEL,       40,
  1410.     'C', 'V', "LABELVARNAME",    (anyptr)  name_LABVAR,      40,
  1411.     'C', 'V', "TEMPNAME",        (anyptr)  name_TEMP,        40,
  1412.     'C', 'V', "DUMMYNAME",       (anyptr)  name_DUMMY,       40,
  1413.     'C', 'V', "FORNAME",         (anyptr)  name_FOR,         40,
  1414.     'C', 'V', "WITHNAME",        (anyptr)  name_WITH,        40,
  1415.     'C', 'V', "PTRNAME",         (anyptr)  name_PTR,         40,
  1416.     'C', 'V', "STRINGNAME",      (anyptr)  name_STRING,      40,
  1417.     'C', 'V', "SETNAME",         (anyptr)  name_SET,         40,
  1418.     'C', 'V', "FNVARNAME",       (anyptr)  name_FNVAR,       40,
  1419.     'C', 'V', "FNSIZENAME",      (anyptr)  name_FNSIZE,      40,
  1420.     'C', 'V', "ALTERNATENAME1",  (anyptr)  alternatename1,   40,
  1421.     'C', 'V', "ALTERNATENAME2",  (anyptr)  alternatename2,   40,
  1422.     'C', 'V', "ALTERNATENAME",   (anyptr)  alternatename,    40,
  1423.     'C', 'V', "EXPORTSYMBOL",    (anyptr)  exportsymbol,     40,
  1424.     'C', 'V', "EXPORT_SYMBOL",   (anyptr)  export_symbol,    40,
  1425.     'C', 'V', "ALIAS",           (anyptr)  externalias,      40,
  1426.     'X', 'V', "SYNONYM",         (anyptr)  NULL,              3,
  1427.     'X', 'V', "NAMEOF",          (anyptr) &nameoflist,        1,
  1428.     'G', 'V', "AVOIDNAME",       (anyptr)  NULL,             AVOIDNAME,
  1429.     'G', 'V', "AVOIDGLOBALNAME", (anyptr)  NULL,             AVOIDGLOB,
  1430.     'G', 'V', "WARNNAME",        (anyptr)  NULL,             WARNNAME,
  1431.     'G', 'V', "NOSIDEEFFECTS",   (anyptr)  NULL,             NOSIDEEFF,
  1432.     'G', 'V', "STRUCTFUNCTION",  (anyptr)  NULL,             STRUCTF,
  1433.     'G', 'V', "STRLAPFUNCTION",  (anyptr)  NULL,             STRLAPF,
  1434.     'F', 'V', "LEAVEALONE",      (anyptr)  NULL,             LEAVEALONE,
  1435.     'G', 'V', "DETERMINISTIC",   (anyptr)  NULL,             DETERMF,
  1436.     'G', 'V', "NEEDSTATIC",      (anyptr)  NULL,             NEEDSTATIC,
  1437.     'S', 'V', "WARNNAMES",       (anyptr) &warnnames,         0,
  1438.     'M', 'V', "VARMACRO",        (anyptr)  NULL,             MAC_VAR,
  1439.     'M', 'V', "CONSTMACRO",      (anyptr)  NULL,             MAC_CONST,
  1440.     'M', 'V', "FIELDMACRO",      (anyptr)  NULL,             MAC_FIELD,
  1441.     'M', 'V', "FUNCMACRO",       (anyptr)  NULL,             MAC_FUNC,
  1442.     'S', 'V', "WARNMACROS",      (anyptr) &warnmacros,        0,
  1443.  
  1444. /* CODING OPTIONS */
  1445.     'A', 'V', "INITIALCALLS",    (anyptr) &initialcalls,      0,
  1446.     'S', 'V', "EXPANDINCLUDES",  (anyptr) &expandincludes,   -1,
  1447.     'S', 'V', "COLLECTNEST",     (anyptr) &collectnest,       1,
  1448.     'S', 'V', "SHORTCIRCUIT",    (anyptr) &shortcircuit,     -1,
  1449.     'S', 'V', "SHORTOPT",        (anyptr) &shortopt,          1,
  1450.     'S', 'V', "ELIMDEADCODE",    (anyptr) &elimdeadcode,      1,
  1451.     'S', 'V', "FOLDCONSTANTS",   (anyptr) &foldconsts,       -1,
  1452.     'S', 'V', "FOLDSTRCONSTANTS",(anyptr) &foldstrconsts,    -1,
  1453.     'S', 'V', "CHARCONSTS",     (anyptr) &charconsts,        1,
  1454.     'S', 'V', "USECONSTS",       (anyptr) &useconsts,        -1,
  1455.     'S', 'V', "USEUNDEF",        (anyptr) &useundef,          1,
  1456.     'L', 'V', "SKIPINDICES",     (anyptr) &skipindices,       0,
  1457.     'S', 'V', "OFFSETFORLOOPS",  (anyptr) &offsetforloops,    1,
  1458.     'S', 'V', "FOREVALORDER",    (anyptr) &forevalorder,      0,
  1459.     'S', 'V', "STRINGLEADERS",   (anyptr) &stringleaders,     2,
  1460.     'S', 'V', "STOREFILENAMES",  (anyptr) &storefilenames,   -1,
  1461.     'S', 'V', "CHARFILETEXT",    (anyptr) &charfiletext,     -1,
  1462.     'S', 'V', "SQUEEZESUBR",     (anyptr) &squeezesubr,       1,
  1463.     'S', 'T', "USEENUM",         (anyptr) &useenum,          -1,
  1464.     'S', 'V', "SQUEEZEENUM",     (anyptr) &enumbyte,         -1,
  1465.     'S', 'V', "COMPENUMS",       (anyptr) &compenums,        -1,
  1466.     'S', 'V', "PRESERVETYPES",   (anyptr) &preservetypes,     1,
  1467.     'S', 'V', "PRESERVEPOINTERS",(anyptr) &preservepointers,  0,
  1468.     'S', 'V', "PRESERVESTRINGS", (anyptr) &preservestrings,  -1,
  1469.     'S', 'V', "PACKING",         (anyptr) &packing,           1,
  1470.     'S', 'V', "PACKSIGNED",      (anyptr) &packsigned,        1,
  1471.     'I', 'V', "STRINGCEILING",   (anyptr) &stringceiling,   255,
  1472.     'I', 'V', "STRINGDEFAULT",   (anyptr) &stringdefault,   255,
  1473.     'I', 'V', "STRINGTRUNCLIMIT",(anyptr) &stringtrunclimit, -1,
  1474.     'I', 'V', "LONGSTRINGSIZE",  (anyptr) &longstringsize,   -1,
  1475.     'S', 'V', "KEEPNULLS",       (anyptr) &keepnulls,         0,
  1476.     'S', 'V', "HIGHCHARBITS",    (anyptr) &highcharbits,     -1,
  1477.     'S', 'V', "ALWAYSCOPYVALUES",(anyptr) &alwayscopyvalues,  0,
  1478.     'S', 'V', "STATICFUNCTIONS", (anyptr) &use_static,        1,
  1479.     'S', 'V', "STATICVARIABLES", (anyptr) &var_static,        1,
  1480.     'S', 'V', "VOIDARGS",        (anyptr) &void_args,        -1,
  1481.     'S', 'V', "PROTOTYPES",      (anyptr) &prototypes,       -1,
  1482.     'S', 'V', "FULLPROTOTYPING", (anyptr) &fullprototyping,  -1,
  1483.     'S', 'V', "PROCPTRPROTOTYPES",(anyptr)&procptrprototypes, 1,
  1484.     'S', 'V', "CASTARGS",        (anyptr) &castargs,         -1,
  1485.     'S', 'V', "CASTLONGARGS",    (anyptr) &castlongargs,     -1,
  1486.     'S', 'V', "PROMOTEARGS",     (anyptr) &promoteargs,      -1,
  1487.     'S', 'V', "FIXPROMOTEDARGS", (anyptr) &fixpromotedargs,   1,
  1488.     'S', 'V', "PROMOTEENUMS",    (anyptr) &promote_enums,    -1,
  1489.     'S', 'V', "STATICLINKS",     (anyptr) &hasstaticlinks,   -1,
  1490.     'S', 'V', "VARSTRINGS",      (anyptr) &varstrings,        0,
  1491.     'S', 'V', "VARFILES",        (anyptr) &varfiles,          1,
  1492.     'S', 'V', "ADDRSTDFILES",    (anyptr) &addrstdfiles,      0,
  1493.     'S', 'V', "COPYSTRUCTFUNCS", (anyptr) ©structfuncs,  -1,
  1494.     'S', 'V', "ATAN2",           (anyptr) &atan2flag,         0,
  1495.     'S', 'V', "BITWISEMOD",      (anyptr) &mod_po2,          -1,
  1496.     'S', 'V', "BITWISEDIV",      (anyptr) &div_po2,          -1,
  1497.     'S', 'V', "ASSUMEBITS",      (anyptr) &assumebits,        0,
  1498.     'S', 'V', "ASSUMESIGNS",     (anyptr) &assumesigns,       1,
  1499.     'S', 'V', "ALLOCZERONIL",    (anyptr) &alloczeronil,      0,
  1500.     'S', 'V', "PRINTFONLY",      (anyptr) &printfonly,       -1,
  1501.     'S', 'V', "MIXWRITELNS",     (anyptr) &mixwritelns,       1,
  1502.     'S', 'V', "MESSAGESTDERR",   (anyptr) &messagestderr,     1,
  1503.     'I', 'V', "INTEGERWIDTH",    (anyptr) &integerwidth,     -1,
  1504.     'I', 'V', "REALWIDTH",       (anyptr) &realwidth,        12,
  1505.     'S', 'V', "FORMATSTRINGS",   (anyptr) &formatstrings,     0,
  1506.     'S', 'V', "WHILEFGETS",      (anyptr) &whilefgets,        1,
  1507.     'S', 'V', "USEGETS",         (anyptr) &usegets,           1,
  1508.     'S', 'V', "NEWLINESPACE",    (anyptr) &newlinespace,     -1,
  1509.     'S', 'V', "BUILDREADS",      (anyptr) &buildreads,        1,
  1510.     'S', 'V', "BUILDWRITES",     (anyptr) &buildwrites,       1,
  1511.     'S', 'V', "BINARYMODE",      (anyptr) &binarymode,        1,
  1512.     'S', 'V', "READWRITEOPEN",   (anyptr) &readwriteopen,    -1,
  1513.     'C', 'V', "OPENMODE",        (anyptr)  openmode,         40,
  1514.     'S', 'V', "LITERALFILES",    (anyptr) &literalfilesflag, -1,
  1515.     'A', 'V', "LITERALFILE",     (anyptr) &literalfiles,      0,
  1516.     'S', 'V', "STRUCTFILES",     (anyptr) &structfilesflag,   0,
  1517.     'A', 'V', "STRUCTFILE",      (anyptr) &structfiles,       0,
  1518.     'C', 'V', "FILENAMEFILTER",  (anyptr)  filenamefilter,   40,
  1519.     'S', 'V', "FULLSTRWRITE",    (anyptr) &fullstrwrite,     -1,
  1520.     'S', 'V', "FULLSTRREAD",     (anyptr) &fullstrread,       1,
  1521.     'I', 'R', "SETBITS",         (anyptr) &setbits,          -1,
  1522.     'I', 'V', "DEFAULTSETSIZE",  (anyptr) &defaultsetsize,   -1,
  1523.     'S', 'V', "SMALLSETCONST",   (anyptr) &smallsetconst,    -2,
  1524.     'S', 'V', "BIGSETCONST",     (anyptr) &bigsetconst,       1,
  1525.     'S', 'V', "LELERANGE",       (anyptr) &lelerange,         0,
  1526.     'S', 'V', "UNSIGNEDTRICK",   (anyptr) &unsignedtrick,     1,
  1527.     'S', 'V', "USEISALPHA",      (anyptr) &useisalpha,        1,
  1528.     'S', 'V', "USEISSPACE",      (anyptr) &useisspace,        0,
  1529.     'S', 'V', "USESTRNCMP",     (anyptr) &usestrncmp,          1,
  1530.  
  1531. /* TARGET LIBRARY */
  1532.     'G', 'V', "WARNLIBRARY",     (anyptr)  NULL,             WARNLIBR,
  1533.     'S', 'V', "QUOTEINCLUDES",   (anyptr) "eincludes,     1,
  1534.     'X', 'V', "IMPORTFROM",      (anyptr) &importfrom,        1,
  1535.     'A', 'V', "IMPORTDIR",       (anyptr) &importdirs,        0,
  1536.     'A', 'V', "INCLUDEDIR",      (anyptr) &includedirs,       0,
  1537.     'X', 'V', "INCLUDEFROM",     (anyptr) &includefrom,       1,
  1538.     'A', 'V', "LIBRARYFILE",     (anyptr) &librfiles,         0,
  1539.     'C', 'V', "HEADERNAME",      (anyptr)  p2c_h_name,       40,
  1540.     'C', 'V', "PROCTYPENAME",    (anyptr)  name_PROCEDURE,   40,
  1541.     'C', 'V', "UCHARNAME",       (anyptr)  name_UCHAR,       40,
  1542.     'C', 'V', "SCHARNAME",       (anyptr)  name_SCHAR,       40,
  1543.     'C', 'V', "BOOLEANNAME",     (anyptr)  name_BOOLEAN,     40,
  1544.     'C', 'V', "TRUENAME",        (anyptr)  name_TRUE,        40,
  1545.     'C', 'V', "FALSENAME",       (anyptr)  name_FALSE,       40,
  1546.     'C', 'V', "NULLNAME",        (anyptr)  name_NULL,        40,
  1547.     'C', 'V', "ESCAPECODENAME",  (anyptr)  name_ESCAPECODE,  40,
  1548.     'C', 'V', "IORESULTNAME",    (anyptr)  name_IORESULT,    40,
  1549.     'C', 'V', "ARGCNAME",        (anyptr)  name_ARGC,        40,
  1550.     'C', 'V', "ARGVNAME",        (anyptr)  name_ARGV,        40,
  1551.     'C', 'V', "MAINNAME",        (anyptr)  name_MAIN,        40,
  1552.     'C', 'V', "ESCAPENAME",      (anyptr)  name_ESCAPE,      40,
  1553.     'C', 'V', "ESCIONAME",       (anyptr)  name_ESCIO,       40,
  1554.     'C', 'V', "CHECKIONAME",     (anyptr)  name_CHKIO,       40,
  1555.     'C', 'V', "SETIONAME",       (anyptr)  name_SETIO,       40,
  1556.     'C', 'V', "FILENOTFOUNDNAME",(anyptr)  filenotfoundname, 40,
  1557.     'C', 'V', "FILENOTOPENNAME", (anyptr)  filenotopenname,  40,
  1558.     'C', 'V', "FILEWRITEERRORNAME",(anyptr)filewriteerrorname,40,
  1559.     'C', 'V', "BADINPUTFORMATNAME",(anyptr)badinputformatname,40,
  1560.     'C', 'V', "ENDOFFILENAME",   (anyptr)  endoffilename,    40,
  1561.     'C', 'V', "OUTMEMNAME",      (anyptr)  name_OUTMEM,      40,
  1562.     'C', 'V', "CASECHECKNAME",   (anyptr)  name_CASECHECK,   40,
  1563.     'C', 'V', "NILCHECKNAME",    (anyptr)  name_NILCHECK,    40,
  1564.     'C', 'V', "SETBITSNAME",     (anyptr)  name_SETBITS,     40,
  1565.     'S', 'V', "SPRINTFVALUE",    (anyptr) &sprintf_value,    -1,
  1566.     'C', 'V', "SPRINTFNAME",     (anyptr)  sprintfname,      40,
  1567.     'C', 'V', "MEMCPYNAME",      (anyptr)  memcpyname,       40,
  1568.     'C', 'V', "ROUNDNAME",       (anyptr)  roundname,        40,
  1569.     'C', 'V', "DIVNAME",     (anyptr)  divname,         40,
  1570.     'C', 'V', "MODNAME",     (anyptr)  modname,         40,
  1571.     'C', 'V', "REMNAME",     (anyptr)  remname,         40,
  1572.     'C', 'V', "STRCICMPNAME",    (anyptr)  strcicmpname,     40,
  1573.     'C', 'V', "STRSUBNAME",      (anyptr)  strsubname,       40,
  1574.     'C', 'V', "STRPOSNAME",      (anyptr)  strposname,       40,
  1575.     'S', 'V', "STRCPYLEFT",      (anyptr) &strcpyleft,        1,
  1576.     'C', 'V', "STRDELETENAME",   (anyptr)  strdeletename,    40,
  1577.     'C', 'V', "STRINSERTNAME",   (anyptr)  strinsertname,    40,
  1578.     'C', 'V', "STRMOVENAME",     (anyptr)  strmovename,         40,
  1579.     'C', 'V', "STRLTRIMNAME",    (anyptr)  strltrimname,     40,
  1580.     'C', 'V', "STRRTRIMNAME",    (anyptr)  strrtrimname,     40,
  1581.     'C', 'V', "STRRPTNAME",      (anyptr)  strrptname,       40,
  1582.     'C', 'V', "STRPADNAME",      (anyptr)  strpadname,       40,
  1583.     'C', 'V', "ABSNAME",         (anyptr)  absname,          40,
  1584.     'C', 'V', "ODDNAME",         (anyptr)  oddname,          40,
  1585.     'C', 'V', "EVENNAME",        (anyptr)  evenname,         40,
  1586.     'C', 'V', "SWAPNAME",        (anyptr)  swapname,         40,
  1587.     'C', 'V', "MALLOCNAME",      (anyptr)  mallocname,       40,
  1588.     'C', 'V', "FREENAME",        (anyptr)  freename,         40,
  1589.     'C', 'V', "FREERVALUENAME",  (anyptr)  freervaluename,   40,
  1590.     'X', 'V', "SPECIALMALLOC",   (anyptr) &specialmallocs,    1,
  1591.     'X', 'V', "SPECIALFREE",     (anyptr) &specialfrees,      1,
  1592.     'X', 'V', "SPECIALSIZEOF",   (anyptr) &specialsizeofs,    1,
  1593.     'C', 'V', "RANDREALNAME",    (anyptr)  randrealname,     40,
  1594.     'C', 'V', "RANDINTNAME",     (anyptr)  randintname,      40,
  1595.     'C', 'V', "RANDOMIZENAME",   (anyptr)  randomizename,    40,
  1596.     'C', 'V', "SKIPSPACENAME",   (anyptr)  skipspacename,    40,
  1597.     'C', 'V', "READLNNAME",      (anyptr)  readlnname,       40,
  1598.     'C', 'V', "FREOPENNAME",     (anyptr)  freopenname,      40,
  1599.     'C', 'V', "EOFNAME",         (anyptr)  eofname,          40,
  1600.     'C', 'V', "EOLNNAME",        (anyptr)  eolnname,         40,
  1601.     'C', 'V', "FILEPOSNAME",     (anyptr)  fileposname,      40,
  1602.     'C', 'V', "MAXPOSNAME",      (anyptr)  maxposname,       40,
  1603.     'C', 'V', "SETUNIONNAME",    (anyptr)  setunionname,     40,
  1604.     'C', 'V', "SETINTNAME",      (anyptr)  setintname,       40,
  1605.     'C', 'V', "SETDIFFNAME",     (anyptr)  setdiffname,      40,
  1606.     'C', 'V', "SETXORNAME",      (anyptr)  setxorname,       40,
  1607.     'C', 'V', "SETINNAME",       (anyptr)  setinname,        40,
  1608.     'C', 'V', "SETADDNAME",      (anyptr)  setaddname,       40,
  1609.     'C', 'V', "SETADDRANGENAME", (anyptr)  setaddrangename,  40,
  1610.     'C', 'V', "SETREMNAME",      (anyptr)  setremname,       40,
  1611.     'C', 'V', "SETEQUALNAME",    (anyptr)  setequalname,     40,
  1612.     'C', 'V', "SUBSETNAME",      (anyptr)  subsetname,       40,
  1613.     'C', 'V', "SETCOPYNAME",     (anyptr)  setcopyname,      40,
  1614.     'C', 'V', "SETEXPANDNAME",   (anyptr)  setexpandname,    40,
  1615.     'C', 'V', "SETPACKNAME",     (anyptr)  setpackname,      40,
  1616.     'C', 'V', "SIGNEXTENDNAME",  (anyptr)  signextname,      40,
  1617.     'C', 'V', "GETBITSNAME",     (anyptr)  getbitsname,      40,
  1618.     'C', 'V', "CLRBITSNAME",     (anyptr)  clrbitsname,      40,
  1619.     'C', 'V', "PUTBITSNAME",     (anyptr)  putbitsname,      40,
  1620.     'C', 'V', "STOREBITSNAME",   (anyptr)  storebitsname,    40,
  1621.     'C', 'V', "DECLBUFNAME",     (anyptr)  declbufname,         40,
  1622.     'C', 'V', "DECLBUFNCNAME",     (anyptr)  declbufncname,    40,
  1623.     'A', 'V', "BUFFEREDFILE",    (anyptr) &bufferedfiles,     0,
  1624.     'A', 'V', "UNBUFFEREDFILE",  (anyptr) &unbufferedfiles,   0,
  1625.     'C', 'V', "RESETBUFNAME",     (anyptr)  resetbufname,     40,
  1626.     'C', 'V', "SETUPBUFNAME",     (anyptr)  setupbufname,     40,
  1627.     'C', 'V', "GETFBUFNAME",     (anyptr)  getfbufname,      40,
  1628.     'C', 'V', "CHARGETFBUFNAME", (anyptr)  chargetfbufname,  40,
  1629.     'C', 'V', "ARRAYGETFBUFNAME",(anyptr)  arraygetfbufname, 40,
  1630.     'C', 'V', "PUTFBUFNAME",     (anyptr)  putfbufname,      40,
  1631.     'C', 'V', "CHARPUTFBUFNAME", (anyptr)  charputfbufname,  40,
  1632.     'C', 'V', "ARRAYPUTFBUFNAME",(anyptr)  arrayputfbufname, 40,
  1633.     'C', 'V', "GETNAME",         (anyptr)  getname,          40,
  1634.     'C', 'V', "CHARGETNAME",     (anyptr)  chargetname,      40,
  1635.     'C', 'V', "ARRAYGETNAME",    (anyptr)  arraygetname,     40,
  1636.     'C', 'V', "PUTNAME",         (anyptr)  putname,          40,
  1637.     'C', 'V', "CHARPUTNAME",     (anyptr)  charputname,      40,
  1638.     'C', 'V', "ARRAYPUTNAME",    (anyptr)  arrayputname,     40,
  1639.     'C', 'V', "EOFBUFNAME",      (anyptr)  eofbufname,       40,
  1640.     'C', 'V', "FILEPOSBUFNAME",  (anyptr)  fileposbufname,   40,
  1641.  
  1642. /* RANGE CHECKING */
  1643.     'S', 'V', "CASECHECK",       (anyptr) &casecheck,         0,
  1644.     'S', 'V', "ARRAYCHECK",      (anyptr) &arraycheck,        0,
  1645.     'S', 'V', "RANGECHECK",      (anyptr) &rangecheck,        0,
  1646.     'S', 'V', "NILCHECK",        (anyptr) &nilcheck,          0,
  1647.     'S', 'V', "MALLOCCHECK",     (anyptr) &malloccheck,       0,
  1648.     'S', 'V', "CHECKFILEOPEN",   (anyptr) &checkfileopen,     1,
  1649.     'S', 'V', "CHECKFILEISOPEN", (anyptr) &checkfileisopen,   0,
  1650.     'S', 'V', "CHECKFILEWRITE",  (anyptr) &checkfilewrite,    2,
  1651.     'S', 'V', "CHECKREADFORMAT", (anyptr) &checkreadformat,   2,
  1652.     'S', 'V', "CHECKFILEEOF",    (anyptr) &checkfileeof,      2,
  1653.     'S', 'V', "CHECKSTDINEOF",   (anyptr) &checkstdineof,     2,
  1654.     'S', 'V', "CHECKFILESEEK",   (anyptr) &checkfileseek,     2,
  1655. }
  1656. #endif /* define_parameters */
  1657.     ;
  1658.  
  1659.  
  1660. #undef extern
  1661.  
  1662.  
  1663. #ifdef define_parameters
  1664.   int numparams = sizeof(rctable) / sizeof(struct rcstruct);
  1665.   Strlist *rcprevvalues[sizeof(rctable) / sizeof(struct rcstruct)];
  1666. #else
  1667.   extern int numparams;
  1668.   extern Strlist *rcprevvalues[];
  1669. #endif /* define_parameters */
  1670.  
  1671.  
  1672.  
  1673. /* Global variables: */
  1674.  
  1675. #ifdef define_globals
  1676. # define extern
  1677. #endif /* define_globals */
  1678.  
  1679.  
  1680. extern char *charname, *ucharname, *scharname, *integername;
  1681. extern long min_schar, max_schar, max_uchar;
  1682. extern long min_sshort, max_sshort, max_ushort;
  1683.  
  1684. extern char *alloctemp;
  1685. extern short error_crash;
  1686. extern int total_bytes, total_exprs, total_meanings, total_strings;
  1687. extern int total_symbols, total_types, total_stmts, total_strlists;
  1688. extern int total_literals, total_ctxstacks, total_tempvars, total_inprecs;
  1689. extern int total_parens, total_ptrdescs, total_misc;
  1690. extern int final_bytes, final_exprs, final_meanings, final_strings;
  1691. extern int final_symbols, final_types, final_stmts, final_strlists;
  1692. extern int final_literals, final_ctxstacks, final_tempvars, final_inprecs;
  1693. extern int final_parens, final_ptrdescs, final_misc;
  1694.  
  1695. extern char *infname, *outfname, *codefname, *hdrfname;
  1696. extern char *requested_module;
  1697. extern FILE *inf, *outf, *codef, *hdrf, *logf;
  1698. extern short setup_complete, found_module;
  1699. extern short regression, verbose, conserve_mem;
  1700. extern int inf_lnum, inf_ltotal;
  1701.  
  1702. extern int outindent, outputmode;
  1703. extern int outf_lnum;
  1704. extern short dontbreaklines;
  1705.  
  1706. extern Token curtok;
  1707. extern char curtokbuf[256], curtokcase[256];
  1708. extern char *inbufptr;
  1709. extern int inbufindent;
  1710. extern long curtokint;
  1711. extern Symbol *curtoksym;
  1712. extern Meaning *curtokmeaning;
  1713. extern Strlist *curcomments;
  1714. extern Strlist **keepingstrlist;
  1715. extern short ignore_directives, skipping_module;
  1716. extern short C_lex;
  1717. extern char sysprog_flag, partial_eval_flag, iocheck_flag;
  1718. extern char range_flag, ovflcheck_flag, stackcheck_flag;
  1719. extern short switch_strpos;
  1720. extern int fixedflag;
  1721. extern int numimports;
  1722. extern Strlist *tempoptionlist;
  1723. extern long curserial, serialcount;
  1724. extern int notephase;
  1725. extern Strlist *permimports;
  1726. extern int permflag;
  1727.  
  1728. #define SYMHASHSIZE 293
  1729. extern Symbol *(symtab[SYMHASHSIZE]);
  1730. extern short partialdump;
  1731.  
  1732. #define MAXWITHS 100
  1733. extern int withlevel;
  1734. extern Type *withlist[MAXWITHS];
  1735. extern Expr *withexprs[MAXWITHS];
  1736.  
  1737. extern Token blockkind;
  1738. extern Meaning *curctx, *curctxlast, *nullctx;
  1739.  
  1740. extern int fixexpr_tryblock;
  1741. extern short fixexpr_tryflag;
  1742.  
  1743. extern Type *tp_integer, *tp_char, *tp_boolean, *tp_real, *tp_longreal;
  1744. extern Type *tp_anyptr, *tp_jmp_buf, *tp_schar, *tp_uchar, *tp_charptr;
  1745. extern Type *tp_int, *tp_sshort, *tp_ushort, *tp_abyte, *tp_sbyte, *tp_ubyte;
  1746. extern Type *tp_void, *tp_str255, *tp_strptr, *tp_text, *tp_bigtext;
  1747. extern Type *tp_unsigned, *tp_uint, *tp_sint, *tp_smallset, *tp_proc;
  1748. extern Meaning *mp_string, *mp_true, *mp_false;
  1749. extern Meaning *mp_input, *mp_output, *mp_stderr;
  1750. extern Meaning *mp_maxint, *mp_minint, *mp_escapecode, *mp_ioresult;
  1751. extern Meaning *mp_uchar, *mp_schar, *mp_unsigned, *mp_uint;
  1752. extern Meaning *mp_str_hp, *mp_str_turbo;
  1753. extern Meaning *mp_val_modula, *mp_val_turbo;
  1754. extern Meaning *mp_blockread_ucsd, *mp_blockread_turbo;
  1755. extern Meaning *mp_blockwrite_ucsd, *mp_blockwrite_turbo;
  1756. extern Meaning *mp_dec_dec, *mp_dec_turbo;
  1757. extern Expr *ex_input, *ex_output;
  1758. extern Strlist *attrlist;
  1759.  
  1760.  
  1761. #ifndef define_globals
  1762. # undef extern
  1763. #endif
  1764.  
  1765.  
  1766.  
  1767.  
  1768. /* Function declarations are created automatically by "makeproto" */
  1769.  
  1770. /* ### BK
  1771. #include "p2c.hdrs"
  1772.  
  1773. #include "p2c.proto"
  1774. */
  1775.  
  1776. #include "p2c.hdr"
  1777.  
  1778. #include "p2c.pro"
  1779.  
  1780.  
  1781. /* Our library omits declarations for these functions! */
  1782.  
  1783. /* ### BK
  1784. int link           PP( (char *, char *) );
  1785. int unlink         PP( (char *) );
  1786. */
  1787.  
  1788.  
  1789.  
  1790. #define minspcthresh ((minspacingthresh >= 0) ? minspacingthresh : minspacing)
  1791.  
  1792. #define delfreearg(ex, n) freeexpr((*(ex))->args[n]), deletearg(ex, n)
  1793. #define delsimpfreearg(ex, n) freeexpr((*(ex))->args[n]), delsimparg(ex, n)
  1794.  
  1795. #define swapexprs(a,b) do {register Expr *t=(a);(a)=(b);(b)=(t);} while (0)
  1796. #define swapstmts(a,b) do {register Stmt *t=(a);(a)=(b);(b)=(t);} while (0)
  1797.  
  1798. #define CHECKORDEXPR(ex,v) ((ex)->kind==EK_CONST ? (ex)->val.i - (v) : -2)
  1799.  
  1800. #define FCheck(flag)  ((flag) == 1 || (!iocheck_flag && (flag)))
  1801. #define checkeof(fex)  (isvar(fex, mp_input) ? FCheck(checkstdineof)  \
  1802.                          : FCheck(checkfileeof))
  1803.  
  1804.  
  1805. #ifdef TEST_MALLOC   /* Memory testing */
  1806.  
  1807. #define ALLOC(N,TYPE,NAME) \
  1808.     (TYPE *) test_malloc((unsigned)((N)*sizeof(TYPE)),  \
  1809.              &__CAT__(total_,NAME), &__CAT__(final_,NAME))
  1810.  
  1811. #define ALLOCV(N,TYPE,NAME) \
  1812.     (TYPE *) test_malloc((unsigned)(N),  \
  1813.              &__CAT__(total_,NAME), &__CAT__(final_,NAME))
  1814.  
  1815. #define REALLOC(P,N,TYPE) \
  1816.     (TYPE *) test_realloc((char *)(P), (unsigned)((N)*sizeof(TYPE)))
  1817.  
  1818. #define FREE(P) test_free((char*)(P))
  1819.  
  1820. #else  /* not TEST_MALLOC */
  1821.  
  1822. /* If p2c always halts immediately with an out-of-memory error, try
  1823.    recompiling all modules with BROKEN_OR defined. */
  1824. #ifdef BROKEN_OR
  1825.  
  1826. #define ALLOC(N,TYPE,NAME) \
  1827.     ((alloctemp = malloc((unsigned)((N)*sizeof(TYPE)))), \
  1828.      (alloctemp ? (TYPE *) alloctemp : (TYPE *) outmem()))
  1829.  
  1830. #define ALLOCV(N,TYPE,NAME) \
  1831.     ((alloctemp = malloc((unsigned)(N))), \
  1832.      (alloctemp ? (TYPE *) alloctemp : (TYPE *) outmem()))
  1833.  
  1834. #define REALLOC(P,N,TYPE) \
  1835.     ((alloctemp = realloc((char*)(P), (unsigned)((N)*sizeof(TYPE)))), \
  1836.      (alloctemp ? (TYPE *) alloctemp : (TYPE *) outmem()))
  1837.  
  1838. #define FREE(P) free((char*)(P))
  1839.  
  1840. #else  /* not BROKEN_OR */
  1841.  
  1842. #define ALLOC(N,TYPE,NAME) \
  1843.     ((alloctemp = malloc((unsigned)((N)*sizeof(TYPE)))) || outmem(), \
  1844.      (TYPE *) alloctemp)
  1845.  
  1846. #define ALLOCV(N,TYPE,NAME) \
  1847.     ((alloctemp = malloc((unsigned)(N))) || outmem(), \
  1848.      (TYPE *) alloctemp)
  1849.  
  1850. #define REALLOC(P,N,TYPE) \
  1851.     ((alloctemp = realloc((char*)(P), (unsigned)((N)*sizeof(TYPE)))) || outmem(), \
  1852.      (TYPE *) alloctemp)
  1853.  
  1854. #define FREE(P) free((char*)(P))
  1855.  
  1856. #endif  /* BROKEN_OR */
  1857. #endif  /* TEST_MALLOC */
  1858.  
  1859.  
  1860. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  1861. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  1862.  
  1863.  
  1864.  
  1865. #ifdef toupper
  1866. # undef toupper
  1867. # undef tolower
  1868. # define toupper(c)   my_toupper(c)
  1869. # define tolower(c)   my_tolower(c)
  1870. #endif
  1871.  
  1872. #ifndef _toupper
  1873. # if 'A' == 65 && 'a' == 97
  1874. #  define _toupper(c)  ((c)-'a'+'A')
  1875. #  define _tolower(c)  ((c)-'A'+'a')
  1876. # else
  1877. #  ifdef toupper
  1878. #   undef toupper   /* hope these are shadowing real functions, */
  1879. #   undef tolower   /* because my_toupper calls _toupper! */
  1880. #  endif
  1881. #  define _toupper(c)  toupper(c)
  1882. #  define _tolower(c)  tolower(c)
  1883. # endif
  1884. #endif
  1885.  
  1886.  
  1887.  
  1888.  
  1889. /* End. */
  1890.  
  1891.