home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PAS_TO_C.ZIP / CONVERT.DOC next >
Encoding:
Text File  |  1980-01-01  |  9.6 KB  |  210 lines

  1.  
  2.          ┌────────────────────────────────────────────────────┐
  3.          │  Minute Translator by AM for Sandra, Aug 08, 1988  │
  4.          │                                                    │
  5.          └────────────────────────────────────────────────────┘
  6.  
  7. NOTE:
  8.      How to run the translator?
  9.      CONVERT path\JOE       { The Program will insert .c to JOE}
  10.  
  11.      The output file is Joe.pas.
  12.  
  13. Sometimes, due to stange the syntax (maybe, because of my limited abililies),
  14. the translator may skip lines. To correct this, you'd  "hand-correct" the
  15. last statement converted in the input file and re-run CONVERT.  For example,
  16. sometimes the translator convert  strcpy(a,"skdks");   to   a := 'skdks'(; .
  17. So it is important that you move all right-parenthesis a space over before
  18. running the translator.
  19.  
  20. Caution: This translator will not produce error-free programs, because
  21.          some commands in C cannot be 100-percent convertible to PASCAL.
  22.          Your skills will be needed at times to help correct the produced
  23.          program.
  24.  
  25.  
  26.                 -Thank You For Using My Translator-
  27.  
  28.  
  29.  
  30.  
  31. Here are some notes on C and Pascal.  The translator can convert these.
  32.  
  33.  
  34.          C                          PASCAL
  35. _____________________________________________________________________________
  36.                   |
  37.                   |
  38. #include <file name.h>   or       |     {I$ file name.ext }
  39.     "file name.ext"           |
  40.                   |
  41. #define  constant name   value    |     const   constant name = value
  42. #define  constant name   "value"  |             constant name = "value"
  43.                   |
  44.                   |
  45. typedef data type variable        |     type  variable = data type
  46. typedef char variable[length]     |           variable = string[length]
  47. typedef datatype st1, st2;        |           st1 = datatype
  48.                                   |           st2 = datatype
  49. typedef enum variable = { a,b,c } |           variable = ( a, b, c )
  50. typedef enum {a,"fs",sd} variable |           variable = (a, 'fs', sd);
  51. typedef struct   {                |     student = record
  52.   char name[30]                   |        name : string[30]
  53.   char age[3]                     |        age  : string[03]
  54.   int   hours, rate, salary       |        hours, rate, salary   : integer
  55.   float fica, state, city, ss     |        fica, state, city, ss : real
  56.   } student                       |      end
  57.                   |
  58. struct name_of_record  {          |     name_of_record = record
  59.   char name[25]                   |       name : string[25]
  60.   int  age                        |       age  : integer
  61.   }                               |     end
  62.                   |
  63.                   |   var
  64.   int    a, b, c                  |      a, b, c : integer
  65.   float  i, j, k                  |      i, j, k : real
  66.   double l, m, n                  |      l, m, n : real
  67.   unsigned char v, w, z           |      v, w, z : byte
  68.   char  d, e, f                   |      d, e, f : char
  69.   char  q[5], r[10], s[15]        |      q       : string[05]
  70.                   |      r       : string[10]
  71.                   |      s       : string[15]
  72.   FILE fp_input, fp_output        |      fp_input  : text
  73.                   |      fp_output : text
  74.   extern                          |      external;
  75.                   |
  76.   {                               |   begin
  77.   }                               |   end
  78.                   |
  79. Loops:                            |
  80.                   |
  81.   while (expr1 condition expr2)   |    while (expr1 condition expr2) do
  82.    {                              |      begin
  83.      statement1;                  |         statement1;
  84.      statement2;                  |         statement2;
  85.    }                              |      end;
  86.                   |
  87.   while (expr1 condition expr2)   |    while (expr1 condition expr2) do
  88.      statement1;                  |      statement1;
  89.                   |
  90.   do  {                           |    repeat
  91.     statement1                    |       statement1
  92.     statement2                    |       statement2
  93.     statement3                    |       statement3
  94.  } while (expr1 condition expr2)  |    until (expr1 condition expr2)
  95.                   |
  96.                   |
  97.  for (start; finish; increment    |    for index := start to finish do
  98.  for (i = 0; i <= 10; i++)        |    for i := 0 to 10 do
  99.  i = 1;                           |
  100.  for (; i <= 10; i++)             |   for i := 0 to 10 do
  101.                   |   ( translator will index at 0 if the
  102.                   |     index is initialized somewhere else
  103.                   |     other than in the for_structure )
  104.                   |
  105. void func name (datatype variable)| procedure func name (variable : datatype)
  106. void MAX_MIN (int  i, int  j)     | procedure MAX_MIN (i, j : integer)
  107. void SWAP    (char a, char b)     | procedure SWAP (a, b : char)
  108. void MAX_MIN                      | procedure  MAX_MIN
  109. void int counter;                 | procedure  counter : integer;
  110.                                   |    ** in this case you'd hand-correct **
  111.                                   |
  112. char Lowercase (char ch)          | function Lowercase (ch : char) : char
  113.  {                                |   begin
  114.   return (tolower (ch))           |       Lowercase := ....(ch)
  115.  }                                |   end
  116.                                   |
  117. int Low (int a, int b)            | function Low (a, b : integer) : integer
  118.  {                                |   begin
  119.     if (a < b)                    |     if (a < b ) then
  120.        return (a);                |       low := a
  121.     else                          |     else
  122.        return (b);                |       low := b;
  123.  }                                |   end
  124.                                   |
  125.    return                       |    exit
  126.    return (result)                |    exit (result) ** you let the function
  127.                                   |
  128.    abort                          |    halt
  129.    break                          |    exit
  130.                                   |                     equal the result **
  131.                                   |
  132.                                   |
  133. Assignments:                      |
  134.                                   |
  135.   a = 1                  |   a := 1
  136.   b = a                              |   b := a
  137.   c = b = a                       |   c := b := a  (you must change it)
  138.                                   |
  139. Conditionals:                     |
  140.                                   |
  141.  if (a != 1)                  |   if (a <> 1) then
  142.  if (a == 1)              |   if (a  = 1) then
  143.  if (a <= 1)                  |   if (a <= 1) then
  144.  if (a >= 1)               |   if (a >= 1) then
  145.                                   |
  146.  if (a != 1) || (b != 0)          |   if (a <> 1) or  (b <> 0) then
  147.  if (a == 1) && (b == 2)          |   if (a  = 1) and (b  = 2) then
  148.                                   |
  149.  while (a == 1) || (b == 2)       |   while (a = 1) or  (b = 2) do
  150.  while (a == 1) && (b == 2)       |   while (a = 1) and (b = 2) do
  151.                                   |
  152.    switch (statement)             |    case statement of
  153.    defualt                        |    else                                  |
  154.                                   |
  155.    strcpy (str1,str2)             |    str1 := str2;
  156.    strcpy (str1,"sksdsasad")      |    str1 := 'sksdsasad';
  157.    strlen ("Misfit")              |    length ('Misfit');
  158.    len = strlen ("Sandra ...");   |    len := length ('Sandra ...');
  159.                                   |
  160.    strcat (st1, st2);             |    concat (st1,st2)
  161.    strcat (st1, "Shaliza");       |    concat (st1, 'Shaliza');
  162.                                   |
  163.    if (strcmp (a,b) != 0)         |    if (a <> b) then
  164.    if (strcmp (a, "ajjs") == 0)   |    if (a 'ajjs' =) then  /* hand-correct
  165.    if (strcmp ("adf","ssd") != 0) |    if ("adf" 'ssd' !=) then /*  these */
  166.                                   |
  167. Input/Output:                     |
  168.    scanf  ("%c",ch)               |    read ('',ch)
  169.    scanf  ("%d",i)                |    read ('',i)
  170.    fscanf (fp_input,"%c",ch)      |    read (fp_input,'',ch)
  171.    gets   (ch)                    |    read (ch)
  172.    getchar (ch)                   |    read (ch)
  173.    fgetc   (ch)                   |    read (ch)
  174.    fgets   (ch)                   |    read (ch)
  175.                                   |
  176.    printf  ("%c",ch)              |    writeln ('',ch)
  177.    printf  ("%d",ch)              |    writeln ('',ch)
  178.    puts    (ch)                   |    write   (ch)
  179.    putchar (ch)                   |    write   (ch)
  180.    fputc   (fp_output,ch)         |    write (fp_output,ch)
  181.    fputs   (fp_output,ch)         |    write (fp_output,ch)
  182.                                   |
  183.    fclose (file);                 |    close (file);
  184.    fflush (file);                 |    flush (file);
  185.    fseek  (file);                 |    seek  (file);
  186.                                   |
  187.    null                           |    nil
  188.    asm                            |    inline
  189.    main ()                        |    blank;
  190.    const                   |    blank;
  191.    auto                           |    blank;
  192.    register                       |    blank;
  193.    long                           |    blank;
  194.    short                          |    blank;
  195.    signed                         |    blank;
  196.    unsigned                       |    blank;
  197.    volitile                       |    blank;
  198.                                   |
  199.    CASE                           |    blank;
  200.    CONTINUE                       |    blank;
  201.    -cs                            |    blank;
  202.    -ds                            |    blank;
  203.    -es                            |    blank;
  204.    -ss                            |    blank;
  205.    -cdecl                         |    blank;
  206.    far                            |    blank;
  207.    huge                           |    blank;
  208.    interrupt                      |    blank;
  209.    near                           |    blank;
  210.    pascal                         |    blank;