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

📄 p2c.cat

📁 把pascal程序转成C语言程序 把pascal程序转成C语言程序
💻 CAT
📖 第 1 页 / 共 5 页
字号:
P2C(1)                   USER COMMANDS                     P2C(1)                    concept  of  procedure  or function pointers,                    though with somewhat different syntaxes.  _P_2_c                    recognizes  both  notational styles.  Another                    difference is that  HP's  procedure  pointers                    can point to nested procedures, while Turbo's                    can point only to global procedures.   In  HP                    Pascal  a procedure pointer must be stored as                    a struct containing both a  pure  C  function                    pointer and a "static link," a pointer to the                    parent procedure's locals.  (The static  link                    is  NULL  for global procedures.)  This nota-                    tion can be forced by setting  StaticLinks=1.                    In  Turbo,  the default (StaticLinks=0) is to                    use plain C function pointers with no  static                    links.   A  third option (StaticLinks=2) uses                    structures with static links, but assumes the                    links  are always NULL when calling through a                    pointer (if you need compatibility  with  the                    HP  format  but know your procedures are glo-                    bal).     SmallSetConst  Pascal sets are translated into  one  of  two                    formats,  depending  on  the size of the set.                    If all elements have ordinal  values  in  the                    range  0..31, the set is translated as a sin-                    gle integer variable  using  bit  operations.                    (The  SetBits parameter may be used to change                    the upper limit  of  31.)  The  SmallSetConst                    parameter  controls  whether these small-sets                    are used,  and,  if  so,  how  constant  sets                    should  be  represented  in  C.    For larger                    sets, an array of long  is  used.   The  _s[0]                    element  contains  the  number  of succeeding                    array elements which are in  use.   Set  ele-                    ments  in  the  range 0..31 are stored in the                    _s[1] array element, and so on.  Sets are nor-                    malized  so  that  _s[_s[0]] is nonzero for any                    nonempty set.  The standard run-time  library                    includes  all  the  necessary  procedures for                    operating on sets.     ReturnValueName                    This is  one  of  many  "naming  conventions"                    parameters.  Most of these take the form of a                    _p_r_i_n_t_f-like string containing a %_s where  the                    relevant  information should go.  In the case                    of ReturnValueName, the %_s refers to a  func-                    tion  name and the resulting string gives the                    name of the  variable  to  use  to  hold  the                    function's  return  value.   Such  a variable                    will be made if a function  contains  assign-                    ments  to  its return value buried within theSun Release 4.1        Last change: local                      14P2C(1)                   USER COMMANDS                     P2C(1)                    body, so that _r_e_t_u_r_n statements  cannot  con-                    veniently  be used.  Some parameters (Return-                    ValueName included) do not require the %_s  to                    be present in the format string; for example,                    the  standard   _p_2_c_r_c   file   stores   every                    function's  return value in a variable called                    _R_e_s_u_l_t.     AlternateName  _P_2_c normally translates Pascal names  into  C                    names  verbatim, but occasionally this is not                    possible.  A Pascal name may be a C  reserved                    word  or  traditional  C  name  like _p_u_t_c, or                    there may be several like-named  things  that                    are  hidden from each other by Pascal's scop-                    ing rules but must be global in C.  In  these                    situations  _p_2_c  uses  the parameter Alterna-                    teName1 to generate an alternative  name  for                    the  symbol.  The default is to add an under-                    score to the name.  There is also an Alterna-                    teName2  parameter  for  a  second  alternate                    name, and an AlternateName parameter for  the                    _nth  alternate  name.   (The  value  for this                    parameter should include both a %_s and a  %_d,                    in either order.)  If these latter parameters                    are not defined, _p_2_c  applies  AlternateName1                    many times over.     ExportSymbol   Symbols in the interface section for a Pascal                    module  are  formatted according to the value                    of ExportSymbol, if any.  It is not  uncommon                    to  use  _m_o_d_u_l_e_n_a_m_e_%_s  for  this symbol; the                    default is %_s, i.e., no special treatment for                    exported  symbols.   If  you  also define the                    Export_Symbol parameter, that format is  used                    instead for exported symbols which contain an                    underscore character.  If %_S (with a  capital                    "S")  appears  in the format string it stands                    for the current module name.     Alias          If the value of this parameter contains a %_s,                    it is a format string applied to the names of                    external  functions  or  variables.   If  the                    value  does  not contain a %_s, it becomes the                    name of the next  external  symbol  which  is                    declared   (after   which  the  parameter  is                    cleared).     Synonym        This creates a  synonym  for  another  Pascal                    symbol or keyword.  The format is                         Synonym _o_l_d-_n_a_m_e = _n_e_w-_n_a_m_eSun Release 4.1        Last change: local                      15P2C(1)                   USER COMMANDS                     P2C(1)                    All occurrences of _o_l_d-_n_a_m_e in the input text                    are  treated  as if they were _n_e_w-_n_a_m_e by the                    parser.  If _n_e_w-_n_a_m_e is a  keyword,  _o_l_d-_n_a_m_e                    will  be  an equivalent keyword.  If _n_e_w-_n_a_m_e                    is the name of a  predefined  function,  _o_l_d-                    _n_a_m_e  will  behave  in  the  same way as that                    function, and so on.  If _n_e_w-_n_a_m_e is omitted,                    then  occurrences  of  _o_l_d-_n_a_m_e  are entirely                    ignored in the input  file.   Synonyms  allow                    you to skip over a keyword in your dialect of                    Pascal that is not understood by _p_2_c,  or  to                    simulate  a  keyword or predefined identifier                    of your dialect with a similar one  that  _p_2_c                    recognizes.   Note  that all predefined func-                    tions are available at all times; if you have                    a  library  routine  that behaves like, e.g.,                    Turbo Pascal's _g_e_t_m_e_m procedure, you can make                    your routine a synonym for _g_e_t_m_e_m even if you                    are not translating in Turbo mode.     NameOf         This defines the name  to  use  in  C  for  a                    specific  symbol.   It must appear before the                    symbol is declared in the Pascal code; it  is                    usually  placed  in  the local _p_2_c_r_c file for                    the project.  The format is                         NameOf _p_a_s_c_a_l-_n_a_m_e = _C-_n_a_m_e                    By default, Pascal names map directly onto  C                    names  with no change (except for the various                    kinds of formatting outlined above).  If  the                    _p_a_s_c_a_l-_n_a_m_e  is  of  the  form _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  only                    to  the  instance  of the Pascal name that is                    global to that module, or local to that  pro-                    cedure.   Otherwise, it applies to all usages                    of the name.     VarMacro       This is analogous to NameOf, but specifically                    for use with Pascal variables.  The righthand                    side can be most any C expression; all refer-                    ences  to the variable are expanded into that                    C expression.  Names used in the C expression                    are  taken  verbatim.  There is also a Const-                    Macro parameter for translating constants  as                    arbitrary  expressions.   Note that the vari-                    able on the lefthand side  must  actually  be                    declared  in  the program or in a module that                    it uses.  The declaration  for  the  variable                    will  be  omitted  from  the  generated  code                    unless the Pascal-name appears in the expres-                    sion:   If you ask to replace _i with _i+_1, theSun Release 4.1        Last change: local                      16P2C(1)                   USER COMMANDS                     P2C(1)                    variable _i will still  be  declared  but  its                    value will be shifted accordingly.  Note that                    if _i appears  on  the  lefthand  side  of  an                    assignment,  _p_2_c  will use algebra to "solve"                    for _i.                    In all cases where _p_2_c parses C  expressions,                    all  C  operators  are recognized except com-                    pound assignments like `+='.  (Increment  and                    decrement  operators  are allowed.) All vari-                    able and function names are assumed  to  have                    integer  type,  even  if  they are names that                    occur  in  the  actual  program.    A   type-                    specification  operator  `::' has been intro-                    duced; it has the same precedence as  `.'  or                    `->'  but the righthand side must be a Pascal                    type identifier (built-in or defined by  your                    program  previously to when the macro defini-                    tion was parsed), or an arbitrary Pascal type                    expression   in  parentheses.   The  lefthand                    argument  is  then  considered  to  have  the                    specified  type.   This  may  be necessary if                    your macro is used in  situations  where  the                    exact  type  of  the expression must be known                    (say, as the argument to a _w_r_i_t_e_l_n).     FieldMacro     Here the lefthand side  must  have  the  form                    _r_e_c_o_r_d._f_i_e_l_d, where _r_e_c_o_r_d is the Pascal type                    or variable name for a record, and _f_i_e_l_d is a                    field  in  that  record.   The righthand side                    must be a C  expression  generally  including                    the  name  _r_e_c_o_r_d. All instances of that name                    are replaced by the actual record being "dot-                    ted." For example,                         FieldMacro Rect.topLeft = topLeft(Rect)                    translates _a[_i]._t_o_p_L_e_f_t  into  _t_o_p_L_e_f_t(_a[_i]),                    where _a is an array of _R_e_c_t.     FuncMacro      The lefthand side must be any Pascal function                    or procedure name plus a parameter list.  The                    number of parameters must match the number in                    the  function's  uses and declaration.  Calls                    to the function are replaced by the C expres-                    sion on the righthand side.  For example,                         FuncMacro PtInRect(p,r) = PtInRect(p,&r)                    causes the second argument of _P_t_I_n_R_e_c_t to  be                    passed by reference, even though the declara-                    tion says  it's  not.   If  the  function  inSun Release 4.1        Last change: local                      17P2C(1)                   USER COMMANDS                     P2C(1)                    question  is  actually defined in the program                    or module  being  translated,  the  FuncMacro                    will  not  affect  the definition but it will                    affect all calls to the function elsewhere in                    the  module.   FuncMacros can also be applied                    to predefined or never-defined functions.     ReplaceBefore  This option specifies a string replacement to                    be  done  on  every  Pascal source line.  For                    example:

⌨️ 快捷键说明

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