home *** CD-ROM | disk | FTP | other *** search
-
- ┌────────────────────────────────────────────────────┐
- │ Minute Translator by AM for Sandra, Aug 08, 1988 │
- │ │
- └────────────────────────────────────────────────────┘
-
- NOTE:
- How to run the translator?
- CONVERT path\JOE { The Program will insert .c to JOE}
-
- The output file is Joe.pas.
-
- Sometimes, due to stange the syntax (maybe, because of my limited abililies),
- the translator may skip lines. To correct this, you'd "hand-correct" the
- last statement converted in the input file and re-run CONVERT. For example,
- sometimes the translator convert strcpy(a,"skdks"); to a := 'skdks'(; .
- So it is important that you move all right-parenthesis a space over before
- running the translator.
-
- Caution: This translator will not produce error-free programs, because
- some commands in C cannot be 100-percent convertible to PASCAL.
- Your skills will be needed at times to help correct the produced
- program.
-
-
- -Thank You For Using My Translator-
-
-
-
-
- Here are some notes on C and Pascal. The translator can convert these.
-
-
- C PASCAL
- _____________________________________________________________________________
- |
- |
- #include <file name.h> or | {I$ file name.ext }
- "file name.ext" |
- |
- #define constant name value | const constant name = value
- #define constant name "value" | constant name = "value"
- |
- |
- typedef data type variable | type variable = data type
- typedef char variable[length] | variable = string[length]
- typedef datatype st1, st2; | st1 = datatype
- | st2 = datatype
- typedef enum variable = { a,b,c } | variable = ( a, b, c )
- typedef enum {a,"fs",sd} variable | variable = (a, 'fs', sd);
- typedef struct { | student = record
- char name[30] | name : string[30]
- char age[3] | age : string[03]
- int hours, rate, salary | hours, rate, salary : integer
- float fica, state, city, ss | fica, state, city, ss : real
- } student | end
- |
- struct name_of_record { | name_of_record = record
- char name[25] | name : string[25]
- int age | age : integer
- } | end
- |
- | var
- int a, b, c | a, b, c : integer
- float i, j, k | i, j, k : real
- double l, m, n | l, m, n : real
- unsigned char v, w, z | v, w, z : byte
- char d, e, f | d, e, f : char
- char q[5], r[10], s[15] | q : string[05]
- | r : string[10]
- | s : string[15]
- FILE fp_input, fp_output | fp_input : text
- | fp_output : text
- extern | external;
- |
- { | begin
- } | end
- |
- Loops: |
- |
- while (expr1 condition expr2) | while (expr1 condition expr2) do
- { | begin
- statement1; | statement1;
- statement2; | statement2;
- } | end;
- |
- while (expr1 condition expr2) | while (expr1 condition expr2) do
- statement1; | statement1;
- |
- do { | repeat
- statement1 | statement1
- statement2 | statement2
- statement3 | statement3
- } while (expr1 condition expr2) | until (expr1 condition expr2)
- |
- |
- for (start; finish; increment | for index := start to finish do
- for (i = 0; i <= 10; i++) | for i := 0 to 10 do
- i = 1; |
- for (; i <= 10; i++) | for i := 0 to 10 do
- | ( translator will index at 0 if the
- | index is initialized somewhere else
- | other than in the for_structure )
- |
- void func name (datatype variable)| procedure func name (variable : datatype)
- void MAX_MIN (int i, int j) | procedure MAX_MIN (i, j : integer)
- void SWAP (char a, char b) | procedure SWAP (a, b : char)
- void MAX_MIN | procedure MAX_MIN
- void int counter; | procedure counter : integer;
- | ** in this case you'd hand-correct **
- |
- char Lowercase (char ch) | function Lowercase (ch : char) : char
- { | begin
- return (tolower (ch)) | Lowercase := ....(ch)
- } | end
- |
- int Low (int a, int b) | function Low (a, b : integer) : integer
- { | begin
- if (a < b) | if (a < b ) then
- return (a); | low := a
- else | else
- return (b); | low := b;
- } | end
- |
- return | exit
- return (result) | exit (result) ** you let the function
- |
- abort | halt
- break | exit
- | equal the result **
- |
- |
- Assignments: |
- |
- a = 1 | a := 1
- b = a | b := a
- c = b = a | c := b := a (you must change it)
- |
- Conditionals: |
- |
- if (a != 1) | if (a <> 1) then
- if (a == 1) | if (a = 1) then
- if (a <= 1) | if (a <= 1) then
- if (a >= 1) | if (a >= 1) then
- |
- if (a != 1) || (b != 0) | if (a <> 1) or (b <> 0) then
- if (a == 1) && (b == 2) | if (a = 1) and (b = 2) then
- |
- while (a == 1) || (b == 2) | while (a = 1) or (b = 2) do
- while (a == 1) && (b == 2) | while (a = 1) and (b = 2) do
- |
- switch (statement) | case statement of
- defualt | else |
- |
- strcpy (str1,str2) | str1 := str2;
- strcpy (str1,"sksdsasad") | str1 := 'sksdsasad';
- strlen ("Misfit") | length ('Misfit');
- len = strlen ("Sandra ..."); | len := length ('Sandra ...');
- |
- strcat (st1, st2); | concat (st1,st2)
- strcat (st1, "Shaliza"); | concat (st1, 'Shaliza');
- |
- if (strcmp (a,b) != 0) | if (a <> b) then
- if (strcmp (a, "ajjs") == 0) | if (a 'ajjs' =) then /* hand-correct
- if (strcmp ("adf","ssd") != 0) | if ("adf" 'ssd' !=) then /* these */
- |
- Input/Output: |
- scanf ("%c",ch) | read ('',ch)
- scanf ("%d",i) | read ('',i)
- fscanf (fp_input,"%c",ch) | read (fp_input,'',ch)
- gets (ch) | read (ch)
- getchar (ch) | read (ch)
- fgetc (ch) | read (ch)
- fgets (ch) | read (ch)
- |
- printf ("%c",ch) | writeln ('',ch)
- printf ("%d",ch) | writeln ('',ch)
- puts (ch) | write (ch)
- putchar (ch) | write (ch)
- fputc (fp_output,ch) | write (fp_output,ch)
- fputs (fp_output,ch) | write (fp_output,ch)
- |
- fclose (file); | close (file);
- fflush (file); | flush (file);
- fseek (file); | seek (file);
- |
- null | nil
- asm | inline
- main () | blank;
- const | blank;
- auto | blank;
- register | blank;
- long | blank;
- short | blank;
- signed | blank;
- unsigned | blank;
- volitile | blank;
- |
- CASE | blank;
- CONTINUE | blank;
- -cs | blank;
- -ds | blank;
- -es | blank;
- -ss | blank;
- -cdecl | blank;
- far | blank;
- huge | blank;
- interrupt | blank;
- near | blank;
- pascal | blank;