CNest program

by Stanislaw Raczynski ©

Consult also: http://www.raczynski.com/pn/bluesss.htm (Bluesss Simulation System)

http://www.raczynski.com/pn/simcourse.htm (Program and material for a complete simulation course)

 

Fluid dynamics

Heat Transfer

Queuing

Molecular simulation

Simulation Encyclopedia

C++ code generators

Delphi code generators

       This is a simple program which will help you to make your C code more readable and clear. The main function of CNest is to insert proper nesting to your code. It works only on the code (*.c or *.cpp units) and does not change header files, if any exist. The operation modes of CNest are as follows:
  • Simple nesting (Separate braces). The braces {  } will appear in separate lines, with proper nesting, which afects the code between the { and } lines.
  • Compact nesting. The code is nested as in simple nesting, but the instructions begin just after the { character. The closing braces } appear at the end of the last line of the segment code.
  • Merge short instructions. In this mode short instructions like  k=1; alfa=fun(beta); are being put in one line of code.
  • Eliminate comments. The comments marke by // and /*....*/ are being eliminated.

     CNest has been developed to process the code generated by the Bluesss Simulation System. However, it can process any C or C++ code.

Examples:

Simple nesting:

The original code:

String ucho; int MyFunction  // my function
(int a, float b
){
a=sqr(a); b=a+52*b; for(int k=0;k<10;k++)b+=a+b; return b;}

void OtherFunction(int a, float   variablex[]){variablex[a]=7;if
(a==2){variablex[a]=a*a; Sleep(200); variablex[a+1]=0;}}

The result of processning in "Simple nesting" mode:

String ucho;
// my function
int MyFunction
(int a, float b)
   {
   a=sqr(a);
   b=a+52*b;
   for(int k=0;k<10;k++)b+=a+b;
   return b;
   }
// End of function MyFunction
 
void OtherFunction(int a, float   variablex[])
   {
   variablex[a]=7;
   if(a==2)
      {
      variablex[a]=a*a;
      Sleep(200);
      variablex[a+1]=0;
      }
   }
// End of function OtherFunction

Processing in "Compact" mode will result in the following:

String ucho;
// my function
int MyFunction
(int a, float b)
   {a=sqr(a);
   b=a+52*b;
   for(int k=0;k<10;k++)b+=a+b;
   return b;}
// End of function MyFunction
 
void OtherFunction(int a, float   variablex[])
   {variablex[a]=7;
   if(a==2)
      {variablex[a]=a*a;
      Sleep(200);
      variablex[a+1]=0;}}
// End of function OtherFunction

The same code after processing in "Compact" and "Merge short instructions" mode:

String ucho;
// my function
int MyFunction (int a, float b) {a=sqr(a); b=a+52*b;
   for(int k=0;k<10;k++)b+=a+b; return b;}
// End of function MyFunction
 
void OtherFunction(int a, float   variablex[])
   {variablex[a]=7;
   if (a==2)
      {variablex[a]=a*a; Sleep(200); variablex[a+1]=0;}}
// End of function OtherFunction
Use the button below to buy the program. Only US$ 7.00
If you don't have a PayPal account, you can open it in few minutes.
What follows: When your payment is accepted, we receive a copy of the receipt. Then, we send to you the download and installation instructions by e-mail. If this does not happen the next few hours, please send us a message. Please provide an alternate e-mail address, sometimes we cannot communicate (bad anti-spam or other restrictions).

 

Consult also
http://www.raczynski.com/pn/pn.htm

and
http://www.raczynski.com (resume of Stanislaw Raczynski)

 

You are visitor number   since Feb 25, 2007 (last counter reset)