home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 379a.lha / p2c1_13a / src / src.zoo / trans.h < prev    next >
C/C++ Source or Header  |  1990-03-14  |  76KB  |  1,791 lines

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