home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / windows / news / 832 < prev    next >
Encoding:
Text File  |  1993-01-22  |  3.5 KB  |  134 lines

  1. Xref: sparky comp.windows.news:832 comp.lang.postscript:6406 comp.compilers:2224
  2. Newsgroups: comp.windows.news,comp.lang.postscript,comp.compilers
  3. Path: sparky!uunet!world!iecc!compilers-sender
  4. From: arthur@turing.ac.uk (Arthur van Hoff)
  5. Subject: PDB -- ANSI-C to PostScript compiler
  6. Reply-To: arthur@turing.ac.uk (Arthur van Hoff)
  7. Organization: The Turing Institute Ltd., Glasgow, Scotland
  8. Date: Thu, 21 Jan 1993 12:52:14 GMT
  9. Approved: compilers@iecc.cambridge.ma.us
  10. Message-ID: <93-01-152@comp.compilers>
  11. Keywords: interpreter, available
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 119
  14.  
  15. Hi PostScript Hackers,
  16.  
  17. PdB version 2.1 (ANSI-C to PostScript compiler) is now available via
  18. anonymous ftp from:
  19.  
  20.      turing.com (192.133.90.28) in pub/pdb2.1-demo.tar.Z
  21.      ftp.uu.net (192.48.96.9) in graphics/NeWS/pdb2.1-demo.tar.Z
  22.  
  23. There is no more need to write PostScript! Start using PdB right now!  PdB
  24. is an optimizing compiler to compile ANSI-C (like) code into Adobe
  25. compatible PostScript. It includes executables, examples and many useful
  26. header files. Note that it is not dependend on NeWS.
  27.  
  28. The release of version 2.1 includes:
  29.  
  30. - Binaries for Sun SPARC station and IBM RS6000.
  31. - Include files for Abobe PostScript level I.
  32. - Include files for NeWS upto version 3.1.
  33. - Include files for TNT upto version 3.1.
  34. - Support for CPS OpenWindows upto version 3.1.
  35. - Support NeWS classing in a C++ manner.
  36. - Plenty of examples of all the above functions.
  37. - NeWS/OpenWindows test suite.
  38. - PostScript reference manual.
  39. - UNIX manual pages.
  40.  
  41. Below are some examples of PdB code together with the PostScript
  42. produced by the compiler.
  43.  
  44. Have fun,
  45.  
  46.     Arthur van Hoff
  47.     pdb@turing.com
  48.  
  49. ################################
  50. Code to draw a star shape in PdB
  51. ################################
  52.  
  53. #include <graphics.h>
  54.  
  55. void starpath(int ang)
  56. {
  57.         int i;
  58.  
  59.         newpath();
  60.         moveto(100,100);
  61.         for (i = 1 ; i <= (int)(360 / ang) ; i++) {
  62.                 rotate(180 + ang);
  63.                 rlineto(100,0);
  64.         }
  65.         setgray(0);
  66.         stroke();
  67. }
  68.  
  69. ########################
  70. Verbatim Compiler output
  71. ########################
  72.  
  73. /starpath {
  74.   % int --
  75.   newpath 100 100 moveto 1 360 2 index div cvi exch sub 1 add 0 max {
  76.     dup 180 add rotate 100 0 rlineto
  77.   } repeat
  78.   pop 0 setgray stroke
  79. } def
  80.  
  81. ###########################
  82. Code for bubble-sort in PdB
  83. ###########################
  84.  
  85. #include <postscript.h>
  86.  
  87. /******************************************************
  88.  * Bubble sort (page 66)
  89.  * From: Algorithms + Data Structures = Programs
  90.  *       Nicklaus Wirth
  91.  */
  92.  
  93. void bubblesort(int *a)
  94. {
  95.         int i, j;
  96.  
  97.         for (i = length(a)-1 ; i > 1 ; i--)
  98.                 for (j = 0 ; j < i ; j++)
  99.                         if (a[j] > a[j+1]) {
  100.                                 int x = a[j+1];
  101.                                 a[j+1] = a[j];
  102.                                 a[j] = x;
  103.                         }
  104. }
  105.  
  106. ########################
  107. Verbatim Compiler output
  108. ########################
  109.  
  110. /bubblesort {
  111.   % int * --
  112.   dup length 1 sub -1 2 {
  113.     0 1 3 -1 roll 1 sub {
  114.       2 copy get 2 index 2 index 1 add get gt {
  115.         2 copy 1 add get 2 index 2 index 1 add 4 index 4 index get put
  116.         2 index 3 1 roll put
  117.       } {pop} ifelse
  118.     } for
  119.   } for
  120.   pop
  121. } def
  122.  
  123. --
  124. Arthur van Hoff 
  125. The Turing Institute Limited
  126. 36 North Hanover Street, 
  127. G1 2AD Glasgow, Scotland
  128.  
  129. Tel: +44 41 552 8858 or +44 41 552 6400  Fax: +44 41 552 2985
  130. Email: arthur@turing.com
  131. -- 
  132. Send compilers articles to compilers@iecc.cambridge.ma.us or
  133. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  134.