Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > cdecl test cases

Reply
Thread Tools

cdecl test cases

 
 
Tor Rustad
Guest
Posts: n/a
 
      03-21-2005
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?

--
Tor <torust AT online DOT no>


 
Reply With Quote
 
 
 
 
tigervamp
Guest
Posts: n/a
 
      03-22-2005

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

 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      03-22-2005
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
>
> 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);


--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

 
Reply With Quote
 
Tor Rustad
Guest
Posts: n/a
 
      03-22-2005
"CBFalconer" <(E-Mail Removed)> wrote in message

<snip>

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

--
Tor <torust AT online DOT no>

 
Reply With Quote
 
Tor Rustad
Guest
Posts: n/a
 
      03-22-2005
"tigervamp" <(E-Mail Removed)> wrote in message

<snip>

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

> > Does someone have ideas for more test-cases?

>
> 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/dev...ecl-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>

--
Tor <torust AT online DOT no>

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-22-2005
Tor Rustad wrote:
>
> "CBFalconer" <(E-Mail Removed)> wrote in message
>
> <snip>
>
> > 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

--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

 
Reply With Quote
 
Kevin D. Quitt
Guest
Posts: n/a
 
      03-22-2005
Version 2.5 source, test cases, and executable for Winblows:

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


--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-23-2005
"Kevin D. Quitt" wrote:
>
> 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.

--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


 
Reply With Quote
 
Kevin D. Quitt
Guest
Posts: n/a
 
      03-24-2005
On Wed, 23 Mar 2005 05:05:29 GMT, CBFalconer <(E-Mail Removed)> wrote:
>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.


--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-25-2005
"Kevin D. Quitt" wrote:
> CBFalconer <(E-Mail Removed)> wrote:
>
>> 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.


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

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cdecl shanti C Programming 12 06-08-2007 06:33 AM
Original authors and licensing of cdecl / c++decl richard.wm.jones@gmail.com C Programming 5 03-14-2007 04:23 PM
Home server cases and external firewire cases thingy@nowhere.commy NZ Computing 5 03-14-2006 07:56 AM
help with 'left-right' cdecl rule James Brown [MVP] C Programming 6 02-14-2006 04:18 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments