Tor Rustad wrote:
> Did a fun project some years ago.. a cdecl, but never really tested
it.
>
> Here are some test cases I just tried:
>
> cdecl> char **argv;
> cdecl> argv is pointer to pointer to char
> Looks ok
>
> cdecl> int (*daytab)[13];
> cdecl> daytab is pointer to array [13] of int
> Looks ok
>
> cdecl> int *daytab[13];
> cdecl> daytab is array [13] of pointer to int
> Looks ok
>
> cdecl> void *comp();
> cdecl> comp is function returning pointer to void
> Looks ok
>
> cdecl> char (*(*x())[])();
> cdecl> x is function returning pointer to array of pointer to
function
> returning char
> Looks ok
>
> cdecl> char (*(*x[3])())[5];
> cdecl> x is array [3] of pointer to function returning pointer to
array
> [5] of char
> Looks ok
>
> cdecl> char* const *(*next)();
> cdecl> next is pointer to function returning pointer to (read-only)
> pointer to char
> Parse error: ";" at line 255. Hint: Not a valid type.
> Looks ok, except for the parse error.
>
> cdecl> char **(c[10])(int **p);
> cdecl> c is array [10] of function returning pointer to pointer to
char
> Looks ok
>
> cdecl> void (*signal(int sig, void (*func)(int)))(int);
> cdecl> signal is function returning pointer to void
> cdecl> void (*signal(int, void (*)(int)))(int);
> cdecl> signal is function returning pointer to void
> Not ok
My cdecl shows:
cdecl> explain void (*signal(int sig, void (*func)(int)))(int);
syntax error
I don't think the version of cdecl that I have handles multiple
identifiers in a single declaration (signal and func in this case).
cdecl> explain void (*signal(int, void (*)(int)))(int);
declare signal as function (int, pointer to function (int) returning
void) returning pointer to function (int) returning void
Look good.
> Did I miss something here, or do people agree with the above?
> (I don't have another cdecl to cross-check with)
>
> Does someone have ideas for more test-cases?
The version I have is very capable and featureful and supports readline
if you have it. It was written for Linux but should be easy to port to
similiar systems. You can download the source code package, which
comes with a mini test quite, at:
http://www.ibiblio.org/pub/Linux/dev...ecl-2.5.tar.gz.
> --
> Tor <torust AT online DOT no>
Rob Gamble