Hello Jack,
yes is the first use of a bigger project.
It will (may)be a C compiler in future.
For now generates explanation in english, and help me in the development if everybody reports the problematic declarations (so I can debug the code).
It understands also many constructs, (not the preprocessor, the switch statement, the goto, the enums and something else).
You can try something like:
int array_of_ints[10][10];
_Static_assert(sizeof (array_of_ints) == sizeof(int)*10*10, "'array_of_ints' doesn't " "occupy" " 400 bytes!");
_Static_assert(sizeof(char) == 1, "'char' is " "not" " equal to 1!");
_Static_assert(sizeof(short) == 2,
"'short'"
" is not"
" equal to 2!");
_Static_assert(sizeof(double) == 8, "'double' is not equal to 8!");
_Static_assert((1<<2)+1 == 2*2+1, "5" " != "
"5"
" ...");
Shows sizeof, arrays and string concatenation. Or:
typedef int INTEGER;
INTEGER int1 = 100;
float FloatVal = 0.34e-1;
float FloatHex = 0x1.99999ap-4;
typedef char * CHAR_PTR;
CHAR_PTR pChar;
int fnproto(int a, char *c, float f);
const unsigned int * restrict const * restrict const flt;
That shows constants input and qualified declarations. Or a function definition:
int fn(int a, int b)
{
typedef int MyInt;
MyInt c = (MyInt){2};
int d = c + 1, z = d-1+array_of_ints[1][1];
_Static_assert((1<<2)+1 == 2*2+1, "5 != 5 ...");
if (flt == 0)
{
c = (MyInt)(void *)(c + d--) >> 2;
}
else
{
flt = 0;
}
do
{
c = c+1;
}
while (c<100);
while (++c > c-a)
{
c = c - 1;
c += 2;
d |= c;
}
int res = (c + a) * b - 2 != 0 ? a >> (int)((3 & 1)) : (int)((b - a) % 4);
return (c + a) * b - 2 != 0 ? a + (3 & 1) : (b - a) % 4;
c = 3;
}
This will trigger a warning for unreachable code.