From: prechelt@i41s14.ira.uka.de (Lutz Prechelt)
Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.objective-c
Subject: C-Refine 3.0 preprocessor available
Date: 22 Jul 1992 14:53:22 GMT
Organization: University of Karlsruhe, FRG
Distribution: world
NNTP-Posting-Host: i41s14.ira.uka.de
Keywords: refinements, programming language extension


C-Refine Version 3.0 is now available for anonymous ftp from
  iraun1.ira.uka.de [129.13.10.90]
  /pub/gnu/crefine.3.0.tar.Z
as
-rw-r--r--  1 ftp      XLINK       93217 Jul 15 10:06 crefine.3.0.tar.Z

It also appeared on comp.sources.reviewed as v02i013 to v02i19
on July 15th, 1992

-----------------------------------------------------------------------------

C-Refine is a preprocessor for programs written in C or C++ or a similar
language. It introduces an additional language construct called 'refinement'
which allows further decomposition with symbolic names inside functions.
This makes programs much easier to read and modify and is very comfortable
for programming. C-Refine is very fast and fits easily into any open
programming environment.

Here is the tiny example program from the manual page,
so that you can grasp the idea:

 "This is a (very simple-minded) version
  of the Sieve of Eratosthenes. It should not be thought
  that  I  believe  the  refinement technique to be espe-
  cially well suited to this problem, but  this  was  the
  smallest 'real' problem I could think of to demonstrate
  at least most of what  the  possibilities  of  C-Refine
  are. So here it is:

/***** EXAMPLE : The Sieve of Eratosthenes *****/

#define MAX        10000
#define PRIME      0
#define NON_PRIME  1

static int sieve[MAX+1];

int main ()
{
  `initialize;
  `do sieve;
  `make output;
  return (0);
  
`initialize:
  int current;
  for (current = 2; current <= MAX; current++)
    sieve[current] = PRIME;
    
`do sieve:
  int current_prime = 1;
  for (;;) {
    `find next bigger prime;  /* perhaps STOP here */
    `delete all multiples of current_prime;
  }

`find next bigger prime:
  int current_candidate = current_prime + 1;
  while (sieve[current_candidate] == NON_PRIME)
    if (current_candidate == MAX)
      leave `do sieve;    /* leave two refinements at once */
    else
      current_candidate++;
  /* now current_candidate is a prime (or we leave `sieve) */
  current_prime = current_candidate;
  
`delete all multiples of current_prime:
  int current = `first multiple of current_prime;
  while (current <= MAX) {
    sieve[current] = NON_PRIME;
    current += current_prime;
  }
  
`first multiple of current_prime:
  2 * current_prime

`make output:
  int current;  /* different from 'current' above */
  printf ("The primes between 2 and %d are\n", MAX);
  for (current = 2; current <= MAX; current++)
    if (`current is prime)
      printf ("%5d ", current);

`current is prime:
  sieve[current] == PRIME

} /* end of main() */

/***** End of example *****/"

Your programs are more complicated ?
Fine, then C-Refine will be much more useful for them.

The installed system consists of a single executable file (crefine) and one
Unix Manualpage (crefine.1). No further data files or libraries
except the standard C library are needed, so C-Refine is very portable.
 
   Lutz 

Lutz Prechelt   (email: prechelt@ira.uka.de)            | Whenever you 
Institut fuer Programmstrukturen und Datenorganisation  | complicate things,
Universitaet Karlsruhe;  D-7500 Karlsruhe 1;  Germany   | they get
(Voice: ++49/721/608-4317, FAX: ++49/721/694092)        | less simple.