So started trying to get my compiler to generate informative errors to some extent (as it is yet to understand code for now) and I ran into a confusing error where it does not print the text currently being analyzed, I'm struggling to see what I did wrong so I'm hoping someone here can, 1st the output:
Code:
...
clang -o mitsy.elf mitsy.o memory.o
./mitsy.elf
mitsy alpha
Opening test.c...
Allocating text buffer...
Passing execution pool & text buffer to compiler...
Entering compiler loop...
Checking Type ...
test.c:1:1: Unknown type
Compilation Failed: ret = 1, errno = 0
makefile:41: recipe for target 'run' failed
make: *** [run] Error 1
Compilation failed.
Now the related bits of code:
Code:
size_t wordlen( char * const text ) {
size_t len = 0;
if ( !text ) return 0;
switch ( *text ) {
case '(': case ')':
case '[': case ']':
case '{': case '}':
case '=': case '%':
case '*': case '/':
case '+': case '-':
case '.': case ':':
return 0;
}
do {
if ( !text[len] || isspace( text[len] ) == 0 ) {
return len;
}
++len;
} while ( 1 );
return len;
}
...
default:
len = wordlen( text );
c = text[len];
text[len] = 0;
printf( "Checking Type %s...\n", text );
block = IsKnownType( *cc_exec_content, text );
if ( !block ) {
printf( "%s:%d:%d: Unknown type %s\n", path, line, pos, text );
return 1;
}
text[len] = c;
The first error should have read:
Code:
Checking Type int...
test.c:1:1: Unknown type int
As the content of test.c is just this:
Code:
int main( int argc, char **argc ) { return 0; }