cdecl test cases

T

Tor Rustad

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

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?
 
T

tigervamp

Tor said:
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/devel/lang/c/cdecl-2.5.tar.gz.

Rob Gamble
 
C

CBFalconer

Tor said:
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

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?

Here are the results on my system

[1] c:\c\junk>cdecl cdecl.c
declare argv as pointer to pointer to char
declare daytab as pointer to array 13 of int
declare daytab as array 13 of pointer to int
declare comp as function returning pointer to void
declare x as function returning pointer to array of pointer to
function returning char
declare x as array 3 of pointer to function returning pointer to
array 5 of char
declare next as pointer to function returning pointer to const
pointer to char
parse error
parse error
declare signal as function (int, pointer to function (int)
returning void) returning pointer to function (int) returning void

[1] c:\c\junk>cat cdecl.c
explain char **argv;
explain int (*daytab)[13];
explain int *daytab[13];
explain void *comp();
explain char (*(*x())[])();
explain char (*(*x[3])())[5];
explain char* const *(*next)();
explain char **(c[10])(int **p);
explain void (*signal(int sig, void (*func)(int)))(int);
explain void (*signal(int, void (*)(int)))(int);
 
T

Tor Rustad

Here are the results on my system

[1] c:\c\junk>cdecl cdecl.c
declare argv as pointer to pointer to char
declare daytab as pointer to array 13 of int
declare daytab as array 13 of pointer to int
declare comp as function returning pointer to void
declare x as function returning pointer to array of pointer to
function returning char
declare x as array 3 of pointer to function returning pointer to
array 5 of char
declare next as pointer to function returning pointer to const
pointer to char
parse error
parse error
declare signal as function (int, pointer to function (int)
returning void) returning pointer to function (int) returning void

[1] c:\c\junk>cat cdecl.c
explain char **argv;
explain int (*daytab)[13];
explain int *daytab[13];
explain void *comp();
explain char (*(*x())[])();
explain char (*(*x[3])())[5];
explain char* const *(*next)();
explain char **(c[10])(int **p);
explain void (*signal(int sig, void (*func)(int)))(int);
explain void (*signal(int, void (*)(int)))(int);

Thanks! Does

explain char **(c[10])(int **);

also give a parse error?
 
T

Tor Rustad

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).

Right, IMHO that would be useful for cdecl to handle.
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.

Yup, agreed.
The version I have is very capable and featureful and supports readline
if you have it.

Windows box here, which lack readline, yacc and flex!!
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/devel/lang/c/cdecl-2.5.tar.gz.

Took a look at the package, and it was far more advanced than my
little C utility (850 lines of yacc code vs 200 lines of C parser code).
For now, I only want to get 'explain' working with C89 (and C99).

I see one main thing for me to add then, and that is to parse/display
the argument list of functions... <g>
 
C

CBFalconer

Tor said:
Here are the results on my system

[1] c:\c\junk>cdecl cdecl.c
declare argv as pointer to pointer to char
declare daytab as pointer to array 13 of int
declare daytab as array 13 of pointer to int
declare comp as function returning pointer to void
declare x as function returning pointer to array of pointer to
function returning char
declare x as array 3 of pointer to function returning pointer to
array 5 of char
declare next as pointer to function returning pointer to const
pointer to char
parse error
parse error
declare signal as function (int, pointer to function (int)
returning void) returning pointer to function (int) returning void

[1] c:\c\junk>cat cdecl.c
explain char **argv;
explain int (*daytab)[13];
explain int *daytab[13];
explain void *comp();
explain char (*(*x())[])();
explain char (*(*x[3])())[5];
explain char* const *(*next)();
explain char **(c[10])(int **p);
explain void (*signal(int sig, void (*func)(int)))(int);
explain void (*signal(int, void (*)(int)))(int);

Thanks! Does

explain char **(c[10])(int **);

also give a parse error?

[1] c:\dnld\scratch>explain char **(c[10])(int **);
declare c as array 10 of function (pointer to pointer to int)
returning pointer
to pointer to char
 
K

Kevin D. Quitt

Version 2.5 source, test cases, and executable for Winblows:

<ftp://ftp.quitt.net/C/cdecl.zip>
 
C

CBFalconer

Kevin D. Quitt said:
Version 2.5 source, test cases, and executable for Winblows:

<ftp://ftp.quitt.net/C/cdecl.zip>

Minor detail - that has been zipped with something outlandish, and
neither unzip (info-zip 5.51) nor pkunzip (katz 2.50) can extract
it.
 
K

Kevin D. Quitt

Minor detail - that has been zipped with something outlandish, and
neither unzip (info-zip 5.51) nor pkunzip (katz 2.50) can extract
it.

My apologies. I used PKZIP originally; rezipped with gnu zip 2.3.
 
C

CBFalconer

Kevin D. Quitt said:
My apologies. I used PKZIP originally; rezipped with gnu zip 2.3.

Of course you snipped the URL, so now I don't know where to go for
it any more :)
 
C

CBFalconer

CBFalconer said:
Of course you snipped the URL, so now I don't know where to go for
it any more :)

And now I found the old URL, redownloaded it, and you omitted the
makefile!
 
M

Michael Mair

CBFalconer said:
And now I found the old URL, redownloaded it, and you omitted the
makefile!

My, you are one hard to satisfy customer...
Next time he will have to go for the closet in the basement ;-)


Cheers
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top