home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cproto.zip / cproto46 / testing / syntax.c < prev    next >
C/C++ Source or Header  |  1994-09-23  |  5KB  |  284 lines

  1. /*
  2.  * Define:
  3.  *    ERR_YACC    to force yacc error reporting
  4.  *    ERR_LEX        to force lex error reporting
  5.  *    ERR_CHECK    to force compiler error reporting
  6.  */
  7.         /* use one item from type-specifiers */
  8. #ifdef    ERR_YACC
  9. auto        x;
  10. register    x1;
  11. #endif    ERR_YACC
  12. static        x2;
  13. extern        x3;
  14. #ifdef    ERR_CC
  15. typedef        x4;
  16. #endif
  17. typedef    int    x4t;
  18. #ifdef    ERR_YACC
  19. void        x5;
  20. #endif    ERR_YACC
  21. char        x6;
  22. short        x7;
  23. int        x8;
  24. long        x9;
  25. float        x10;
  26. double        x11;
  27. signed        x12;
  28. unsigned    x13;
  29. struct        x14;
  30. #ifdef    ERR_CHECK
  31. struct        x14a {};
  32. struct        {};
  33. #endif    ERR_CHECK
  34. union        x15;
  35. enum        x16;
  36. x4t;
  37. x4t        x17;
  38. const        x18;
  39. volatile    x19;
  40. #ifdef    ERR_CHECK
  41. junk        x20;
  42. #endif    ERR_CHECK
  43.  
  44. typedef    struct    _first    {
  45.     int        a:5;
  46.     struct    {
  47.         int    a,b;
  48.     } b_struct;
  49.     char        b:16, b1:1;    /* comment with };};}; */
  50.     long        c:16, c1;
  51.     short        d:16, d1:8, d2;
  52.     unsigned    e:16;
  53.     float        f;
  54.     double        g;
  55. #ifdef    ERR_CHECK
  56.     long    float    f2;
  57.     long    double    g2;
  58. #endif    ERR_CHECK
  59.     struct    _first    *link;
  60.     }    _FIRST;
  61.  
  62. _FIRST    first, last={0}, first_last[] = {{0},{1},{2},{3,{4}}};
  63.  
  64. struct    _second    {
  65.         enum    {true, false} bool;
  66.         enum    {wrong=1, right=3} values;
  67.     } _SECOND;
  68.  
  69. int    i[] = {1,
  70.         '\002',
  71.         03,
  72.         0x4,
  73.         0X5,
  74.         0x6a,
  75.         0X7b,
  76.         0x8aBcD,
  77.         9l,
  78.         10l,
  79.         11L};
  80. float    f[] = {5,
  81. #ifdef    ERR_CHECK
  82.         .5,
  83.         .5e,
  84.         .5e+,
  85.         5e-,
  86.         5e,
  87. #endif
  88.         5.5,
  89.         5e5,
  90.         5e0,
  91.         5e-1,
  92.         5e+5
  93.         };
  94.  
  95. int    array[][10][20];
  96.  
  97.     /*
  98.      * This grammar can accept some illegal stuff too, in particular it will
  99.      * permit some instances of parameter-names to be dropped.
  100.      */
  101. #ifdef    ERR_CHECK
  102. #define    P1
  103. #define    P2
  104. #define    P3
  105. #else
  106. #define    P1    p1
  107. #define    P2    p2
  108. #define    P3    p3
  109. #endif
  110.  
  111.     /* ellipsis is legal, except in K&R style declaration */
  112.  
  113.     dots_0(p1)        { return(1); }
  114.  
  115.     dots_1(int p1, ...)    { return(1); }
  116.  
  117. #ifdef    ERR_CHECK
  118.     dots_2(p1, ...)        { return(1); }
  119. #endif    ERR_CHECK
  120.  
  121.     dots_3(int P1,char P2, ...)    { return(1); }
  122.  
  123. int    dots_4(int,char, char *);
  124. char *    dots_5(int,char, char *, ...);
  125.  
  126. extern    _FIRST *xdots_0(p1);
  127.  
  128. extern    char *xdots_1(int p1, ...);
  129.  
  130. #ifdef    ERR_CHECK
  131. extern    xdots_2(p1, ...);
  132. #endif    ERR_CHECK
  133.  
  134. extern    xdots_3(int P1,char P2, ...);
  135.  
  136. _FIRST    *func1() { }
  137. _FIRST    *func2(_FIRST *P1,int P2[],float p) { }
  138.  
  139. int    *(func_func)(
  140. #ifdef    ERR_CHECK
  141. p1,p2,p3
  142. #endif    ERR_CHECK
  143. )    { return(0); }
  144.  
  145. extern    float    efunc0(p1,p2,p3);
  146. extern    _FIRST    efunc1(int p1, float p2,long P3);
  147. #ifdef    ERR_CHECK
  148. extern    _FIRST    efunc1(int p1, float p2,p3);
  149. #endif    ERR_CHECK
  150.  
  151.  
  152. typedef    int    bool;
  153.  
  154. bool    a1;
  155. static    bool    a2;
  156. extern    bool    a3;
  157.  
  158. struct    ZIP1    { int x1, y1; };
  159. struct    zip2    { int x2, y2; } z2;
  160. struct        { int x3, y3; } z3;    /* not ANSI, but mostly accepted */
  161.  
  162. static    struct    ZIP4    { int x4, y4; };
  163. static    struct    zip5    { int x5, y5; } z5;
  164. static    struct    zip6    { int x6, y6; } z6, w6;
  165. static    struct        { int x7, y7; } z7;
  166. static    struct        { int x8, y8; } z8, w8;
  167.  
  168. enum    zap1    { a,b,c,d }    what;
  169. enum    zap2            what2;
  170. enum        {a9,b9,c9,d9}    what3;
  171.  
  172. static    char    *zap = "alphabet/\
  173. first/\
  174. last";
  175. typedef    struct    bong    {
  176.     int    (*func)();
  177.     } BONG;
  178.  
  179. typedef    char    *string;
  180.  
  181. #ifdef    ERR_LEX
  182. string    s = "aaa\0000\
  183.  
  184. bbb";
  185. #endif    ERR_LEX
  186.  
  187. extern    int    junk;
  188.  
  189. main(argc, argv)
  190. register argc;
  191. #ifdef    ERR_CHECK
  192. extern
  193. #endif    ERR_CHECK
  194. char    **argv;
  195. {
  196. }
  197.  
  198. /*VARARGS*/
  199. /* some other comment */
  200. veryfunny(a,b,c)
  201. char *a;
  202. long b, c;
  203. {
  204.     return 0;
  205. }
  206.  
  207. /*VARARGS3*/
  208. program(argv, y, zz, z1, z2, z3)
  209. string    argv[];    /* first argument */
  210. struct    alpha { int x,z; } y;    /* second argument */
  211. {
  212.     return(0);
  213. }
  214.  
  215. junk0() { if(junk != 6) return; else junk++; }
  216. junk1() { return (0); }
  217. junk2() { }
  218. junk3() { return 1; }
  219.  
  220. BONG    *junk4() { }
  221.  
  222. typedef    int    extern_junk;
  223. extern_junk    *foo() { }
  224.  
  225. typedef    int    void_junk;
  226. extern void_junk    *foo2a() { }
  227. extern void_junk    *foo2a();
  228. void_junk    *foo2() { }
  229. void_junk    *foo_void(void_junk void_int) { }
  230. static    void_junk    *foo_void2() { }
  231.  
  232. extern void (*sigdisp(int sig, void (*func)(int sig)))(int sig);
  233.  
  234. void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1)
  235. { /* nothing */ }
  236.  
  237. void (*sigdisp2(sig, func))(int sig2)
  238.     int sig;        /* the signal value */
  239.     void (*func)(int sig);    /* the function pointer */
  240. { /* nothing again! */ }
  241.  
  242. int (*K_R_INT_ptr(p1, p2))() long *p1; int p2; { return (*(int(*)())0); }
  243.  
  244. int (*STD_INT_ptr(long* , int))();
  245.  
  246. void (*K_R_VOID_ptr(p1,p2))() long *p1; int p2; { return (*(void(*)())0); }
  247.  
  248. void (*STD_VOID_ptr(long* , int))();
  249.  
  250. int *K_R_int_ptr(p1,p2) long *p1; int p2; { return (*(int **)0); }
  251.  
  252. int **STD_int2_ptr(long* , int);
  253.  
  254. int *STD_int_ptr(long* , int);
  255.  
  256. void *K_R_void_ptr(p1,p2) long *p1; int p2; { return (*(void **)0); }
  257.  
  258. void *STD_void_ptr(long* , int);
  259.  
  260. int K_R_int_val(p1,p2) long *p1; int p2; { return (*(int *)0); }
  261.  
  262. K_R_int_val2(p1,p2) long *p1; int p2; { return (*(int *)0); }
  263.  
  264. int STD_int_val(long*, int);
  265.  
  266. void K_R_void_val(p1,p2) long *p1; int p2; { /*void*/ }
  267.  
  268. K_R_void_val2(p1,p2) long *p1; int p2; { /*void*/ }
  269.  
  270. void STD_void_val(long* , int);
  271.  
  272. extern    xdots_3(int P1,char P2, ...);
  273.  
  274. extern int (*XSetAfterFunction(long* , int (*) ( long*)))();
  275. extern XQueryKeymap(long*, char [32]);
  276. extern Another(long*, int (*)());
  277.  
  278. extern GenFunc(int *, int *());
  279.  
  280. /* these are pointers, not actual functions */
  281. extern void * (*__glob_opendir_hook) (const char *__directory);
  282. extern const char *(*__glob_readdir_hook) (void * __stream);
  283. extern void (*__glob_closedir_hook) (void * __stream);
  284.