home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / p2cbin / p2c.cat < prev    next >
Text File  |  1993-09-12  |  60KB  |  1,188 lines

  1.  
  2.  
  3.  
  4.    local                                                               P2C(1)
  5.  
  6.  
  7.  
  8.    NAME
  9.      p2c - Pascal to C translator, version 1.20
  10.  
  11.    SYNOPSIS
  12.      p2c [ options ] [ file [ module ] ]
  13.  
  14.    DESCRIPTION
  15.      _✓P_✓2_✓c is a tool for translating Pascal programs into C.  The input con-
  16.      sists of a set of source files in any of the following Pascal dialects:
  17.      HP Pascal, Turbo/UCSD Pascal, DEC VAX Pascal, Oregon Software Pascal/2,
  18.      Macintosh Programmer's Workshop Pascal, Sun/Berkeley Pascal.  Modula-2
  19.      syntax is also supported.  Output is a set of .c and .h files that
  20.      comprise an equivalent program in any of several dialects of C.  Output
  21.      code may be kept machine- and dialect-independent, or it may be targeted
  22.      to a specific machine and compiler.  Most reasonable Pascal programs are
  23.      converted into fully functional C which will compile and run with no
  24.      further modifications, although _✓p_✓2_✓c sometimes chooses to generate read-
  25.      able code at the expense of absolute generality. _✓P_✓2_✓c endeavors to insert
  26.      notes and warning messages into the output code to point out areas which
  27.      may require human intervention.  Output code is arranged to be readable
  28.      and efficient, and to make use of C idioms wherever possible.  The main
  29.      goal of the translation is to produce C files which are pleasant and
  30.      "natural" enough to be acceptable as the new source files for a program.
  31.      In a pinch, _✓p_✓2_✓c will also serve as an ad hoc Pascal compiler.
  32.  
  33.      Code generated by _✓p_✓2_✓c normally does not assume characters are signed or
  34.      unsigned.  Also, it assumes int is the same as either short or long but
  35.      does not depend on which.  However, if int is not the same as long it is
  36.      best to use a modern C compiler which supports prototypes.  Generated
  37.      code does not require an ANSI-compatible compiler (unless ANSI-style
  38.      code is requested), but it does use various ANSI-standard library rou-
  39.      tines.
  40.  
  41.      All generated code includes the file <_✓p_✓2_✓c/_✓p_✓2_✓c._✓h> which in turn includes
  42.      <_✓s_✓t_✓d_✓i_✓o._✓h> and various other common resources.  Also, many translated
  43.      programs will need to be linked with the run-time library, typically -
  44.      _✓l_✓p_✓2_✓c.
  45.  
  46.      Given a file name, _✓p_✓2_✓c reads from the specified file and outputs to a
  47.      file with a .c suffix added or substituted.  For example,
  48.  
  49.           p2c myfile.pas
  50.  
  51.      reads from _✓m_✓y_✓f_✓i_✓l_✓e._✓p_✓a_✓s to produce the file _✓m_✓y_✓f_✓i_✓l_✓e._✓c. The input file may
  52.      contain a Pascal main program or a single Pascal module (or "unit" in
  53.      Turbo and UCSD Pascal nomenclature), or it may just contain a number of
  54.      procedures and declarations.  _✓P_✓2_✓c is designed to work for correct input
  55.      programs.  That is, it will accept partial programs but may occasionally
  56.      core dump if the input refers to undefined symbols.
  57.  
  58.      If the input is a module, the translator will also produce a file
  59.      _✓m_✓o_✓d_✓u_✓l_✓e.h containing a translation of the module's interface section.
  60.      The implementation section may be omitted in which case only the .h file
  61.  
  62.  
  63.                                                                             1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.    P2C(1)                                                               local
  71.  
  72.  
  73.      will be interesting.  If the program or module has include files, these
  74.      may cause additional .c files to be generated depending on the value of
  75.      the ExpandIncludes option (see below).
  76.  
  77.      If no file name is given, _✓p_✓2_✓c reads Pascal from the standard input and
  78.      writes the resulting C to standard output (though a .h file may still be
  79.      produced).  If a file name and module name are given, the file may
  80.      include several modules (or units).  The specified module is translated;
  81.      any others are skipped.  The output files will be named _✓m_✓o_✓d_✓u_✓l_✓e.c and
  82.      _✓m_✓o_✓d_✓u_✓l_✓e.h.  _✓P_✓2_✓c never translates more than one module per run.
  83.  
  84.      Before starting, _✓p_✓2_✓c reads the file /_✓t_✓m_✓p/_✓q_✓q/_✓h_✓o_✓m_✓e/_✓p_✓2_✓c_✓r_✓c for a number of
  85.      configuration parameters.  (The actual path used on your system may
  86.      vary.  The -i option is a handy way to examine this file.) If the P2CRC
  87.      environment variable is set, it gives the name of a file to read instead
  88.      of the system file; this file can start with Include %H/p2crc to include
  89.      the system file.  Next, _✓p_✓2_✓c attempts to read the file _✓p_✓2_✓c_✓r_✓c in your
  90.      directory for further configuration.  If this file does not exist, _✓p_✓2_✓c
  91.      looks for ._✓p_✓2_✓c_✓r_✓c instead.
  92.  
  93.    OPTIONS
  94.  
  95.      -o _✓c_✓f_✓i_✓l_✓e
  96.           Use _✓c_✓f_✓i_✓l_✓e in place of _✓f_✓i_✓l_✓e.c or _✓m_✓o_✓d_✓u_✓l_✓e.c as the primary output
  97.           file.  A single dash (`-o -') says to write the C code to the stan-
  98.           dard output.
  99.  
  100.      -h _✓h_✓f_✓i_✓l_✓e
  101.           Use _✓h_✓f_✓i_✓l_✓e in place of _✓m_✓o_✓d_✓u_✓l_✓e.h as the output file for interface
  102.           text.  This only has effect if the input is an HP Pascal module or
  103.           a Turbo Pascal unit.
  104.  
  105.      -s _✓s_✓f_✓i_✓l_✓e
  106.           Read interface text from _✓s_✓f_✓i_✓l_✓e before beginning the translation.
  107.           This file typically contains one or more modules, often with inter-
  108.           face sections omitted for speed, which the program or module being
  109.           translated will use.  (Typically the ImportFrom and ImportDir
  110.           parameters in _✓p_✓2_✓c_✓r_✓c are set up to allow _✓p_✓2_✓c to locate interface
  111.           text without needing any -s options.)  If there are several -s
  112.           options in the command, the _✓s_✓f_✓i_✓l_✓e_✓s are read from left to right.
  113.  
  114.      -p_✓n  Display progress of translation in the form of a line number/file
  115.           name display.  This is refreshed every _✓n lines, 25 by default.
  116.  
  117.      -c _✓r_✓c_✓f_✓i_✓l_✓e
  118.           Read local configuration commands from _✓r_✓c_✓f_✓i_✓l_✓e instead of _✓p_✓2_✓c_✓r_✓c or
  119.           ._✓p_✓2_✓c_✓r_✓c. A dash (`-c -') in place of _✓r_✓c_✓f_✓i_✓l_✓e causes no local confi-
  120.           guration file to be used.
  121.  
  122.      -v   ("Vanilla.")  Do not read from the system configuration file
  123.           /_✓t_✓m_✓p/_✓q_✓q/_✓h_✓o_✓m_✓e/_✓p_✓2_✓c_✓r_✓c. Since some of the parameters in this file are
  124.           required, your local configuration file must include those parame-
  125.           ters instead.  This also suppresses the file named by the P2CRC
  126.           environment variable.
  127.  
  128.  
  129.    2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.    local                                                               P2C(1)
  137.  
  138.  
  139.      -H _✓h_✓o_✓m_✓e_✓d_✓i_✓r
  140.           Use _✓h_✓o_✓m_✓e_✓d_✓i_✓r instead of /_✓t_✓m_✓p/_✓q_✓q/_✓h_✓o_✓m_✓e as the _✓p_✓2_✓c home directory.  The
  141.           system _✓p_✓2_✓c_✓r_✓c file will be searched for in this directory.
  142.  
  143.      -I_✓p_✓a_✓t_✓t_✓e_✓r_✓n
  144.           Add _✓p_✓a_✓t_✓t_✓e_✓r_✓n to the ImportDir search list of places to find modules
  145.           which are imported.  The pattern should include a %_✓s to represent
  146.           the module name, and should evaluate to a potential file name for
  147.           that module's source code.  For example, ../%s.pas looks for
  148.           _✓m_✓o_✓d_✓u_✓l_✓e_✓n_✓a_✓m_✓e.pas in the parent of the current directory.
  149.  
  150.      -i   This special option (which must be the only argument on the command
  151.           line if used) simply copies the system configuration file
  152.           /_✓t_✓m_✓p/_✓q_✓q/_✓h_✓o_✓m_✓e/_✓p_✓2_✓c_✓r_✓c to the standard output in its entirety.  (It may
  153.           be used with -H, but -i is most useful precisely when you don't
  154.           know the location of the home directory.)
  155.  
  156.      -q   Quiet mode.  Suppresses output of status messages during transla-
  157.           tion.
  158.  
  159.      -E_✓n  Abort translation after _✓n errors.  If _✓n is omitted it defaults to
  160.           zero, which means unlimited errors are allowed.  Use -E1 to make
  161.           _✓p_✓2_✓c halt after the first error.
  162.  
  163.      -e   Echo the Pascal source into the output file, surrounded by #ifdefs.
  164.           This is the same as the CopySource parameter in the _✓p_✓2_✓c_✓r_✓c file.
  165.  
  166.      -a   Produce modern ANSI C.  This is a convenient override for the AnsiC
  167.           parameter in the _✓p_✓2_✓c_✓r_✓c file.
  168.  
  169.      -L _✓l_✓a_✓n_✓g_✓u_✓a_✓g_✓e
  170.           Select input language name, such as VAX or TURBO.  This is a con-
  171.           venient override for the Language parameter.
  172.  
  173.      -V   Verbose mode.  This causes _✓p_✓2_✓c to generate an additional ".log"
  174.           file with further details of the translation, such as a list of
  175.           warnings and notes including those which are suppressed in the reg-
  176.           ular output.
  177.  
  178.      -M0  Disable memory conservation.  This prevents _✓p_✓2_✓c from freeing vari-
  179.           ous data structures after translating each function, in case this
  180.           new conservation feature causes unforseen problems.
  181.  
  182.      -R   Regression testing mode.  Formats notes and warning messages in a
  183.           way that makes it easier to run _✓d_✓i_✓f_✓f(1) on the output of _✓p_✓2_✓c.
  184.  
  185.      _✓P_✓2_✓c also understands a few debugging options which may occasionally be
  186.      useful when tracking down translation problems.  The -d_✓n option sets the
  187.      "debug level" to _✓n, a small integer which is normally zero.  Debugging
  188.      output is written into the regular output file along with the C code;
  189.      the higher your _✓n, the more "wallpaper" you get.  Also, -t prints debug-
  190.      ging information at every Pascal token, -B_✓n enables line-breaker debug-
  191.      ging, and -C_✓n enables comment placement debugging.
  192.  
  193.  
  194.  
  195.                                                                             3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.    P2C(1)                                                               local
  203.  
  204.  
  205.    CHOICE OF SOURCE LANGUAGE
  206.      The Language configuration parameter or -L command-line option tells _✓p_✓2_✓c
  207.      which Pascal dialect to expect in the input file.  Any language features
  208.      which do not overlap between dialects are supported all of the time.
  209.      The Language parameter is consulted when a syntax or usage is detected
  210.      that has different meanings in two different dialects, and also to
  211.      determine default values for various other translation parameters as
  212.      described below.
  213.  
  214.      The following language words are supported by _✓p_✓2_✓c. Names are case-
  215.      insensitive.
  216.  
  217.      HP      HP Pascal.  This is the default language.  All features of HP
  218.              Standard Pascal, the Pascal Workstation version, are supported
  219.              except as noted in BUGS below.  Some features of MODCAL, HP's
  220.              extended Pascal, are also supported.  This is a superset of ISO
  221.              standard Pascal, including conformant arrays and procedural
  222.              parameters.
  223.  
  224.      HP-UX   HP Pascal, HP-UX version.  Almost identical to the "HP" dialect.
  225.  
  226.      Turbo   Turbo Pascal 5.0 for the IBM PC.  Few conflicts with HP Pascal,
  227.              so the Language parameter is not often needed for Turbo.  (Most
  228.              important is that the Turbo and HP dialects use 16 and 32 bit
  229.              integers, respectively.)
  230.  
  231.      UCSD    UCSD Pascal.  Similar to Turbo in many ways.
  232.  
  233.      MPW     Macintosh Programmer's Workshop Pascal 2.0.  Should also do a
  234.              pretty good job for Lightspeed Pascal.  Object Pascal features
  235.              are not supported, nor is the fact that char variables are some-
  236.              times stored in 16 bits.
  237.  
  238.      VAX     VAX/VMS Pascal version 3.5.  Most but not all language features
  239.              supported.  This has not yet been tested on large programs.
  240.  
  241.      Oregon  Oregon Software Pascal/2.  All features implemented.
  242.  
  243.      Berk    Berkeley Pascal with Sun extensions.
  244.  
  245.      Modula  Modula-2.  Based on Wirth's _✓P_✓r_✓o_✓g_✓r_✓a_✓m_✓m_✓i_✓n_✓g _✓i_✓n _✓M_✓o_✓d_✓u_✓l_✓a-_✓2, 3rd edi-
  246.              tion.  Proper setting of the Language parameter is _✓n_✓o_✓t optional.
  247.              Translation will be incomplete in most cases, but should be good
  248.              enough to work with.  Structure of local sub-modules is essen-
  249.              tially ignored; like-named identifiers may be confused.  Type
  250.              WORD is translated as an integer, but type ADDRESS is translated
  251.              as char * or void *; this may cause inconsistencies in the out-
  252.              put code.
  253.  
  254.              Modula-2 modules have two parts in separate files.  Suppose
  255.              these are called _✓f_✓o_✓o._✓d_✓e_✓f (definition part) and _✓f_✓o_✓o._✓m_✓o_✓d (imple-
  256.              mentation part) for module _✓f_✓o_✓o. Then a pattern like %s.def must
  257.              be included in the ImportDir list, and LibraryFile must be
  258.              changed to refer to _✓s_✓y_✓s_✓t_✓e_✓m._✓m_✓2 instead of _✓s_✓y_✓s_✓t_✓e_✓m._✓i_✓m_✓p. To
  259.  
  260.  
  261.    4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.    local                                                               P2C(1)
  269.  
  270.  
  271.              translate the definition part, give the command
  272.  
  273.                   p2c foo.def
  274.  
  275.              to translate the definition part into files _✓f_✓o_✓o._✓h and _✓f_✓o_✓o._✓c; the
  276.              latter will usually be empty.  The command
  277.  
  278.                   p2c -s foo.def foo.mod
  279.  
  280.              will translate the implementation part into file _✓f_✓o_✓o._✓c.
  281.  
  282.      Even if all language features are supported for a dialect, some prede-
  283.      fined functions may be omitted.  In these cases, the function call will
  284.      be translated literally into C with a warning.  Some hand modification
  285.      may be required.
  286.  
  287.    CONFIGURATION PARAMETERS
  288.      _✓P_✓2_✓c is highly configurable.  The defaults are suitable for most applica-
  289.      tions, but customizing these parameters will help you get the best pos-
  290.      sible translation.  Since the output of _✓p_✓2_✓c is intended to be used as
  291.      human-maintainable source code, there are many parameters for describing
  292.      the coding style and conventions you prefer.  Others give hints about
  293.      your program that help _✓p_✓2_✓c to generate more correct, efficient, or read-
  294.      able code.
  295.  
  296.      The _✓p_✓2_✓c_✓r_✓c files contain a list of parameters, one per line.  The system
  297.      configuration file, which may be viewed using the -i option to _✓p_✓2_✓c,
  298.      serves as an example of the proper format.  Parameter names are case-
  299.      insensitive.  If a parameter name occurs exactly once in the system
  300.      _✓p_✓2_✓c_✓r_✓c, this indicates that it must have a unique value and the last
  301.      value given to it by the configuration files is used.  Other parameters
  302.      are written several times in a row; these are lists to which each confi-
  303.      guration line adds an entry.
  304.  
  305.      Many _✓p_✓2_✓c_✓r_✓c options take a numeric value of 0 or 1, roughly corresponding
  306.      to "no" or "yes."  Sometimes a blank value or the value "def"
  307.      corresponds to an intermediate "maybe" state.  For example, the stylis-
  308.      tic option ExtraParens switches between copious or minimal parentheses
  309.      in expressions, with the default being a nice compromise intended to be
  310.      best for readers with an average knowledge of C operator precedences.
  311.  
  312.      Configuration options may also be embedded in the source file in the
  313.      form of Pascal comments:
  314.  
  315.           {ShortOpt=0} {AvoidName=fred}
  316.           {FuncMacro slope(x,y)=atan2(y,x)*RadDeg}
  317.  
  318.      disables automatic short-circuiting of and and or expressions, adds
  319.      "_✓f_✓r_✓e_✓d" to the list of names to avoid using in generated C code, and
  320.      defines a special translation for the Pascal program's _✓s_✓l_✓o_✓p_✓e function
  321.      using the standard C _✓a_✓t_✓a_✓n_✓2 function and a constant _✓R_✓a_✓d_✓D_✓e_✓g presumably
  322.      defined in the program.  Whitespace is generally not allowed in embedded
  323.      parameters.  The `=' sign is required for embedded parameters, though it
  324.      is optional in _✓p_✓2_✓c_✓r_✓c files.  Comments within embedded parameters are
  325.  
  326.  
  327.                                                                             5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.    P2C(1)                                                               local
  335.  
  336.  
  337.      delimited by `##'.  Numeric parameters may replace `=' with `+' or `-'
  338.      to increase or decrease the parameter; list-based parameters may use `-'
  339.      to remove a name from a list rather than adding it.  Also, the parameter
  340.      name by itself in comment braces means to restore the parameter's value
  341.      that was current before the last change:
  342.  
  343.           {VarFiles=0  ## Pass FILE *'s params by value even if VAR}
  344.           _✓s_✓o_✓m_✓e _✓d_✓e_✓c_✓l_✓a_✓r_✓a_✓t_✓i_✓o_✓n_✓s
  345.           {VarFiles    ## Back to original FILE * passing}
  346.  
  347.      causes the parameter VarFiles to have the value 0 for those few declara-
  348.      tions, without affecting the parameter's value elsewhere in the file.
  349.  
  350.      If an embedded parameter appears in an include file or in interface text
  351.      for a module, the effect of the assignment normally carries over to any
  352.      programs that included that file.  If the parameter name is preceded by
  353.      a `*', then the assignment is automatically undone after the source file
  354.      that contains it ends:
  355.  
  356.           {IncludeFrom strings=<p2c/strings.h>}
  357.           {*ExportSymbol=pascal_%s}
  358.           module strings;
  359.  
  360.      will record the location of the _✓s_✓t_✓r_✓i_✓n_✓g_✓s module's include file for the
  361.      rest of the translation, but the assignment of ExportSymbol pertains
  362.      only to the module itself.
  363.  
  364.      For the complete list of _✓p_✓2_✓c_✓r_✓c parameters, run _✓p_✓2_✓c with the -i option.
  365.      Here are some additional comments on selected parameters:
  366.  
  367.      ImportAll      Because Turbo Pascal only allows one unit per source
  368.                     file, _✓p_✓2_✓c normally stops reading past the word _✓i_✓m_✓p_✓l_✓e_✓m_✓e_✓n_✓-
  369.                     _✓t_✓a_✓t_✓i_✓o_✓n in a file being scanned for interface text.  But
  370.                     HP Pascal allows several modules per file and so this
  371.                     would not be safe to do.  The ImportAll option lets you
  372.                     override the default behavior for your Pascal dialect.
  373.  
  374.      AnsiC          This parameter selects which dialect of C to use.  If 1,
  375.                     all conventions of ANSI C such as prototypes, void *
  376.                     pointers, etc. are used.  If 0, only strict K&R (first
  377.                     edition) C is used.  The default is to use "traditional
  378.                     UNIX C," which includes enum and void but not void * or
  379.                     prototypes.  Once again there are a number of other
  380.                     parameters which may be used to control the individual
  381.                     features if just setting AnsiC is not enough.
  382.  
  383.      C++            At present _✓p_✓2_✓c does not use much of C++ at all.  The
  384.                     default action is to generate code that will compile in
  385.                     either language.
  386.  
  387.      UseVExtern     Many non-UNIX linkers prohibit variables from being
  388.                     defined (not declared) by more than one source file.  One
  389.                     module must declare, e.g., "int foo;", and all others
  390.                     must declare "extern int foo;".  _✓P_✓2_✓c accomplishes this by
  391.  
  392.  
  393.    6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.    local                                                               P2C(1)
  401.  
  402.  
  403.                     declaring public variables "vextern" in header files, and
  404.                     arranging for the macro vextern to expand to extern or to
  405.                     nothing when appropriate.  If you set UseVExtern=0 _✓p_✓2_✓c
  406.                     will instead declare variables in a simpler way that
  407.                     works only on UNIX-style linkers.
  408.  
  409.      UseAnyptrMacros
  410.                     Certain C reserved words have meanings which may vary
  411.                     from one C implementation to another.  _✓P_✓2_✓c uses special
  412.                     capitalized names for these words; these names are
  413.                     defined as macros in the file _✓p_✓2_✓c._✓h which all translated
  414.                     programs include.  You can set UseAnyptrMacros=0 to dis-
  415.                     able the use of these macros.  Note that the functions of
  416.                     many of these macros can also be had directly using other
  417.                     parameters; for example, UseConsts allows you to specify
  418.                     whether your target language recognizes the word const in
  419.                     constant declarations.  The default is to use the Const
  420.                     macro instead, so that your code will be portable to
  421.                     either kind of implementation.
  422.  
  423.                     Signed expands to the reserved word signed if that word
  424.                     is available, otherwise it is given a null definition.
  425.                     Similarly, Const expands to const if that feature is
  426.                     available.  The words Volatile and Register are also
  427.                     defined in _✓p_✓2_✓c._✓h, although _✓p_✓2_✓c does not use them at
  428.                     present.  The word Char expands to char by default, but
  429.                     might need to be redefined to signed char or unsigned
  430.                     char in a particular implementation.  This is used for
  431.                     the Pascal character type; lowercase char is used when
  432.                     the desired meaning is "byte," not "character."
  433.  
  434.                     The word Static always expands to static by default.
  435.                     This is used in situations where a function or variable
  436.                     is declared static to make it local to the source file;
  437.                     lowercase static is used for static local variables.
  438.                     Thus you can redefine Static to be null if you want to
  439.                     force private names to be public for purposes of debug-
  440.                     ging.
  441.  
  442.                     The word Void expands to void in all cases; it is used
  443.                     when declaring a function with no return value.  The word
  444.                     Anyptr is a typedef for void * or char * as necessary; it
  445.                     represents a generic pointer.
  446.  
  447.      UsePPMacros    The _✓p_✓2_✓c._✓h header also declares two macros for function
  448.                     prototyping, PP(x) and PV().  These macros are used as
  449.                     follows:
  450.  
  451.                          Void foo  PP( (int x, int y, Char *z) );
  452.                          Char *bar PV( );
  453.  
  454.                     If prototypes are available, these macros will expand to
  455.  
  456.                          Void foo  (int x, int y, Char *z);
  457.  
  458.  
  459.                                                                             7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.    P2C(1)                                                               local
  467.  
  468.  
  469.                          Char *bar (void);
  470.  
  471.                     but if only old-style declarations are supported, you
  472.                     instead get
  473.  
  474.                          Void foo  ();
  475.                          Char *bar ();
  476.  
  477.                     By default, _✓p_✓2_✓c uses these macros for all function
  478.                     declarations, but function _✓d_✓e_✓f_✓i_✓n_✓i_✓t_✓i_✓o_✓n_✓s are written in
  479.                     old-style C.  The UsePPMacros parameter can be set to 0
  480.                     to disable all use of PP and PV, or it can be set to 1 to
  481.                     use the macros even when defining a function.  (This is
  482.                     accomplished by preceding each old-style definition with
  483.                     a PP-style declaration.)  If you know your code will
  484.                     always be compiled on systems that support prototyping,
  485.                     it is prettier to set Prototypes=1 or simply AnsiC=1 to
  486.                     get true function prototypes.
  487.  
  488.      EatNotes       Notes and warning messages containing any of these
  489.                     strings as sub-strings are not omitted.  Each type of
  490.                     message includes an identifier like [145]; you can add
  491.                     this identifier to the EatNotes list to suppress that
  492.                     message.  Another useful form is to use a variable name
  493.                     or other identifier to suppress warnings about that vari-
  494.                     able.  The strings are a space-separated list, and thus
  495.                     may not contain embedded spaces.  To suppress notes
  496.                     around a section of code, use, e.g., {_✓E_✓a_✓t_✓N_✓o_✓t_✓e_✓s+[_✓1_✓4_✓5]} and
  497.                     {_✓E_✓a_✓t_✓N_✓o_✓t_✓e_✓s-[_✓1_✓4_✓5]}. Most notes are generated during pars-
  498.                     ing, but to suppress those generated during output the
  499.                     string may need to remain in the list far beyond the
  500.                     point where it appears to be generated.  Use the string
  501.                     "1" or "0" to disable or enable all notes, respectively.
  502.  
  503.      ExpandIncludes The default action is to expand Pascal include files in-
  504.                     line.  This may not be desirable if include files are
  505.                     being used to simulate modules.  With ExpandIncludes=0,
  506.                     _✓p_✓2_✓c attempts to convert include files containing only
  507.                     whole procedures and global declarations into analogous C
  508.                     include files.  This may not always work, though; if you
  509.                     get error messages, don't use this option.  By combining
  510.                     this option with StaticFunctions=0, then doing some
  511.                     fairly minor editing on the result, you can convert a
  512.                     pseudo-modular Pascal program into a truly modular col-
  513.                     lection of C source files.
  514.  
  515.      ElimDeadCode   Some transformations that _✓p_✓2_✓c does on the program may
  516.                     result in unreachable or "dead" code.  By default _✓p_✓2_✓c
  517.                     removes such code, but sometimes it removes more than it
  518.                     should.  If you have "if false" segments which you wish
  519.                     to retain in C, you may have to set ElimDeadCode=0.
  520.  
  521.      SkipIndices    Normally Pascal arrays not based at zero are "shifted"
  522.                     down for C, preserving the total size of the array.  A
  523.  
  524.  
  525.    8
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.    local                                                               P2C(1)
  533.  
  534.  
  535.                     Pascal array a[2..10] is translated to a C array a[9]
  536.                     with references like "a[i]" changed to "a[i-2]" every-
  537.                     where.  If SkipIndices is set to a value of 2 or higher,
  538.                     this array would instead be translated to a[11] with the
  539.                     first two elements never used.  This arrangement may gen-
  540.                     erate incorrect code, though, for tricky source programs.
  541.  
  542.      FoldConstants  Pascal non-structured constants generally translate to
  543.                     #define's in C.  Set this to 1 to have constants instan-
  544.                     tiated directly into the code.  This may be turned on or
  545.                     off around specific constant declarations.  Set this to 0
  546.                     to force _✓p_✓2_✓c to make absolutely no assumptions about the
  547.                     constant's value in generated code, so that you can
  548.                     change the constant later in the C code without invali-
  549.                     dating the translation.  The default is to allow _✓p_✓2_✓c to
  550.                     take advantage of its knowledge of a constant's value,
  551.                     such as by generating code that assumes the constant is
  552.                     positive.
  553.  
  554.      CharConsts     This governs whether single-character string literals in
  555.                     Pascal const declarations should be interpreted as char-
  556.                     acters or strings.  In other words, _✓c_✓o_✓n_✓s_✓t _✓a='_✓x'; will
  557.                     translate to #_✓d_✓e_✓f_✓i_✓n_✓e _✓a '_✓x' if CharConsts=1 (the default),
  558.                     or to #_✓d_✓e_✓f_✓i_✓n_✓e _✓a _✓x if CharConsts=0.  Note that if _✓p_✓2_✓c
  559.                     guesses wrong, the generated code will not be wrong, just
  560.                     uglier.  For example, if _✓a is written as a character con-
  561.                     stant but it turns out to be used as a string, _✓p_✓2_✓c will
  562.                     have to write char-to-string conversion code each time
  563.                     the constant is used.
  564.  
  565.      VarStrings     In HP Pascal, a parameter of the form "var s : string"
  566.                     will match a string variable of any size; a hidden size
  567.                     parameter is passed which may be accessed by the Pascal
  568.                     _✓s_✓t_✓r_✓m_✓a_✓x function.  You can prevent _✓p_✓2_✓c from creating a
  569.                     hidden size parameter by setting VarString=0.  (Note that
  570.                     each function uses the value of VarStrings as of the
  571.                     _✓f_✓i_✓r_✓s_✓t declaration of the function that is parsed, which
  572.                     is often in the interface section of a module.)
  573.  
  574.      Prototypes     Control whether ANSI C function prototypes are used.
  575.                     Default is according to AnsiC.  This also controls
  576.                     whether to include parameter names or just their types in
  577.                     situations where names are optional.  The FullPrototyping
  578.                     parameter allows prototypes to be generated for declara-
  579.                     tions but not for definitions (older versions of
  580.                     Lightspeed C required this).  If you use a mixture of
  581.                     prototypes and old-style definitions, types like short
  582.                     and float will be promoted to int and double as required
  583.                     by the ANSI standard, unless PromoteArgs is used to over-
  584.                     ride this.  The CastArgs parameter controls whether
  585.                     type-casts are used in function arguments; by default
  586.                     they are used only if prototypes are not available.
  587.  
  588.      StaticLinks    HP Pascal and Turbo Pascal each include the concept of
  589.  
  590.  
  591.                                                                             9
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.    P2C(1)                                                               local
  599.  
  600.  
  601.                     procedure or function pointers, though with somewhat dif-
  602.                     ferent syntaxes.  _✓P_✓2_✓c recognizes both notational styles.
  603.                     Another difference is that HP's procedure pointers can
  604.                     point to nested procedures, while Turbo's can point only
  605.                     to global procedures.  In HP Pascal a procedure pointer
  606.                     must be stored as a struct containing both a pure C func-
  607.                     tion pointer and a "static link," a pointer to the parent
  608.                     procedure's locals.  (The static link is NULL for global
  609.                     procedures.)  This notation can be forced by setting Sta-
  610.                     ticLinks=1.  In Turbo, the default (StaticLinks=0) is to
  611.                     use plain C function pointers with no static links.  A
  612.                     third option (StaticLinks=2) uses structures with static
  613.                     links, but assumes the links are always NULL when calling
  614.                     through a pointer (if you need compatibility with the HP
  615.                     format but know your procedures are global).
  616.  
  617.      SmallSetConst  Pascal sets are translated into one of two formats,
  618.                     depending on the size of the set.  If all elements have
  619.                     ordinal values in the range 0..31, the set is translated
  620.                     as a single integer variable using bit operations.  (The
  621.                     SetBits parameter may be used to change the upper limit
  622.                     of 31.) The SmallSetConst parameter controls whether
  623.                     these small-sets are used, and, if so, how constant sets
  624.                     should be represented in C.   For larger sets, an array
  625.                     of long is used.  The _✓s[0] element contains the number of
  626.                     succeeding array elements which are in use.  Set elements
  627.                     in the range 0..31 are stored in the _✓s[1] array element,
  628.                     and so on.  Sets are normalized so that _✓s[_✓s[0]] is
  629.                     nonzero for any nonempty set.  The standard run-time
  630.                     library includes all the necessary procedures for operat-
  631.                     ing on sets.
  632.  
  633.      ReturnValueName
  634.                     This is one of many "naming conventions" parameters.
  635.                     Most of these take the form of a _✓p_✓r_✓i_✓n_✓t_✓f-like string con-
  636.                     taining a %_✓s where the relevant information should go.
  637.                     In the case of ReturnValueName, the %_✓s refers to a func-
  638.                     tion name and the resulting string gives the name of the
  639.                     variable to use to hold the function's return value.
  640.                     Such a variable will be made if a function contains
  641.                     assignments to its return value buried within the body,
  642.                     so that _✓r_✓e_✓t_✓u_✓r_✓n statements cannot conveniently be used.
  643.                     Some parameters (ReturnValueName included) do not require
  644.                     the %_✓s to be present in the format string; for example,
  645.                     the standard _✓p_✓2_✓c_✓r_✓c file stores every function's return
  646.                     value in a variable called _✓R_✓e_✓s_✓u_✓l_✓t.
  647.  
  648.      AlternateName  _✓P_✓2_✓c normally translates Pascal names into C names verba-
  649.                     tim, but occasionally this is not possible.  A Pascal
  650.                     name may be a C reserved word or traditional C name like
  651.                     _✓p_✓u_✓t_✓c, or there may be several like-named things that are
  652.                     hidden from each other by Pascal's scoping rules but must
  653.                     be global in C.  In these situations _✓p_✓2_✓c uses the parame-
  654.                     ter AlternateName1 to generate an alternative name for
  655.  
  656.  
  657.    10
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.    local                                                               P2C(1)
  665.  
  666.  
  667.                     the symbol.  The default is to add an underscore to the
  668.                     name.  There is also an AlternateName2 parameter for a
  669.                     second alternate name, and an AlternateName parameter for
  670.                     the _✓nth alternate name.  (The value for this parameter
  671.                     should include both a %_✓s and a %_✓d, in either order.)  If
  672.                     these latter parameters are not defined, _✓p_✓2_✓c applies
  673.                     AlternateName1 many times over.
  674.  
  675.      ExportSymbol   Symbols in the interface section for a Pascal module are
  676.                     formatted according to the value of ExportSymbol, if any.
  677.                     It is not uncommon to use _✓m_✓o_✓d_✓u_✓l_✓e_✓n_✓a_✓m_✓e_%_✓s for this symbol;
  678.                     the default is %_✓s, i.e., no special treatment for
  679.                     exported symbols.  If you also define the Export_Symbol
  680.                     parameter, that format is used instead for exported sym-
  681.                     bols which contain an underscore character.  If %_✓S (with
  682.                     a capital "S") appears in the format string it stands for
  683.                     the current module name.
  684.  
  685.      Alias          If the value of this parameter contains a %_✓s, it is a
  686.                     format string applied to the names of external functions
  687.                     or variables.  If the value does not contain a %_✓s, it
  688.                     becomes the name of the next external symbol which is
  689.                     declared (after which the parameter is cleared).
  690.  
  691.      Synonym        This creates a synonym for another Pascal symbol or key-
  692.                     word.  The format is
  693.  
  694.                          Synonym _✓o_✓l_✓d-_✓n_✓a_✓m_✓e = _✓n_✓e_✓w-_✓n_✓a_✓m_✓e
  695.  
  696.                     All occurrences of _✓o_✓l_✓d-_✓n_✓a_✓m_✓e in the input text are treated
  697.                     as if they were _✓n_✓e_✓w-_✓n_✓a_✓m_✓e by the parser.  If _✓n_✓e_✓w-_✓n_✓a_✓m_✓e is a
  698.                     keyword, _✓o_✓l_✓d-_✓n_✓a_✓m_✓e will be an equivalent keyword.  If
  699.                     _✓n_✓e_✓w-_✓n_✓a_✓m_✓e is the name of a predefined function, _✓o_✓l_✓d-_✓n_✓a_✓m_✓e
  700.                     will behave in the same way as that function, and so on.
  701.                     If _✓n_✓e_✓w-_✓n_✓a_✓m_✓e is omitted, then occurrences of _✓o_✓l_✓d-_✓n_✓a_✓m_✓e are
  702.                     entirely ignored in the input file.  Synonyms allow you
  703.                     to skip over a keyword in your dialect of Pascal that is
  704.                     not understood by _✓p_✓2_✓c, or to simulate a keyword or prede-
  705.                     fined identifier of your dialect with a similar one that
  706.                     _✓p_✓2_✓c recognizes.  Note that all predefined functions are
  707.                     available at all times; if you have a library routine
  708.                     that behaves like, e.g., Turbo Pascal's _✓g_✓e_✓t_✓m_✓e_✓m procedure,
  709.                     you can make your routine a synonym for _✓g_✓e_✓t_✓m_✓e_✓m even if
  710.                     you are not translating in Turbo mode.
  711.  
  712.      NameOf         This defines the name to use in C for a specific symbol.
  713.                     It must appear before the symbol is declared in the Pas-
  714.                     cal code; it is usually placed in the local _✓p_✓2_✓c_✓r_✓c file
  715.                     for the project.  The format is
  716.  
  717.                          NameOf _✓p_✓a_✓s_✓c_✓a_✓l-_✓n_✓a_✓m_✓e = _✓C-_✓n_✓a_✓m_✓e
  718.  
  719.                     By default, Pascal names map directly onto C names with
  720.                     no change (except for the various kinds of formatting
  721.  
  722.  
  723.                                                                            11
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.    P2C(1)                                                               local
  731.  
  732.  
  733.                     outlined above).  If the _✓p_✓a_✓s_✓c_✓a_✓l-_✓n_✓a_✓m_✓e is of the form
  734.                     _✓m_✓o_✓d_✓u_✓l_✓e._✓n_✓a_✓m_✓e or _✓p_✓r_✓o_✓c_✓e_✓d_✓u_✓r_✓e._✓n_✓a_✓m_✓e then the command applies
  735.                     only to the instance of the Pascal name that is global to
  736.                     that module, or local to that procedure.  Otherwise, it
  737.                     applies to all usages of the name.
  738.  
  739.      VarMacro       This is analogous to NameOf, but specifically for use
  740.                     with Pascal variables.  The righthand side can be most
  741.                     any C expression; all references to the variable are
  742.                     expanded into that C expression.  Names used in the C
  743.                     expression are taken verbatim.  There is also a Const-
  744.                     Macro parameter for translating constants as arbitrary
  745.                     expressions.  Note that the variable on the lefthand side
  746.                     must actually be declared in the program or in a module
  747.                     that it uses.  The declaration for the variable will be
  748.                     omitted from the generated code unless the Pascal-name
  749.                     appears in the expression:  If you ask to replace _✓i with
  750.                     _✓i+_✓1, the variable _✓i will still be declared but its value
  751.                     will be shifted accordingly.  Note that if _✓i appears on
  752.                     the lefthand side of an assignment, _✓p_✓2_✓c will use algebra
  753.                     to "solve" for _✓i.
  754.  
  755.                     In all cases where _✓p_✓2_✓c parses C expressions, all C opera-
  756.                     tors are recognized except compound assignments like
  757.                     `+='.  (Increment and decrement operators are allowed.)
  758.                     All variable and function names are assumed to have
  759.                     integer type, even if they are names that occur in the
  760.                     actual program.  A type-specification operator `::' has
  761.                     been introduced; it has the same precedence as `.' or `-
  762.                     >' but the righthand side must be a Pascal type identif-
  763.                     ier (built-in or defined by your program previously to
  764.                     when the macro definition was parsed), or an arbitrary
  765.                     Pascal type expression in parentheses.  The lefthand
  766.                     argument is then considered to have the specified type.
  767.                     This may be necessary if your macro is used in situations
  768.                     where the exact type of the expression must be known
  769.                     (say, as the argument to a _✓w_✓r_✓i_✓t_✓e_✓l_✓n).
  770.  
  771.      FieldMacro     Here the lefthand side must have the form _✓r_✓e_✓c_✓o_✓r_✓d._✓f_✓i_✓e_✓l_✓d,
  772.                     where _✓r_✓e_✓c_✓o_✓r_✓d is the Pascal type or variable name for a
  773.                     record, and _✓f_✓i_✓e_✓l_✓d is a field in that record.  The right-
  774.                     hand side must be a C expression generally including the
  775.                     name _✓r_✓e_✓c_✓o_✓r_✓d. All instances of that name are replaced by
  776.                     the actual record being "dotted." For example,
  777.  
  778.                          FieldMacro Rect.topLeft = topLeft(Rect)
  779.  
  780.                     translates _✓a[_✓i]._✓t_✓o_✓p_✓L_✓e_✓f_✓t into _✓t_✓o_✓p_✓L_✓e_✓f_✓t(_✓a[_✓i]), where _✓a is an
  781.                     array of _✓R_✓e_✓c_✓t.
  782.  
  783.      FuncMacro      The lefthand side must be any Pascal function or pro-
  784.                     cedure name plus a parameter list.  The number of parame-
  785.                     ters must match the number in the function's uses and
  786.                     declaration.  Calls to the function are replaced by the C
  787.  
  788.  
  789.    12
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.    local                                                               P2C(1)
  797.  
  798.  
  799.                     expression on the righthand side.  For example,
  800.  
  801.                          FuncMacro PtInRect(p,r) = PtInRect(p,&r)
  802.  
  803.                     causes the second argument of _✓P_✓t_✓I_✓n_✓R_✓e_✓c_✓t to be passed by
  804.                     reference, even though the declaration says it's not.  If
  805.                     the function in question is actually defined in the pro-
  806.                     gram or module being translated, the FuncMacro will not
  807.                     affect the definition but it will affect all calls to the
  808.                     function elsewhere in the module.  FuncMacros can also be
  809.                     applied to predefined or never-defined functions.
  810.  
  811.      IncludeFrom    This specifies that a given module's header should be
  812.                     included from a given place.  The second argument may be
  813.                     surrounded by " " or < > as necessary; if the second
  814.                     argument is omitted, no include directive will be gen-
  815.                     erated for the module.
  816.  
  817.      ImportFrom     This specifies that a given module's Pascal interface
  818.                     text can be found in the given file.  The named file
  819.                     should be either the source file for the module, or a
  820.                     specially prepared file with the implementation section
  821.                     removed for speed.  If no ImportFrom entry is found for a
  822.                     module, the path defined by the ImportDir list is
  823.                     searched.  Each entry in the path may contain a %_✓s, which
  824.                     expands to the name of the module.  The default path
  825.                     looks for %_✓s._✓p_✓a_✓s and %_✓s._✓t_✓e_✓x_✓t in the current directory,
  826.                     then for /_✓t_✓m_✓p/_✓q_✓q/_✓h_✓o_✓m_✓e/%_✓s._✓i_✓m_✓p. (where /tmp/qq/home is the
  827.                     _✓p_✓2_✓c home directory.)
  828.  
  829.      StructFunction This parameter is a list of functions which follow the
  830.                     _✓p_✓2_✓c semantics for structure-valued functions (functions
  831.                     returning arrays, sets, and strings, and structs in prim-
  832.                     itive C dialects).  For these functions, a pointer to a
  833.                     return-value area is passed to the function as a special
  834.                     first parameter.  The function stores the result in this
  835.                     area, then returns a copy of the pointer.  (The standard
  836.                     C function _✓s_✓t_✓r_✓c_✓p_✓y is an example of this concept.  _✓S_✓p_✓r_✓i_✓n_✓t_✓f
  837.                     also behaves this way in some dialects; it always appears
  838.                     on the StructFunction list regardless of the type of
  839.                     implementation.)  The system configuration file includes
  840.                     a list of common structured functions so that _✓p_✓2_✓c's
  841.                     optimizer will know how to manipulate them.
  842.  
  843.      StrlapFunction Functions on this list are structured functions as above,
  844.                     but with the ability to work in-place; that is, the same
  845.                     pointer may be passed as both the return value area and a
  846.                     regular parameter.
  847.  
  848.      Deterministic  Functions on this list have no side effects or side
  849.                     dependencies.  An example is the _✓s_✓i_✓n function in the
  850.                     standard math library; two calls with the same parameter
  851.                     values produce the same result, and have no effects other
  852.                     than returning a value.  _✓P_✓2_✓c can make use of this
  853.  
  854.  
  855.                                                                            13
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.    P2C(1)                                                               local
  863.  
  864.  
  865.                     knowledge when optimizing code for efficiency or reada-
  866.                     bility.  Functions on this list are also assumed to be
  867.                     relatively fast, so that it is acceptable to duplicate a
  868.                     call to the function.
  869.  
  870.      LeaveAlone     Functions on this list are not subjected to the normal
  871.                     built-in translation rules that _✓p_✓2_✓c would otherwise use.
  872.                     For example, adding _✓w_✓r_✓i_✓t_✓e_✓l_✓n to this list would translate
  873.                     _✓w_✓r_✓i_✓t_✓e_✓l_✓n statements blindly into calls to a C _✓w_✓r_✓i_✓t_✓e_✓l_✓n()
  874.                     function, rather than being translated into equivalent
  875.                     _✓p_✓r_✓i_✓n_✓t_✓f calls.  The built-in translation is also
  876.                     suppressed if the function has a FuncMacro.
  877.  
  878.      BufferedFile   _✓P_✓2_✓c normally assumes binary files will use _✓r_✓e_✓a_✓d/_✓w_✓r_✓i_✓t_✓e,
  879.                     not _✓g_✓e_✓t/_✓p_✓u_✓t/^ notation.  A file buffer variable will only
  880.                     be created for a file if buffer notation is used for it.
  881.                     For global file variables this may be detected too late
  882.                     (a declaration without buffers may already have been
  883.                     written).  Such files can be listed in BufferedFile to
  884.                     force _✓p_✓2_✓c to allocate buffers for them; do this if you
  885.                     get a warning message that says it is necessary.  Set
  886.                     BufferedFile=1 to buffer all files, in which case UnBuf-
  887.                     feredFile allows you to force certain files _✓n_✓o_✓t to have
  888.                     buffers.
  889.  
  890.      StructFiles    If _✓p_✓2_✓c still can't translate your file operations
  891.                     correctly, you can set StructFiles=1 to cause Pascal
  892.                     files to translate into structs which include the usual C
  893.                     _✓F_✓I_✓L_✓E pointer, as well as file buffer and file name
  894.                     fields.  While the resulting code doesn't look as much
  895.                     like native C, the file structs will allow _✓p_✓2_✓c to do a
  896.                     correct translation in many more cases.
  897.  
  898.      CheckFileEOF   Normally only file-open operations are checked for
  899.                     errors.  Additional error checking, such as read-past-
  900.                     end-of-file, can be enabled with parameters like Check-
  901.                     FileEOF.  These checks can make the code very ugly!  If
  902.                     I/O checking is enabled by the program ($iocheck on$ in
  903.                     HP Pascal; {$I+} in Turbo; this is always the default
  904.                     state), these checks will generate fatal errors unless
  905.                     enclosed in an HP Pascal try-recover construct.  If I/O
  906.                     checking is disabled, these will cause the global vari-
  907.                     able _✓P__✓i_✓o_✓r_✓e_✓s_✓u_✓l_✓t to be set zero or nonzero according to
  908.                     the outcome.  The default for most of these options is to
  909.                     check only when I/O checking is disabled.
  910.  
  911.    ISSUES
  912.      Integer size. _✓P_✓2_✓c normally generates code to work with either 16 or 32
  913.      bit ints.  If you know your C integers will be 16 or 32 bits, set
  914.      IntSize appropriately.  In particular setting IntSize=32 will generate
  915.      much cleaner code: _✓p_✓2_✓c no longer must carefully cast function arguments
  916.      between int and long.  These casts also will be unnecessary if ANSI pro-
  917.      totypes are available.  To disable int/long casting because you know at
  918.      least one of these cases will hold, set CastLongArgs=0.  (The CastArgs
  919.  
  920.  
  921.    14
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.    local                                                               P2C(1)
  929.  
  930.  
  931.      parameter similarly controls other types of casts, such as between ints
  932.      and doubles.) The Integer16 parameter controls whether Pascal integers
  933.      are interpreted as 16 or 32 bits, or translated as native C integers.
  934.      The default value depends on the Language selected.
  935.  
  936.      Signed/unsigned chars. Pascal characters are normally "weakly" inter-
  937.      preted as unsigned; this is controlled by UnsignedChar.  The default is
  938.      "either," so that C's native char type may be used even if its signed-
  939.      ness is unknown.  Code that uses characters outside of the range 0-127
  940.      may need a different setting.  Alternatively, you can use the types
  941.      {SIGNED} char and {UNSIGNED} char in the few cases where it really
  942.      matters.  These comments are controlled by the SignedComment and Unsig-
  943.      nedComment parameters.  (The type {UNSIGNED} integer is also recog-
  944.      nized.)  The SignedChar parameter tells whether C characters are signed
  945.      or unsigned (default is "unknown").  The HasSignedChar parameter tells
  946.      whether the phrase "signed char" is legal in the output.  If it is not,
  947.      _✓p_✓2_✓c may have to translate Pascal signed bytes into C shorts.
  948.  
  949.      Special types. _✓P_✓2_✓c understands the following predefined Pascal type
  950.      names: integer, signed integers depending on Integer16; longint, signed
  951.      32-bit integers; unsigned, unsigned 32-bit integers; sword, signed 16-
  952.      bit integers; word, unsigned 16-bit integers; c_int, signed native C
  953.      integers; c_uint, unsigned native C integers; sbyte, signed 8-bit
  954.      integers; byte, unsigned 8-bit integers; real, floating-point numbers
  955.      depending on DoubleReals; single, single-precision floats; longreal,
  956.      double, and extended, double-precision floats; pointer and anyptr, gen-
  957.      eric pointers (assignment-compatible with any pointer type); string,
  958.      generic string of length StringDefault (normally 255); also, the usual
  959.      Pascal types char, boolean, and text.  (If your Pascal uses different
  960.      names for these concepts, the Synonym option will come in handy.)
  961.  
  962.      Embedded code. It is possible to write a Pascal comment containing C
  963.      code to be embedded into the output.  See the descriptions of EmbedCom-
  964.      ment and its relatives in the system _✓p_✓2_✓c_✓r_✓c file.  These techniques are
  965.      helpful if you plan to do repeated translations of code that is still
  966.      being maintained in Pascal.
  967.  
  968.      Comments and blank lines. _✓P_✓2_✓c collects the comments in a procedure into
  969.      a list.  All comments and statements are stamped with serial numbers
  970.      which are used to reattach comments to statements even after code has
  971.      been added, removed, or rearranged during translation.  "Orphan" com-
  972.      ments attached to statements that have been lost are attached to nearby
  973.      statements or emitted at the end of the procedure.  Blank lines are
  974.      treated as a kind of comment, so _✓p_✓2_✓c will also reproduce your usage of
  975.      blank lines.  If the comment mechanism goes awry, you can disable com-
  976.      ments with EatComments or disable their being attached to code with
  977.      SpitComments.
  978.  
  979.      Indentation. _✓P_✓2_✓c has a number of parameters to govern indentation of
  980.      code.  The default values produce the GNU Emacs standard indentation
  981.      style, although _✓p_✓2_✓c can do a better job since it knows more about the
  982.      code it is indenting.  Indentation works by applying "indentation del-
  983.      tas," which are either absolute numbers (which override the previous
  984.      indentation), or signed relative numbers (which augment the previous
  985.  
  986.  
  987.                                                                            15
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.    P2C(1)                                                               local
  995.  
  996.  
  997.      indentation).  A delta of "+0" specifies no change in indentation.  All
  998.      of the indentation options are described in the standard _✓p_✓2_✓c_✓r_✓c file.
  999.  
  1000.      Line breaking. _✓P_✓2_✓c uses an algorithm similar to the TeX typesetter's
  1001.      paragraph formatter for breaking long statements into multiple lines.  A
  1002.      "penalty" is assigned to various undesirable aspects of all possible
  1003.      line breaks; the "badness" of a set of line breaks is approximately the
  1004.      sum of all the penalties.  Chief among these are serious penalties for
  1005.      overrunning the desired maximum line length (default 78 columns), an
  1006.      infinite penalty for overrunning the absolute maximum line length
  1007.      (default 90), and progressively greater penalties for breaking at opera-
  1008.      tors deeply nested in expressions.  Parameters such as OpBreakPenalty
  1009.      control the relative weights of various choices.  BreakArith and its
  1010.      neighbors control whether the operator at a line break should be placed
  1011.      at the end of the previous line or at the beginning of the next.  If you
  1012.      don't want any oversize lines, define MaxLineWidth=78.
  1013.  
  1014.      Unlike TeX, _✓p_✓2_✓c's line breaker must actually try all possible sets of
  1015.      break points.  To avoid excessive computation, the total penalty contri-
  1016.      buted at each decision point must sum to a nonnegative value; negative
  1017.      values are clipped up to zero.  This allows _✓p_✓2_✓c to prune away obviously
  1018.      undesirable alternatives in advance.  The MaxLineBreakTries parameter
  1019.      (default 5000) controls how many alternatives to try before giving up
  1020.      and using the best so far.
  1021.  
  1022.      PASCAL_MAIN. _✓P_✓2_✓c generates a call to this function at the front of the
  1023.      main program.  In the (unmodified) run-time library all this does is
  1024.      save argc and argv away because in both HP and Turbo these are accessed
  1025.      as global variables.  If you do not wish to use this feature, define
  1026.      ArgCName to be _✓a_✓r_✓g_✓c, ArgVName to be _✓a_✓r_✓g_✓v, and MainName (normally
  1027.      "PASCAL_MAIN") to be blank.  This will work if argc and argv are never
  1028.      accessed outside of your main program.
  1029.  
  1030.    BUGS
  1031.      _✓P_✓2_✓c was designed with the idea that clean, readable output in most cases
  1032.      is worth more than guaranteed correct output in extreme cases.  _✓P_✓2_✓c is
  1033.      _✓n_✓o_✓t a compiler!  However, ideally the "extreme" cases would include only
  1034.      those which never arise in real life.  Thus if _✓p_✓2_✓c actually generates
  1035.      incorrect code I will consider it a bug, but I will not apologize for
  1036.      it. :-)  Below are the major remaining cases where this is known to
  1037.      occur.
  1038.  
  1039.      Certain kinds of conformant array parameters (including multi-
  1040.      dimensional conformant arrays) produce code that declares variable-
  1041.      length arrays in C.  Only a few C compilers, such as the GNU C compiler,
  1042.      support this language extension.  Otherwise some hand re-coding will be
  1043.      required.
  1044.  
  1045.      HP Pascal try-recover structures are translated into calls to _✓T_✓R_✓Y and
  1046.      _✓R_✓E_✓C_✓O_✓V_✓E_✓R macros, which are defined to simulate the construct using _✓s_✓e_✓t_✓j_✓m_✓p
  1047.      and _✓l_✓o_✓n_✓g_✓j_✓m_✓p. If this emulation does not work, define the symbol FAKE_TRY
  1048.      to cause these macros to become "inert."  (In cases where the error is
  1049.      detected by code physically within the body of the try statement, a C
  1050.      goto to the recover section is always generated.)  Also, local file
  1051.  
  1052.  
  1053.    16
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.    local                                                               P2C(1)
  1061.  
  1062.  
  1063.      variables in scopes which are destroyed by an escape are not closed.
  1064.  
  1065.      Non-local GOTO's and try-recover statements are each implemented, but
  1066.      may conflict if both are used at once.  Non-local GOTO's are fairly
  1067.      careful about closing files that go out of scope but may fail to do so
  1068.      in the presence of recursion.
  1069.  
  1070.      Arrays containing files are not initialized to NULL as other files are.
  1071.      In some cases, such as file variables allocated by NEW, the file is ini-
  1072.      tialized but not automatically closed by DISPOSE.
  1073.  
  1074.      LINK variables allowing sub-procedures access to their parents' vari-
  1075.      ables are occasionally omitted by mistake, if the access is too indirect
  1076.      for _✓p_✓2_✓c to notice.  If this happens, you can add an explicit reference
  1077.      to a parent variable in the sub-procedure.  A statement of the form
  1078.      "a:=a" will count as a reference but then be optimized away by _✓p_✓2_✓c.
  1079.  
  1080.      Many aspects of Modula-2 are translated only superficially.  For exam-
  1081.      ple, the type-compatibility properties of the _✓W_✓O_✓R_✓D and _✓A_✓R_✓R_✓A_✓Y _✓O_✓F _✓W_✓O_✓R_✓D
  1082.      types are only roughly modelled, as are the scope rules concerning
  1083.      modules.
  1084.  
  1085.      Parts of VAX Pascal are still untreated.  In particular, the [_✓U_✓N_✓S_✓A_✓F_✓E]
  1086.      attribute and a few others are not fully supported, nor are the seman-
  1087.      tics of the _✓O_✓P_✓E_✓N procedure.
  1088.  
  1089.      Turbo and VAX Pascal's _✓d_✓o_✓u_✓b_✓l_✓e, _✓q_✓u_✓a_✓d_✓r_✓u_✓p_✓l_✓e, and _✓e_✓x_✓t_✓e_✓n_✓d_✓e_✓d real types all
  1090.      translate to the C double type.  Turbo's _✓c_✓o_✓m_✓p_✓u_✓t_✓a_✓t_✓i_✓o_✓n_✓a_✓l type is not sup-
  1091.      ported at all.
  1092.  
  1093.      Because Pascal strings (with length bytes) are translated into C strings
  1094.      (with null terminators), certain Pascal string tricks will not work in
  1095.      the translated code.  For example the assignment _✓s[_✓0]:=_✓c_✓h_✓r(_✓x) is
  1096.      translated to _✓s[_✓x]=_✓0 on the assumption that the string is being shor-
  1097.      tened.  If _✓x is actually greater than the current length, but not of a
  1098.      recognizable form like _✓o_✓r_✓d(_✓s[_✓0])+_✓n, then the generated code will not
  1099.      work.  In VAX Pascal this corresponds to performing arithmetic on the
  1100.      _✓L_✓E_✓N_✓G_✓T_✓H field of a varying-length string.
  1101.  
  1102.      Turbo Pascal's automatic clipping of strings is not supported.  In
  1103.      Turbo, if a ten character string is assigned to a _✓s_✓t_✓r_✓i_✓n_✓g[_✓8] variable,
  1104.      the last two characters are silently removed.  The code produced by _✓p_✓2_✓c
  1105.      generally will overrun the target string instead!  The StringTruncLimit
  1106.      parameter (80 by default if Language=Turbo) specifies a string size
  1107.      which should be considered "short"; assignments of potentially-long
  1108.      strings to short string variables will cause a warning but will not
  1109.      automatically truncate.  The cure is to use _✓c_✓o_✓p_✓y in the Pascal source to
  1110.      truncate the strings explicitly.
  1111.  
  1112.    FILES
  1113.      file._✓x_✓x_✓x               Pascal source files
  1114.      file.c                 resulting C source file
  1115.      module.h               resulting C header file
  1116.      p2crc                  local configuration file
  1117.  
  1118.  
  1119.                                                                            17
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.    P2C(1)                                                               local
  1127.  
  1128.  
  1129.      .p2crc                 alternate local configuration file
  1130.      /tmp/qq/home/p2crc     system-wide configuration file
  1131.      /tmp/qq/home/system.impdeclarations for predefined functions
  1132.      /tmp/qq/home/system.m2 analogous declarations for Modula-2
  1133.      /tmp/qq/home/*.imp     interface text for standard modules
  1134.      /tmp/qq/home/p2c/p2c.h header file for translated programs
  1135.      /tmp/qq/home/libp2c.a  run-time library
  1136.  
  1137.    AUTHOR
  1138.      Dave Gillespie, daveg@csvax.cs.caltech.edu.
  1139.  
  1140.      Many thanks to William Bader, Steven Levi, Rick Koshi, Eric Raymond,
  1141.      Magne Haveraaen, Dirk Grunwald, David Barto, Paul Fisher, Tom Schneider,
  1142.      and others whose suggestions and bug reports have helped improve _✓p_✓2_✓c in
  1143.      countless ways.
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.    18
  1186.  
  1187.