home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / gcc / help / 3056 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  3.8 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!rpi!crdgw1!rdsunx.crd.ge.com!rdsunx!montnaro
  2. From: montnaro@spyder.crd.ge.com (Skip Montanaro)
  3. Newsgroups: gnu.gcc.help
  4. Subject: Re: Making a C to PostScript compiler with GCC
  5. Message-ID: <MONTNARO.93Jan28095014@spyder.crd.ge.com>
  6. Date: 28 Jan 93 14:50:14 GMT
  7. References: <9301262119.AA29680@osnome.che.wisc.edu>
  8. Sender: usenet@crd.ge.com (Required for NNTP)
  9. Reply-To: montanaro@ausable.crd.ge.com (Skip Montanaro)
  10. Distribution: gnu
  11. Organization: GE Corporate Research & Development, Schenectady, NY
  12. Lines: 128
  13. In-Reply-To: epperly@osnome.che.wisc.edu's message of 26 Jan 1993 16:33:08 -0500
  14. Nntp-Posting-Host: spyder.crd.ge.com
  15.  
  16.  
  17. In article <9301262119.AA29680@osnome.che.wisc.edu> epperly@osnome.che.wisc.edu (Tom Epperly) writes:
  18.  
  19.    I was wondering how difficult it would be to make a C to PostScript
  20.    compiler with GCC.  Could this be done by writing a GCC machine
  21.    description file for the PostScript language?  Can someone describe if
  22.    this is feasible and how difficult it would be?
  23.  
  24. There is something already available from the Turing Institute. Here's the
  25. announcement.
  26.  
  27. ----------
  28.  
  29.   From: Arthur van Hoff <arthur@turing-institute.ac.uk>
  30.   To: pdb-list@turing-institute.ac.uk
  31.   Subject: PDB -- ANSI-C to PostScript compiler
  32.   Date: Wed, 20 Jan 93 12:19:36 GMT
  33.  
  34.  
  35.   Hi HyperLook and HyperNeWS Hackers,
  36.  
  37.   PdB version 2.1 (ANSI-C to PostScript compiler) is now available
  38.   via anonymous ftp from:
  39.  
  40.        turing.com (192.133.90.28)  pub/pdb2.1-demo.tar.Z.
  41.  
  42.   There is no more need to write PostScript! Start using PdB right now!
  43.   PdB is an optimizing compiler to compile ANSI-C (like) code into Adobe
  44.   compatible PostScript. The release of version 2.1 includes:
  45.  
  46.   - Binaries for Sun SPARC station and IBM RS6000.
  47.   - Include files for Abobe PostScript level I.
  48.   - Include files for NeWS upto version 3.1.
  49.   - Include files for TNT upto version 3.1.
  50.   - Support for CPS OpenWindows upto version 3.1.
  51.   - Support NeWS classing in a C++ manner.
  52.   - Plenty of examples of all the above functions.
  53.   - NeWS/OpenWindows test suite.
  54.   - PostScript reference manual.
  55.   - UNIX manual pages.
  56.  
  57.   Below are some examples of PdB code together with the PostScript
  58.   produced by the compiler.
  59.  
  60.   Have fun,
  61.  
  62.       Arthur van Hoff
  63.       pdb@turing.com
  64.  
  65.  
  66.  
  67.   ################################
  68.   Code to draw a star shape in PdB
  69.   ################################
  70.  
  71.   #include <graphics.h>
  72.  
  73.   void starpath(int ang)
  74.   {
  75.       int i;
  76.  
  77.       newpath();
  78.       moveto(100,100);
  79.       for (i = 1 ; i <= (int)(360 / ang) ; i++) {
  80.           rotate(180 + ang);
  81.           rlineto(100,0);
  82.       }
  83.       setgray(0);
  84.       stroke();
  85.   }
  86.  
  87.   ########################
  88.   Verbatim Compiler output
  89.   ########################
  90.  
  91.   /starpath {
  92.     % int --
  93.     newpath 100 100 moveto 1 360 2 index div cvi exch sub 1 add 0 max {
  94.       dup 180 add rotate 100 0 rlineto
  95.     } repeat
  96.     pop 0 setgray stroke
  97.   } def
  98.  
  99.   ###########################
  100.   Code for bubble-sort in PdB
  101.   ###########################
  102.  
  103.   #include <postscript.h>
  104.  
  105.   /******************************************************
  106.    * Bubble sort (page 66)
  107.    * From: Algorithms + Data Structures = Programs
  108.    *       Nicklaus Wirth
  109.    */
  110.  
  111.   void bubblesort(int *a)
  112.   {
  113.       int i, j;
  114.  
  115.       for (i = length(a)-1 ; i > 1 ; i--)
  116.           for (j = 0 ; j < i ; j++)
  117.               if (a[j] > a[j+1]) {
  118.                   int x = a[j+1];
  119.                   a[j+1] = a[j];
  120.                   a[j] = x;
  121.               }
  122.   }
  123.  
  124.   ########################
  125.   Verbatim Compiler output
  126.   ########################
  127.  
  128.   /bubblesort {
  129.     % int * --
  130.     dup length 1 sub -1 2 {
  131.       0 1 3 -1 roll 1 sub {
  132.     2 copy get 2 index 2 index 1 add get gt {
  133.       2 copy 1 add get 2 index 2 index 1 add 4 index 4 index get put
  134.       2 index 3 1 roll put
  135.     } {pop} ifelse
  136.       } for
  137.     } for
  138.     pop
  139.   } def
  140.  
  141. ----------
  142. --
  143. Skip (montanaro@crd.ge.com)
  144.