hi
i made another vector c-like language compiler recently, and port it to my os. it seems work fine.
little language brief:
int main()
{
int[4] * p;
(*p)[2]=100;
}
semi-new language & compiler for test.
semi-new language & compiler for test.
- Attachments
-
- win32.zip
- (31.88 KiB) Downloaded 69 times
-
- Member
- Posts: 199
- Joined: Sat Jun 28, 2008 6:44 pm
Re: semi-new language & compiler for test.
Sorry to rain on your parade, but I don't see the advantage of this. Putting the size of the subsequent array beside the type name instead of the identifier seems like a bad idea. For one, it means that each declaration ends up being ambiguous or creating using stack space in excess for no reason. It creates confusion for the reader and adds extra complexity to the compiler. It's basically the same as C, except that array size is placed beside the type instead of after the identifier. You can accomplish the exact same thing in C by dereferencing 'p' combined with an displacement offset like this:
Code: Select all
int *p[4];
*(p+2) = 100; /* or */
(*p)[2] = 100;
Re: semi-new language & compiler for test.
I guess that "int[4] * p;" defines a pointer to an array of four ints, not an array of four pointers to an int.
Nevertheless I do not see the advantage over C, and moreover, the pointer isn't initialized so "(*p)[2]=100;" is trashing memory.
Nevertheless I do not see the advantage over C, and moreover, the pointer isn't initialized so "(*p)[2]=100;" is trashing memory.
Re: semi-new language & compiler for test.
yes, it's a pointer of int[4]. It functions just like traditional C, but in clean syntax.
declaration syntax: typelist variablelist;
int*(int*)* p_function; // a function pointer, function itself return pointer, its argument is a pointer too
vector int [4] vi; // vector int128, operate sse instruction directly
typedef mytype int*[4]* // define new type
declaration syntax: typelist variablelist;
int*(int*)* p_function; // a function pointer, function itself return pointer, its argument is a pointer too
vector int [4] vi; // vector int128, operate sse instruction directly
typedef mytype int*[4]* // define new type
Re: semi-new language & compiler for test.
...Where "clean syntax" means "completely unreadable by people who understand C conventions"?blackoil wrote:yes, it's a pointer of int[4]. It functions just like traditional C, but in clean syntax.
C works. Leave it alone.
Re: semi-new language & compiler for test.
well, how difficult to understand?Lithorien wrote:...Where "clean syntax" means "completely unreadable by people who understand C conventions"?blackoil wrote:yes, it's a pointer of int[4]. It functions just like traditional C, but in clean syntax.
C works. Leave it alone.
you can understand something like
int*(*f)(int*p);
but you can not understand otherthing like
int*(int*)* f;
convention is man-made, it doesn't mean it could not be changed.
I am not here to replace C language.
Re: semi-new language & compiler for test.
Like I said, I don't see the advantage, but I don't see why you shouldn't design your own language either. I wish you good luck. Post some documentation if you like.
Re: semi-new language & compiler for test.
the most difference is the declaration syntax.Hobbes wrote:Like I said, I don't see the advantage, but I don't see why you shouldn't design your own language either. I wish you good luck. Post some documentation if you like.
typelist variablelist;
left side is type declarator, right side is identifier. pretty simple.
I haven't finished any documents yet. but the compiler has finished for 1 year, with x86 mips ppc cross compilation available.