Page 1 of 1

View in other colours (as comments) #if #endif optional code

Posted: Tue Nov 18, 2003 2:27 pm
by ihoseba
Posibility to configure the editor to see in a graphic mode (different colours) the code areas that will be compiled and what will not.
I meant in 'c' code with sentences as #if (A==1)&&(B==0), #else, #endif.
In this case the editor has to recognise the constants A and B.
It will be very helpfull to design this kind of code when there are lots of sentences like this even nested.

Example:

#include "xxx.h";

#define A 1
#define B 0
#define C 1
#define D 0

void main(void)
{
#if (A==1)||(B==0) // In this case this is true
a=1; // This will be compiled, normal color
#if (C==1)&&(D==1) // In this case this is false
a=2; // This will not be compiled, comment color
#else // In this case this is true
a=3; // This will be compiled, normal color
#endif // End
a=4; // This will be compiled, normal color
#else // In this case this is false
a=5; // This will not be compiled, comment color
#endif // End
}

good

Posted: Tue Nov 18, 2003 2:52 pm
by ihoseba
very good

Posted: Tue Nov 18, 2003 3:36 pm
by MudGuard
For which programming languages?

Can you define a language-independant way to implement this?

Again, this needs a full parser for the programming language - Textpad is a language independant text editor.

Posted: Tue Nov 18, 2003 4:00 pm
by ihoseba
MudGuard wrote:For which programming languages?

Can you define a language-independant way to implement this?

Again, this needs a full parser for the programming language - Textpad is a language independant text editor.
As in "/*, */" for comments in 'c', almost all languages have conditional compilations directives.
It is not neccesary a parser it could be done with a definition file or something similar.