🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Tom Epperly Tue, 26 Jan 1993 21:33
Making a C to PostScript compiler with GCC
#896
Author: Tom Epperly
Date: Tue, 26 Jan 1993 21:33
6 lines
715 bytes
I was wondering how difficult it would be to make a C to PostScript
compiler with GCC.  Could this be done by writing a GCC machine
description file for the PostScript language?  Can someone describe if
this is feasible and how difficult it would be?

				Tom
Re: Making a C to PostScript compiler with GCC
#909
Author: Skip Montanaro
Date: Thu, 28 Jan 1993 14:50
128 lines
4001 bytes
In article <9301262119.AA29680@osnome.che.wisc.edu> epperly@osnome.che.wisc.edu (Tom Epperly) writes:

   I was wondering how difficult it would be to make a C to PostScript
   compiler with GCC.  Could this be done by writing a GCC machine
   description file for the PostScript language?  Can someone describe if
   this is feasible and how difficult it would be?

There is something already available from the Turing Institute. Here's the
announcement.

----------

  From: Arthur van Hoff <arthur@turing-institute.ac.uk>
  To: pdb-list@turing-institute.ac.uk
  Subject: PDB -- ANSI-C to PostScript compiler
  Date: Wed, 20 Jan 93 12:19:36 GMT


  Hi HyperLook and HyperNeWS Hackers,

  PdB version 2.1 (ANSI-C to PostScript compiler) is now available
  via anonymous ftp from:

	   turing.com (192.133.90.28)  pub/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. 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

----------
--
Skip (montanaro@crd.ge.com)
Re: Making a C to PostScript compiler with GCC
#902
Author: Paul Crowley
Date: Thu, 28 Jan 1993 17:49
11 lines
1146 bytes
Quoting epperly@osnome.che.wisc.edu (Tom Epperly) in article <9301262119.AA29680@osnome.che.wisc.edu>:
>I was wondering how difficult it would be to make a C to PostScript
>compiler with GCC.  Could this be done by writing a GCC machine
>description file for the PostScript language?  Can someone describe if
>this is feasible and how difficult it would be?

The resulting code would certainly run very, very slowly.  What is it
you're trying to do?
  __                                  _____
\/ o\ Paul Crowley   pdc@dcs.ed.ac.uk \\ //
/\__/ Trust me. I know what I'm doing. \X/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads