hn-classics/_stories/1993/12668668.md

188 lines
5.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[Source](https://compilers.iecc.com/comparch/article/93-01-152 "Permalink to Comp.compilers: PDB -- ANSI-C to PostScript compiler")
# Comp.compilers: PDB -- ANSI-C to PostScript compiler
# PDB -- ANSI-C to PostScript compiler
## arthur@turing.ac.uk (Arthur van Hoff)
Thu, 21 Jan 1993 12:52:14 GMT
          _From comp.compilers_
* * *
| ----- |
| Related articles |
| [**PDB -- ANSI-C to PostScript compiler][1] _arthur@turing.ac.uk_ (1993-01-21)** |
| [List of all articles for this month][2] |
* * *
* * *
| ----- |
| **Newsgroups: ** | comp.windows.news,comp.lang.postscript,comp.compilers |
| **From: ** | arthur@turing.ac.uk (Arthur van Hoff) |
| **Organization: ** | The Turing Institute Ltd., Glasgow, Scotland |
| **Date: ** | Thu, 21 Jan 1993 12:52:14 GMT |
| **Keywords: ** | interpreter, available |
Hi PostScript Hackers,
PdB version 2.1 (ANSI-C to PostScript compiler) is now available via
anonymous ftp from:
turing.com (192.133.90.28) in pub/pdb2.1-demo.tar.Z
ftp.uu.net (192.48.96.9) in graphics/NeWS/pdb2.1-demo.tar.Z
There is no more need to write PostScript! Start using PdB right now! PdB
is an optimizing compiler to compile ANSI-C (like) code into Adobe
compatible PostScript. It includes executables, examples and many useful
header files. Note that it is not dependend on NeWS.
The release of version 2.1 includes:
\- Binaries for Sun SPARC station and IBM RS6000.
\- Include files for Abobe PostScript level I.
\- Include files for NeWS upto version 3.1.
\- Include files for TNT upto version 3.1.
\- Support for CPS OpenWindows upto version 3.1.
\- Support NeWS classing in a C++ manner.
\- Plenty of examples of all the above functions.
\- NeWS/OpenWindows test suite.
\- PostScript reference manual.
\- UNIX manual pages.
Below are some examples of PdB code together with the PostScript
produced by the compiler.
Have fun,
Arthur van Hoff
pdb@turing.com
################################
Code to draw a star shape in PdB
################################
#include <graphics.h>
void starpath(int ang)
{
                int i;
                newpath();
                moveto(100,100);
                for (i = 1 ; i <= (int)(360 / ang) ; i++) {
                                rotate(180 + ang);
                                rlineto(100,0);
                }
                setgray(0);
                stroke();
_}_
########################
Verbatim Compiler output
########################
/starpath {
    % int --
    newpath 100 100 moveto 1 360 2 index div cvi exch sub 1 add 0 max {
        dup 180 add rotate 100 0 rlineto
    } repeat
    pop 0 setgray stroke
_} def_
###########################
Code for bubble-sort in PdB
###########################
#include <postscript.h>
/******************************************************
  * Bubble sort (page 66)
  * From: Algorithms + Data Structures = Programs
  * Nicklaus Wirth
  */
void bubblesort(int *a)
{
                int i, j;
                for (i = length(a)-1 ; i > 1 ; i--)
                                for (j = 0 ; j < i ; j++)
                                                if (a[j] > a[j+1]) {
                                                                int x = a[j+1];
                                                                a[j+1] = a[j];
                                                                a[j] = x;
                                                }
_}_
########################
Verbatim Compiler output
########################
/bubblesort {
    % int * --
    dup length 1 sub -1 2 {
        0 1 3 -1 roll 1 sub {
            2 copy get 2 index 2 index 1 add get gt {
                2 copy 1 add get 2 index 2 index 1 add 4 index 4 index get put
                2 index 3 1 roll put
            } {pop} ifelse
        } for
    } for
    pop
_} def_
\--
Arthur van Hoff
The Turing Institute Limited
36 North Hanover Street,
G1 2AD Glasgow, Scotland
Tel: +44 41 552 8858 or +44 41 552 6400 Fax: +44 41 552 2985
Email: arthur@turing.com
\--
* * *
[Post a followup to this message][3]
* * *
* * *
![][4] Return to the [comp.compilers page][5].
![][6] Search the [comp.compilers archives][7] again.
[1]: /comparch/article/93-01-152
[2]: https://compilers.iecc.com/comparch/index/1993-01
[3]: mailto:compilers@iecc.com?subject=PDB%20--%20ANSI-C%20to%20PostScript%20compiler
[4]: https://compilers.iecc.com/icons/up.gif
[5]: https://compilers.iecc.com/index.phtml
[6]: https://compilers.iecc.com/icons/left.gif
[7]: https://compilers.iecc.com/compsearch.phtml