📄 p2c.cat
字号:
P2C(1) USER COMMANDS P2C(1)NAME p2c - Pascal to C translator, version 1.21alpha-07.Dec.93SYNOPSIS p2c [ options ] [ file [ module ] ]DESCRIPTION _P_2_c is a tool for translating Pascal programs into C. The input consists of a set of source files in any of the fol- lowing Pascal dialects: HP Pascal, Turbo/UCSD Pascal, DEC VAX Pascal, Oregon Software Pascal/2, Macintosh Programmer's Workshop Pascal, Sun/Berkeley Pascal, Texas Instruments Pas- cal, Apollo Domain Pascal. Modula-2 syntax is also sup- ported. Output is a set of .c and .h files that comprise an equivalent program in any of several dialects of C. Output code may be kept machine- and dialect-independent, or it may be targeted to a specific machine and compiler. Most rea- sonable Pascal programs are converted into fully functional C which will compile and run with no further modifications, although _p_2_c sometimes chooses to generate readable code at the expense of absolute generality. _P_2_c endeavors to insert notes and warning messages into the output code to point out areas which may require human intervention. Output code is arranged to be readable and efficient, and to make use of C idioms wherever possible. The main goal of the translation is to produce C files which are pleasant and "natural" enough to be acceptable as the new source files for a pro- gram. In a pinch, _p_2_c will also serve as an ad hoc Pascal compiler. The p2cc(1) script makes it easy to use _p_2_c as a compiler. Code generated by _p_2_c normally does not assume characters are signed or unsigned. Also, it assumes int is the same as either short or long but does not depend on which. However, if int is not the same as long it is best to use a modern C compiler which supports prototypes. Generated code does not require an ANSI-compatible compiler (unless ANSI-style code is requested), but it does use various ANSI-standard library routines. All generated code includes the file <_p_2_c/_p_2_c._h> which in turn includes <_s_t_d_i_o._h> and various other common resources. Also, many translated programs will need to be linked with the run-time library, typically -_l_p_2_c. Given a file name, _p_2_c reads from the specified file and outputs to a file with a .c suffix added or substituted. For example, p2c myfile.pasSun Release 4.1 Last change: local 1P2C(1) USER COMMANDS P2C(1) 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 contain a Pascal main program or a single Pascal module (or "unit" in Turbo and UCSD Pascal nomencla- ture), or it may just contain a number of procedures and declarations. _P_2_c is designed to work for correct input programs. That is, it will accept partial programs but may occasionally core dump if the input refers to undefined sym- bols. If the input is a module, the translator will also produce a file _m_o_d_u_l_e.h containing a translation of the module's interface section. The implementation section may be omit- ted in which case only the .h file will be interesting. If the program or module has include files, these may cause additional .c files to be generated depending on the value of the ExpandIncludes option (see below). If no file name is given, _p_2_c reads Pascal from the standard input and writes the resulting C to standard output (though a .h file may still be produced). If a file name and module name are given, the file may include several modules (or units). The specified module is translated; any others are skipped. The output files will be named _m_o_d_u_l_e.c and _m_o_d_u_l_e.h. _P_2_c never translates more than one module per run. Before starting, _p_2_c reads the file /_u_s_r/_l_i_b/_p_2_c/_p_2_c_r_c for a number of configuration parameters. (The actual path used on your system may vary. The -i option is a handy way to examine this file.) If the P2CRC environment variable is set, it gives the name of a file to read instead of the sys- tem file; this file can start with Include %H/p2crc to include the system file. Next, _p_2_c attempts to read the file _p_2_c_r_c in your directory for further configuration. If this file does not exist, _p_2_c looks for ._p_2_c_r_c instead.OPTIONS -o _c_f_i_l_e 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 file. A single dash (`-o -') says to write the C code to the standard output. -h _h_f_i_l_e Use _h_f_i_l_e in place of _m_o_d_u_l_e.h as the output file for interface text. This only has effect if the input is an HP Pascal module or a Turbo Pascal unit. -s _s_f_i_l_e Read interface text from _s_f_i_l_e before beginning the translation. This file typically contains one or more modules, often with implementation sections omitted for speed, which the program or module being translatedSun Release 4.1 Last change: local 2P2C(1) USER COMMANDS P2C(1) will use. (Typically the ImportFrom and ImportDir parameters in _p_2_c_r_c are set up to allow _p_2_c to locate interface text without needing any -s options.) If there are several -s options in the command, the _s_f_i_l_e_s are read from left to right. -p_n Display progress of translation in the form of a line number/file name display. This is refreshed every _n lines, 25 by default. -c _r_c_f_i_l_e Read local configuration commands from _r_c_f_i_l_e instead of _p_2_c_r_c or ._p_2_c_r_c. A dash (`-c -') in place of _r_c_f_i_l_e causes no local configuration file to be used. -v ("Vanilla.") Do not read from the system configuration file /_u_s_r/_l_i_b/_p_2_c/_p_2_c_r_c. Since some of the parameters in this file are required, your local configuration file must include those parameters instead. This also suppresses the file named by the P2CRC environment variable. -H _h_o_m_e_d_i_r Use _h_o_m_e_d_i_r instead of /_u_s_r/_l_i_b/_p_2_c as the _p_2_c home directory. The system _p_2_c_r_c file will be searched for in this directory. -I_p_a_t_t_e_r_n Add _p_a_t_t_e_r_n to the ImportDir search list of places to find modules which are imported. The pattern should include a %_s to represent the module name, and should evaluate to a potential file name for that module's source code. For example, ../%s.pas looks for _m_o_d_u_l_e_n_a_m_e.pas in the parent of the current directory. -i This special option (which must be the only argument on the command line if used) simply copies the system con- figuration file /_u_s_r/_l_i_b/_p_2_c/_p_2_c_r_c to the standard out- put in its entirety. (It may be used with -H, but -i is most useful precisely when you don't know the loca- tion of the home directory.) -q Quiet mode. Suppresses output of status messages dur- ing translation. -E_n Abort translation after _n errors. If _n is omitted it defaults to zero, which means unlimited errors are allowed. Use -E1 to make _p_2_c halt after the first error. -e Echo the Pascal source into the output file, surrounded by #ifdefs. This is the same as the CopySourceSun Release 4.1 Last change: local 3P2C(1) USER COMMANDS P2C(1) parameter in the _p_2_c_r_c file. -a Produce modern ANSI C. This is a convenient override for the AnsiC parameter in the _p_2_c_r_c file. -L _l_a_n_g_u_a_g_e Select input language name, such as VAX or TURBO. This is a convenient override for the Language parameter. -V Verbose mode. This causes _p_2_c to generate an addi- tional ".log" file with further details of the transla- tion, such as a list of warnings and notes including those which are suppressed in the regular output. -comp Compiler mode. This switch tells _p_2_c to use various configuration defaults that are more suitable for use as a Pascal compiler rather than a translator. It is the same as specifying the following options in your _p_2_c_r_c file: ElimDeadCode 0 AnalyzeFlow 0 MaxLineBreakTies 0 FoldConstants 1 FoldStrConstants 1 OffsetForLoops 0 StaticLinks 1 BitwiseMod 0 BitwiseDiv 0 AssumeBits 0 AssumeSigns 0 FormatStrings 1 StructFiles 1 FullStrWrite 1 The _p_2_c_c script specifies this option when it runs _p_2_c to compile a Pascal program. -local Local settings. This switch uses various configuration defaults that are appropriate if the code generated by _p_2_c is going to be compiled and run on the same machine that ran _p_2_c itself. -check Enable all error checking. Normally, some error checks are off by default, as described in the comments in the system _p_2_c_r_c file. -M0 Disable memory conservation. This prevents _p_2_c from freeing various data structures after translating eachSun Release 4.1 Last change: local 4P2C(1) USER COMMANDS P2C(1) function, in case this new conservation feature causes unforseen problems. -R Regression testing mode. Formats notes and warning messages in a way that makes it easier to run _d_i_f_f(1) on the output of _p_2_c. _P_2_c also understands a few debugging options which may occa- sionally be useful when tracking down translation problems. The -d_n option sets the "debug level" to _n, a small integer which is normally zero. Debugging output is written into the regular output file along with the C code; the higher your _n, the more "wallpaper" you get. Also, -t prints debugging information at every Pascal token, -B_n enables
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -