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

📄 p2c.cat

📁 把pascal程序转成C语言程序 把pascal程序转成C语言程序
💻 CAT
📖 第 1 页 / 共 5 页
字号:
                         ReplaceBefore "{$ifdef" "{EMBED  #ifdef"                         ReplaceBefore     "{$endif}"     "{EMBED                    #endif}"                    These lines rewrite Turbo Pascal compile-time                    conditionals into comments beginning with the                    special word EMBED.  This word instructs  p2c                    to format the rest of the comment without "/*                    */" delimiters, i.e., the rest of the comment                    is embedded directly in the output C program.                    There is also a  ReplaceAfter  option,  which                    specifies replacements to be done on the out-                    put of _p_2_c.                    Currently, this feature  makes  only  literal                    string    replacements,   not   pattern-based                    matches.  Some users of  _p_2_c  have  found  it                    useful  to feed their Pascal programs through                    a more  powerful  editor  like  _s_e_d  or  _p_e_r_l                    before  giving  them to _p_2_c. Quite often this                    is all that is necessary to get an acceptable                    translation  in the face of unrecognized Pas-                    cal dialects or language features.     IncludeFrom    This specifies that a given  module's  header                    should  be  included from a given place.  The                    second argument may be surrounded by  " "  or                    < >  as  necessary; if the second argument is                    omitted, no include directive  will  be  gen-                    erated for the module.     ImportFrom     This specifies that a given  module's  Pascal                    interface  text  can  be  found  in the given                    file.  The named file should  be  either  the                    source  file  for  the module, or a specially                    prepared file with the implementation section                    removed for speed.  If no ImportFrom entry is                    found for a module, the path defined  by  the                    ImportDir  list  is  searched.  Each entry in                    the path may contain a %_s, which  expands  to                    the  name  of  the  module.  The default pathSun Release 4.1        Last change: local                      18P2C(1)                   USER COMMANDS                     P2C(1)                    looks for %_s._p_a_s and %_s._t_e_x_t in  the  current                    directory,   then   for  /_u_s_r/_l_i_b/_p_2_c/%_s._i_m_p.                    (where /usr/lib/p2c is the  _p_2_c  home  direc-                    tory.)     StructFunction This parameter is a list of  functions  which                    follow the _p_2_c semantics for structure-valued                    functions (functions returning arrays,  sets,                    and  strings,  and  structs  in  primitive  C                    dialects).  For these functions, a pointer to                    a return-value area is passed to the function                    as a special first parameter.   The  function                    stores  the result in this area, then returns                    a copy of the pointer.  (The standard C func-                    tion  _s_t_r_c_p_y  is  an example of this concept.                    _S_p_r_i_n_t_f  also  behaves  this  way   in   some                    dialects;    it   always   appears   on   the                    StructFunction list regardless of the type of                    implementation.)   The  system  configuration                    file includes a  list  of  common  structured                    functions  so  that _p_2_c's optimizer will know                    how to manipulate them.     StrlapFunction Functions on this list are  structured  func-                    tions  as above, but with the ability to work                    in-place; that is, the same  pointer  may  be                    passed  as  both  the return value area and a                    regular parameter.     Deterministic  Functions on this list have no  side  effects                    or  side dependencies.  An example is the _s_i_n                    function in the standard  math  library;  two                    calls  with the same parameter values produce                    the same result, and have  no  effects  other                    than  returning a value.  _P_2_c can make use of                    this knowledge when optimizing code for effi-                    ciency  or  readability.   Functions  on this                    list are also assumed to be relatively  fast,                    so  that it is acceptable to duplicate a call                    to the function.     LeaveAlone     Functions on this list are not  subjected  to                    the  normal  built-in  translation rules that                    _p_2_c would otherwise use.  For example, adding                    _w_r_i_t_e_l_n  to this list would translate _w_r_i_t_e_l_n                    statements blindly into calls  to  a  C  _w_r_i_-                    _t_e_l_n() function, rather than being translated                    into equivalent _p_r_i_n_t_f calls.   The  built-in                    translation  is  also suppressed if the func-                    tion has a FuncMacro.     BufferedFile   _P_2_c normally assumes binary  files  will  useSun Release 4.1        Last change: local                      19P2C(1)                   USER COMMANDS                     P2C(1)                    _r_e_a_d/_w_r_i_t_e,  not  _g_e_t/_p_u_t/^ notation.  A file                    buffer variable will only be  created  for  a                    file  if buffer notation is used for it.  For                    global file variables this  may  be  detected                    too  late  (a declaration without buffers may                    already have been written).  Such  files  can                    be  listed  in  BufferedFile  to force _p_2_c to                    allocate buffers for them; do this if you get                    a  warning message that says it is necessary.                    Set BufferedFile=1 to buffer  all  files,  in                    which case UnBufferedFile allows you to force                    certain files _n_o_t to have buffers.     StructFiles    If _p_2_c still can't translate your file opera-                    tions correctly, you can set StructFiles=1 to                    cause Pascal files to translate into  structs                    which  include  the  usual C _F_I_L_E pointer, as                    well as file buffer  and  file  name  fields.                    While the resulting code doesn't look as much                    like native C, the file  structs  will  allow                    _p_2_c  to do a correct translation in many more                    cases.     CheckFileEOF   Normally  only   file-open   operations   are                    checked  for errors.  Additional error check-                    ing, such as  read-past-end-of-file,  can  be                    enabled  with  parameters  like CheckFileEOF.                    These checks can make the code very ugly!  If                    I/O   checking  is  enabled  by  the  program                    ($iocheck on$ in HP Pascal; {$I+}  in  Turbo;                    this  is  always  the  default  state), these                    checks  will  generate  fatal  errors  unless                    enclosed  in  an  HP  Pascal try-recover con-                    struct.  If I/O checking is  disabled,  these                    will  cause the global variable _P__i_o_r_e_s_u_l_t to                    be set zero or nonzero according to the  out-                    come.   The default for most of these options                    is  to  check  only  when  I/O  checking   is                    enabled.ISSUES     Integer size. _P_2_c  normally  generates  code  to  work  with     either  16 or 32 bit ints.  If you know your C integers will     be 16 or 32 bits, set IntSize appropriately.  In  particular     setting  IntSize=32  will generate much cleaner code: _p_2_c no     longer must carefully cast function  arguments  between  int     and long.  These casts also will be unnecessary if ANSI pro-     totypes are available.  To disable int/long casting  because     you  know  at  least one of these cases will hold, set Cast-     LongArgs=0.   (The  CastArgs  parameter  similarly  controls     other types of casts, such as between ints and doubles.) The     Integer16 parameter controls  whether  Pascal  integers  areSun Release 4.1        Last change: local                      20P2C(1)                   USER COMMANDS                     P2C(1)     interpreted  as  16  or  32  bits, or translated as native C     integers.   The  default  value  depends  on  the   Language     selected.     Signed/unsigned  chars.  Pascal  characters   are   normally     "weakly"  interpreted  as  unsigned;  this  is controlled by     UnsignedChar.  The default is "either," so that  C's  native     char  type  may  be used even if its signed-ness is unknown.     Code that uses characters outside of  the  range  0-127  may     need  a  different  setting.  Alternatively, you can use the     types {SIGNED} char and {UNSIGNED} char  in  the  few  cases     where  it  really matters.  These comments are controlled by     the SignedComment and UnsignedComment parameters.  (The type     {UNSIGNED}  integer  is  also  recognized.)   The SignedChar     parameter tells whether C characters are signed or  unsigned     (default  is  "unknown").  The HasSignedChar parameter tells     whether the phrase "signed char" is legal in the output.  If     it  is  not,  _p_2_c  may have to translate Pascal signed bytes     into C shorts.     Special types. _P_2_c understands the following predefined Pas-     cal  type  names:  integer,  signed  integers  depending  on     Integer16;  longint,  signed  32-bit   integers;   unsigned,     unsigned  32-bit  integers;  sword,  signed 16-bit integers;     word, unsigned  16-bit  integers;  c_int,  signed  native  C     integers;  c_uint, unsigned native C integers; sbyte, signed     8-bit  integers;  byte,  unsigned  8-bit   integers;   real,     floating-point  numbers  depending  on  DoubleReals; single,     single-precision floats;  longreal,  double,  and  extended,     double-precision   floats;   pointer   and  anyptr,  generic     pointers  (assignment-compatible  with  any  pointer  type);     string,  generic  string  of  length StringDefault (normally     255); also, the usual Pascal types char, boolean, and  text.     (If your Pascal uses different names for these concepts, the     Synonym option will come in handy.)     Embedded code. It is possible to write a Pascal comment con-     taining  C  code  to  be  embedded into the output.  See the     descriptions of EmbedComment and its relatives in the system     _p_2_c_r_c  file.  These techniques are helpful if you plan to do     repeated translations of code that is still being maintained     in  Pascal.   See  the  description  of ReplaceBefore for an     example use of embedded code.     Comments and blank lines. _P_2_c collects  the  comments  in  a     procedure  into  a  list.   All  comments and statements are     stamped with serial numbers which are used to reattach  com-     ments to statements even after code has been added, removed,     or  rearranged  during   translation.    "Orphan"   comments     attached  to  statements that have been lost are attached to     nearby statements or emitted at the end  of  the  procedure.     Blank  lines  are  treated as a kind of comment, so _p_2_c willSun Release 4.1        Last change: local                      21P2C(1)                   USER COMMANDS                     P2C(1)     also reproduce your usage of blank lines.   If  the  comment     mechanism  goes  awry, you can disable comments with EatCom-     ments or disable their being attached to code with  SpitCom-     ments.     Indentation. _P_2_c has a number of parameters to govern inden-     tation  of  code.   The default values produce the GNU Emacs     standard indentation style, although _p_2_c can do a better job     since  it knows more about the code it is indenting.  Inden-     tation works by applying  "indentation  deltas,"  which  are     either  absolute numbers (which override the previous inden-     tation), or signed relative numbers (which augment the  pre-     vious  indentation).  A delta of "+0" specifies no change in     indentation.  All of the indentation options  are  described     in the standard _p_2_c_r_c file.     Line breaking. _P_2_c uses an  algorithm  similar  to  the  TeX     typesetter's  paragraph  formatter  for breaking long state-     ments into multiple lines.  A "penalty" is assigned to vari-     ous  undesirable  aspects  of  all possible line breaks; the     "badness" of a set of line breaks is approximately  the  sum     of  all the penalties.  Chief among these are serious penal-     ties  for  overrunning  the  desired  maximum  line   length     (default  78  columns),  an infinite penalty for overrunning     the absolute maximum line length (default 90), and  progres-     sively  greater  penalties  for breaking at operators deeply     nested in expressions.  Parameters  such  as  OpBreakPenalty     control the relative weights of various choices.  BreakArith     and its neighbors control whether the  opera

⌨️ 快捷键说明

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