⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p2c.man

📁 把pascal程序转成C语言程序 把pascal程序转成C语言程序
💻 MAN
📖 第 1 页 / 共 4 页
字号:
.\" p2c  Copyright 1989, 1990, 1991, 1992, 1993 Free Software Foundation.TH P2C 1 "local".SH NAMEp2c \- Pascal to C translator, version 1.21alpha-07.Dec.93.SH SYNOPSIS.B p2c[ options ] [ file [ module ] ].SH DESCRIPTION.I P2cis a tool for translating Pascal programs into C.  The input consistsof a set of source files in any of the following Pascal dialects:HP Pascal, Turbo/UCSD Pascal, DEC VAX Pascal, Oregon Software Pascal/2,Macintosh Programmer's Workshop Pascal, Sun/Berkeley Pascal, TexasInstruments Pascal, Apollo Domain Pascal.Modula-2 syntax is also supported.  Output is a set of.B .cand.B .hfiles that comprise an equivalent program in any of several dialectsof C.  Output code may be kept machine- and dialect-independent, orit may be targeted to a specific machine and compiler.  Most reasonablePascal programs are converted into fully functional C which will compileand run with no further modifications, although.I p2csometimes chooses to generate readable code at the expense of absolutegenerality.  .I P2cendeavors to insert notes and warning messages into the output codeto point out areas which may require human intervention.  Output codeis arranged to be readable and efficient, and to make use of C idiomswherever possible.  The main goal of the translation is to produce Cfiles which are pleasant and "natural" enough to be acceptable as the newsource files for a program.  In a pinch,.I p2cwill also serve as an ad hoc Pascal compiler.  The.BR p2cc (1)script makes it easy to use.I p2cas a compiler..PPCode generated by.I p2cnormally does not assume characters are signed or unsigned.Also, it assumes.B intis the same as either.B shortor.B longbut does not depend on which.  However, if.B intis not the same as.BR longit 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 variousANSI-standard library routines..PPAll generated code includes the file.I <p2c/p2c.h>which in turn includes.I <stdio.h>and various other common resources.  Also, many translated programswill need to be linked with the run-time library, typically.I -lp2c..PPGiven a file name,.I p2creads from the specified file and outputs to a file with a.B .csuffix added or substituted.  For example,.IP "" 5p2c myfile.pas.PPreads from.I myfile.pasto produce the file.I myfile.c.The input file may contain a Pascal main program or asingle Pascal module (or "unit" in Turbo and UCSD Pascal nomenclature),or it may just contain a number of procedures and declarations..I P2cis designed to work for correct input programs.  That is, it will acceptpartial programs but may occasionally core dump if the input refers toundefined symbols..PPIf the input is a module, the translator will also produce a file.IB module .hcontaining a translation of the module's interface section.The implementation section may be omitted in which case only the.B .hfile will be interesting.  If the program or module has include files,these may cause additional.B .cfiles to be generated depending on the value of the.B ExpandIncludesoption (see below)..PPIf no file name is given,.I p2creads Pascal from the standard input and writes the resulting C tostandard output (though a.B .hfile may still be produced).  If a file name and module name are given,the file may include several modules (or units).  The specified moduleis translated; any others are skipped.  The output files will be named.IB module .cand.IB module .h ..I P2cnever translates more than one module per run..PPBefore starting,.I p2creads the file.I --HOMEDIR--/p2crcfor a number of configuration parameters.  (The actual path used on yoursystem may vary.  The.B \-ioption is a handy way to examine this file.)If the P2CRC environment variable is set, it gives the name of a fileto read instead of the system file; this file can start with.B Include %H/p2crcto include the system file.  Next,.I p2cattempts to read the file.I p2crcin your directory for further configuration.  If this file does notexist,.I p2clooks for.I .p2crcinstead..SH OPTIONS.TP.BI \-o "\ cfile"Use.I cfilein place of.IB file .cor.IB module .cas the primary output file.  A single dash (`\-o \-') says to write theC code to the standard output..TP.BI \-h "\ hfile"Use.I hfilein place of.IB module .has the output file for interface text.  This only has effect if theinput is an HP Pascal module or a Turbo Pascal unit..TP.BI \-s "\ sfile"Read interface text from.I sfilebefore beginning the translation.  This file typically contains one ormore modules, often with implementation sections omitted for speed, whichthe program or module being translated will use.  (Typically the.B ImportFromand.B ImportDirparameters in.I p2crcare set up to allow.I p2cto locate interface text without needing any.B \-soptions.)  If there are several.B \-soptions in the command, the.I sfilesare read from left to right..TP.BI \-p nDisplay progress of translation in the form of a line number/file namedisplay.  This is refreshed every.I nlines, 25 by default..TP.BI \-c "\ rcfile"Read local configuration commands from.I rcfileinstead of.I p2crcor.I .p2crc.A dash (`\-c \-') in place of.I rcfilecauses no local configuration file to be used..TP.B \-v("Vanilla.")  Do not read from the system configuration file.I --HOMEDIR--/p2crc.Since some of the parameters in this file are required, your localconfiguration file must include those parameters instead.  Thisalso suppresses the file named by the P2CRC environment variable..TP.BI \-H "\ homedir"Use.I homedirinstead of.I --HOMEDIR--as the.I p2chome directory.  The system.I p2crcfile will be searched for in this directory. .TP.BI \-I patternAdd.I patternto the.B ImportDirsearch list of places to find modules which are imported.  The patternshould include a.I %sto represent the module name, and should evaluate to a potential file namefor that module's source code.  For example,.B ../%s.paslooks for.IB modulename .pasin the parent of the current directory..TP.B \-iThis special option (which must be the only argument on thecommand line if used) simply copies the system configurationfile.I --HOMEDIR--/p2crcto the standard output in its entirety.  (It may be used with.BR \-H ,but.B \-iis most useful precisely when you don't know thelocation of the home directory.).TP.B \-qQuiet mode.  Suppresses output of status messages during translation..TP.BI \-E nAbort translation after.I nerrors.  If.I nis omitted it defaults to zero, which means unlimited errors are allowed.Use.B -E1to make.I p2chalt after the first error..TP.B \-eEcho the Pascal source into the output file, surrounded by #ifdefs.This is the same as the.B CopySourceparameter in the.I p2crcfile..TP.B \-aProduce modern ANSI C.  This is a convenient override for the.B AnsiCparameter in the.I p2crcfile..TP.BI \-L "\ language"Select input language name, such as VAX or TURBO.  This is a convenientoverride for the.B Languageparameter..TP.B \-VVerbose mode.  This causes.I p2cto generate an additional ".log" file with further details of thetranslation, such as a list of warnings and notes including thosewhich are suppressed in the regular output..TP.B \-compCompiler mode.  This switch tells.I p2cto use various configuration defaults that are more suitable foruse as a Pascal compiler rather than a translator.  It is the sameas specifying the following options in your.I p2crcfile:.IP\ \ \ \ \ ElimDeadCode 0.br\ \ \ \ \ AnalyzeFlow 0.br\ \ \ \ \ MaxLineBreakTies 0.br\ \ \ \ \ FoldConstants 1.br\ \ \ \ \ FoldStrConstants 1.br\ \ \ \ \ OffsetForLoops 0.br\ \ \ \ \ StaticLinks 1.br\ \ \ \ \ BitwiseMod 0.br\ \ \ \ \ BitwiseDiv 0.br\ \ \ \ \ AssumeBits 0.br\ \ \ \ \ AssumeSigns 0.br\ \ \ \ \ FormatStrings 1.br\ \ \ \ \ StructFiles 1.br\ \ \ \ \ FullStrWrite 1.IPThe.I p2ccscript specifies this option when it runs.I p2cto compile a Pascal program..TP.B \-localLocal settings.  This switch uses various configuration defaultsthat are appropriate if the code generated by.I p2cis going to be compiled and run on the same machine that ran.I p2citself..TP.B \-checkEnable all error checking.  Normally, some error checks are offby default, as described in the comments in the system.I p2crcfile..TP.B \-M0Disable memory conservation.  This prevents.I p2cfrom freeing various data structures after translating each function,in case this new conservation feature causes unforseen problems..TP.B \-RRegression testing mode.  Formats notes and warning messages in a waythat makes it easier to run.IR diff (1)on the output of.I p2c..PP.I P2calso understands a few debugging options which may occasionally beuseful when tracking down translation problems.  The.BI \-d noption sets the "debug level" to.I n,a small integer which is normally zero.  Debugging output iswritten into the regular output file along with the C code; thehigher your.I n,the more "wallpaper" you get.  Also,.B \-tprints debugging information at every Pascal token,.BI \-B nenables line-breaker debugging,.BI \-C nenables comment placement debugging, and.BI \-F nenables flow-analysis debugging..SH CHOICE OF SOURCE LANGUAGEThe.B Languageconfiguration parameter or.B \-Lcommand-line option tells.I p2cwhich Pascal dialect to expect in the input file.  Any language featureswhich do not overlap between dialects are supported all of the time.  The.B Languageparameter is consulted when a syntax or usage is detected that has differentmeanings in two different dialects, and also to determine default valuesfor various other translation parameters as described below..PPThe following language words are supported by.I p2c.Names are case-insensitive..TP 8.B HPHP Pascal.  This is the default language.  All features of HP StandardPascal, the Pascal Workstation version, are supported except as notedin BUGS below.  Some features of MODCAL, HP's extended Pascal, are alsosupported.  This is a superset of ISO standard Pascal, includingconformant arrays and procedural parameters..TP.B HP-UXHP Pascal, HP-UX version.  Almost identical to the "HP" dialect..TP.B TurboTurbo Pascal 5.0 for the IBM PC.  Few conflicts with HP Pascal, so the.B Languageparameter is not often needed for Turbo.  (Most important is that the Turboand HP dialects use 16 and 32 bit integers, respectively.).TP.B UCSDUCSD Pascal.  Similar to Turbo in many ways..TP.B MPWMacintosh Programmer's Workshop Pascal 2.0.  Should also do a prettygood job for Lightspeed Pascal.  Object Pascal features are not supported,nor is the fact that.B charvariables are sometimes stored in 16 bits..TP.B VAXVAX/VMS Pascal version 3.5.  Most but not all language features supported.This has not yet been tested on large programs..TP.B OregonOregon Software Pascal/2.  All features implemented..TP.B BerkBerkeley Pascal with Sun extensions..TP.B TIPTexas Instruments Pascal..TP.B ApolloApollo Domain Pascal..TP.B Modula

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -