|
|
1.1 root 1: /* rosy.c - RO stub-generator (yacc-based) */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/rosy/RCS/rosy.c,v 7.3 90/07/01 21:06:20 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/rosy/RCS/rosy.c,v 7.3 90/07/01 21:06:20 mrose Exp $
9: *
10: *
11: * $Log: rosy.c,v $
12: * Revision 7.3 90/07/01 21:06:20 mrose
13: * pepsy
14: *
15: * Revision 7.2 90/01/27 10:27:17 mrose
16: * touch-up
17: *
18: * Revision 7.1 90/01/11 18:37:50 mrose
19: * real-sync
20: *
21: * Revision 7.0 89/11/23 22:21:50 mrose
22: * Release 6.0
23: *
24: */
25:
26: /*
27: * NOTICE
28: *
29: * Acquisition, use, and distribution of this module and related
30: * materials are subject to the restrictions of a license agreement.
31: * Consult the Preface in the User's Manual for the full terms of
32: * this agreement.
33: *
34: */
35:
36:
37: #include <ctype.h>
38: #include <stdio.h>
39: #include <varargs.h>
40: #define pepyversion rosyversion
41: #include "rosy-defs.h"
42: #include "../pepsy/pass2.h"
43:
44: /* DATA */
45:
46: int Cflag = 0; /* rosy */
47: int dflag = 0;
48: int Pflag = 0; /* pepy compat... */
49: int Pepsyflag = 0; /* Pepsy compatability */
50: int Defsflag = 0; /* Produce #define function names for Pepsy */
51: int doexternals;
52: static int linepos = 0;
53: static int mflag = 0;
54: static int rosydebug = 0;
55: char *bflag = NULLCP;
56: static int sflag = 0;
57:
58: static char *eval = NULLCP;
59:
60: char *mymodule = "";
61: static char *mymodulename = NULL;
62: static char mymodaux[BUFSIZ];
63: static char oplistorig[BUFSIZ];
64: #define NOPS 128
65: static char *opvp[NOPS];
66: static int opvc;
67: OID mymoduleid;
68:
69: int yysection = NULL;
70: char *yyencpref = "none";
71: char *yydecpref = "none";
72: char *yyprfpref = "none";
73: char *yyencdflt = "none";
74: char *yydecdflt = "none";
75: char *yyprfdflt = "none";
76:
77: static char *yymode = "";
78:
79: static char *classes[] = {
80: "UNIVERSAL ",
81: "APPLICATION ",
82: "",
83: "PRIVATE "
84: };
85:
86: static char autogen[BUFSIZ];
87:
88: char *sysin = NULLCP;
89: static char sysout[BUFSIZ];
90: static char sysdef[BUFSIZ];
91: static char systbl[BUFSIZ];
92: static char systub[BUFSIZ];
93:
94: static FILE *fdef;
95: static FILE *ftbl;
96: static FILE *fstb;
97:
98: typedef struct symlist {
99: char *sy_encpref;
100: char *sy_decpref;
101: char *sy_prfpref;
102: char *sy_module;
103: char *sy_name;
104:
105: union {
106: YO sy_un_op;
107:
108: YE sy_un_err;
109:
110: YP sy_un_type;
111: } sy_un;
112: #define sy_op sy_un.sy_un_op
113: #define sy_err sy_un.sy_un_err
114: #define sy_type sy_un.sy_un_type
115:
116: struct symlist *sy_next;
117: } symlist, *SY;
118: #define NULLSY ((SY) 0)
119:
120: static SY myoperations = NULLSY;
121:
122: static int erroff = 0;
123: static SY myerrors = NULLSY;
124:
125: static SY mytypes = NULLSY;
126:
127:
128: char *modsym ();
129: char *cmodsym ();
130: char *csymmod ();
131: SY new_symbol (), add_symbol ();
132:
133: YE lookup_err ();
134: YP lookup_type ();
135:
136: /* MAIN */
137:
138: /* ARGSUSED */
139:
140: main (argc, argv, envp)
141: int argc;
142: char **argv,
143: **envp;
144: {
145: register char *cp,
146: *sp;
147:
148: fprintf (stderr, "%s\n", rosyversion);
149:
150: sysout[0] = sysdef[0] = systbl[0] = systub[0] = NULL;
151: for (argc--, argv++; argc > 0; argc--, argv++) {
152: cp = *argv;
153:
154: if (strcmp (cp, "-pepsy") == 0) {
155: Pepsyflag++;
156: continue;
157: }
158: if (strcmp (cp, "-defs") == 0) {
159: Defsflag++;
160: continue;
161: }
162: if (strcmp (cp, "-d") == 0) {
163: dflag++;
164: continue;
165: }
166: if (strcmp (cp, "-m") == 0) {
167: mflag++;
168: continue;
169: }
170: if (strcmp (cp, "-o") == 0) {
171: if (sysout[0]) {
172: fprintf (stderr, "too many output files\n");
173: exit (1);
174: }
175: argc--, argv++;
176: if ((cp = *argv) == NULL || (*cp == '-' && cp[1] != NULL))
177: goto usage;
178: (void) strcpy (sysout, cp);
179:
180: continue;
181: }
182: if (strcmp (cp, "-b") == 0) {
183: if (bflag) {
184: fprintf (stderr, "too many prefixes\n");
185: exit (1);
186: }
187: argc--, argv++;
188: if ((bflag = *argv) == NULL || *bflag == '-')
189: goto usage;
190: continue;
191: }
192: if (strcmp (cp, "-s") == 0) {
193: sflag++;
194: continue;
195: }
196: if (strcmp (cp, "-T") == 0) {
197: if (mymodulename) {
198: fprintf (stderr, "too many table names\n");
199: exit (1);
200: }
201: argc --; argv ++;
202: if ((mymodulename = *argv) == NULL || *mymodulename == '-')
203: goto usage;
204: continue;
205: }
206: if (strcmp (cp, "-O") == 0) {
207: argc --; argv ++;
208: if ((cp = *argv) == NULL || (*cp == '-'))
209: goto usage;
210: if (oplistorig[0])
211: (void) strcat (oplistorig, cp);
212: else
213: (void) strcpy (oplistorig, cp);
214: continue;
215: }
216:
217: if (sysin) {
218: usage: ;
219: fprintf (stderr,
220: "usage: rosy [-pepsy] [-d] [-o module.py] [-s] module.ry\n");
221: exit (1);
222: }
223:
224: if (*cp == '-') {
225: if (*++cp != NULL)
226: goto usage;
227: sysin = "";
228: }
229: sysin = cp;
230:
231: if (sysout[0])
232: continue;
233: if (sp = rindex (cp, '/'))
234: sp++;
235: if (sp == NULL || *sp == NULL)
236: sp = cp;
237: sp += strlen (cp = sp) - 3;
238: if (sp > cp && strcmp (sp, ".ry") == 0)
239: (void) sprintf (sysout, "%.*s.py", sp - cp, cp);
240: else
241: (void) sprintf (sysout, "%s.py", cp);
242: }
243:
244: switch (rosydebug = (cp = getenv ("ROSYTEST")) && *cp ? atoi (cp) : 0) {
245: case 2:
246: yydebug++; /* fall */
247: case 1:
248: sflag++; /* .. */
249: case 0:
250: break;
251: }
252:
253: if (sysin == NULLCP)
254: sysin = "";
255:
256: if (*sysin && freopen (sysin, "r", stdin) == NULL) {
257: fprintf (stderr, "unable to read "), perror (sysin);
258: exit (1);
259: }
260:
261: if (strcmp (sysout, "-") == 0)
262: sysout[0] = NULL;
263: if (*sysout && freopen (sysout, "w", stdout) == NULL) {
264: fprintf (stderr, "unable to write "), perror (sysout);
265: exit (1);
266: }
267:
268: if (cp = index (rosyversion, ')'))
269: for (cp++; *cp != ' '; cp++)
270: if (*cp == NULL) {
271: cp = NULL;
272: break;
273: }
274: if (cp == NULL)
275: cp = rosyversion + strlen (rosyversion);
276: (void) sprintf (autogen, "%*.*s",
277: cp - rosyversion, cp - rosyversion, rosyversion);
278: printf ("-- automatically generated by %s, do not edit!\n\n", autogen);
279:
280: initoidtbl ();
281:
282: exit (yyparse ()); /* NOTREACHED */
283: }
284:
285: /* ERRORS */
286:
287: yyerror (s)
288: register char *s;
289: {
290: yyerror_aux (s);
291:
292: if (*sysout)
293: (void) unlink (sysout);
294: if (*sysdef)
295: (void) unlink (sysdef);
296: if (*systbl)
297: (void) unlink (systbl);
298: if (*systub)
299: (void) unlink (systub);
300:
301: exit (1);
302: }
303:
304: #ifndef lint
305: warning (va_alist)
306: va_dcl
307: {
308: char buffer[BUFSIZ];
309: char buffer2[BUFSIZ];
310: char *cp;
311: va_list ap;
312:
313: va_start (ap);
314:
315: _asprintf (buffer, NULLCP, ap);
316:
317: va_end (ap);
318:
319: (void) sprintf (buffer2, "Warning: %s", buffer);
320: yyerror_aux (buffer2);
321: }
322:
323: #else
324:
325: /* VARARGS1 */
326: warning (fmt)
327: char *fmt;
328: {
329: warning (fmt);
330: }
331: #endif
332:
333: static yyerror_aux (s)
334: register char *s;
335: {
336: if (linepos)
337: fprintf (stderr, "\n"), linepos = 0;
338:
339: if (eval)
340: fprintf (stderr, "%s %s: ", yymode, eval);
341: else
342: fprintf (stderr, "line %d: ", yylineno);
343: fprintf (stderr, "%s\n", s);
344: if (!eval)
345: fprintf (stderr, "last token read was \"%s\"\n", yytext);
346: }
347:
348: /* */
349:
350: #ifndef lint
351: myyerror (va_alist)
352: va_dcl
353: {
354: char buffer[BUFSIZ];
355: va_list ap;
356:
357: va_start (ap);
358:
359: _asprintf (buffer, NULLCP, ap);
360:
361: va_end (ap);
362:
363: yyerror (buffer);
364: }
365: #else
366: /* VARARGS */
367:
368: myyerror (fmt)
369: char *fmt;
370: {
371: myyerror (fmt);
372: }
373: #endif
374:
375: #ifdef notyet
376: #ifndef lint
377: static pyyerror (va_alist)
378: va_dcl
379: {
380: char buffer[BUFSIZ];
381: register YP yp;
382:
383: va_start (ap);
384:
385: yp = va_arg (ap, YP);
386:
387: _asprintf (buffer, NULLCP, ap);
388:
389: va_end (ap);
390:
391: yyerror_aux (buffer);
392: print_type (yp, 0);
393:
394: if (*sysout)
395: (void) unlink (sysout);
396: if (*sysdef)
397: (void) unlink (sysdef);
398: if (*systbl)
399: (void) unlink (systbl);
400: if (*systub)
401: (void) unlink (systub);
402:
403: exit (1);
404: }
405: #else
406: /* VARARGS */
407: +
408: static pyyerror (yp, fmt)
409: YP yp;
410: char *fmt;
411: {
412: pyyerror (yp, fmt);
413: }
414: #endif
415: #endif
416:
417: /* */
418:
419: yywrap () {
420: if (linepos)
421: fprintf (stderr, "\n"), linepos = 0;
422:
423: return 1;
424: }
425:
426: /* */
427:
428: /* ARGSUSED */
429:
430: yyprint (s, f, top)
431: char *s;
432: int f,
433: top;
434: {
435: }
436:
437: static yyprint_aux (s, mode)
438: char *s,
439: *mode;
440: {
441: int len;
442: static int nameoutput = 0;
443: static int outputlinelen = 79;
444:
445: if (sflag)
446: return;
447:
448: if (strcmp (yymode, mode)) {
449: if (linepos)
450: fprintf (stderr, "\n\n");
451:
452: fprintf (stderr, "%s", mymodule);
453: nameoutput = (linepos = strlen (mymodule)) + 1;
454:
455: fprintf (stderr, " %ss", yymode = mode);
456: linepos += strlen (yymode) + 1;
457: fprintf (stderr, ":");
458: linepos += 2;
459: }
460:
461: len = strlen (s);
462: if (linepos != nameoutput)
463: if (len + linepos + 1 > outputlinelen)
464: fprintf (stderr, "\n%*s", linepos = nameoutput, "");
465: else
466: fprintf (stderr, " "), linepos++;
467: fprintf (stderr, "%s", s);
468: linepos += len;
469: }
470:
471: /* PASS1 */
472:
473: pass1 ()
474: {
475: printf ("%s ", mymodule);
476: if (mymoduleid)
477: printf ("%s ", oidprint(mymoduleid));
478: printf ("DEFINITIONS ::=\n\n");
479: }
480:
481: /* */
482:
483: pass1_op (mod, id, arg, result, errors, linked, opcode)
484: char *mod,
485: *id;
486: YP arg,
487: result;
488: YV errors;
489: YV linked;
490: int opcode;
491: {
492: register SY sy;
493: register YO yo;
494:
495: if ((yo = (YO) calloc (1, sizeof *yo)) == NULLYO)
496: yyerror ("out of memory");
497:
498: yo -> yo_name = id;
499: yo -> yo_arg = arg;
500: yo -> yo_result = result;
501: yo -> yo_errors = errors;
502: yo -> yo_linked = linked;
503: yo -> yo_opcode = opcode;
504:
505: if (rosydebug) {
506: if (linepos)
507: fprintf (stderr, "\n"), linepos = 0;
508:
509: fprintf (stderr, "%s.%s\n", mod ? mod : mymodule, id);
510: print_op (yo, 0);
511: fprintf (stderr, "--------\n");
512: }
513: else
514: yyprint_aux (id, "operation");
515:
516: sy = new_symbol (NULLCP, NULLCP, NULLCP, mod, id);
517: sy -> sy_op = yo;
518: myoperations = add_symbol (myoperations, sy);
519: }
520:
521: /* */
522:
523: pass1_err (mod, id, param, errcode)
524: char *mod,
525: *id;
526: YP param;
527: int errcode;
528: {
529: register SY sy;
530: register YE ye;
531:
532: if ((ye = (YE) calloc (1, sizeof *ye)) == NULLYE)
533: yyerror ("out of memory");
534:
535: ye -> ye_name = id;
536: ye -> ye_param = param;
537: ye -> ye_errcode = errcode;
538: ye -> ye_offset = erroff++;
539:
540: if (rosydebug) {
541: if (linepos)
542: fprintf (stderr, "\n"), linepos = 0;
543:
544: fprintf (stderr, "%s.%s\n", mod ? mod : mymodule, id);
545: print_err (ye, 0);
546: fprintf (stderr, "--------\n");
547: }
548: else
549: yyprint_aux (id, "error");
550:
551: sy = new_symbol (NULLCP, NULLCP, NULLCP, mod, id);
552: sy -> sy_err = ye;
553: myerrors = add_symbol (myerrors, sy);
554: }
555:
556: /* */
557:
558: pass1_type (encpref, decpref, prfpref, mod, id, yp)
559: register char *encpref,
560: *decpref,
561: *prfpref,
562: *mod,
563: *id;
564: register YP yp;
565: {
566: register SY sy;
567:
568: if (dflag && lookup_type (mod, id)) /* no duplicate entries, please... */
569: return;
570:
571: if (rosydebug) {
572: if (linepos)
573: fprintf (stderr, "\n"), linepos = 0;
574:
575: fprintf (stderr, "%s.%s\n", mod ? mod : mymodule, id);
576: print_type (yp, 0);
577: fprintf (stderr, "--------\n");
578: }
579: else
580: if (!(yp -> yp_flags & YP_IMPORTED))
581: yyprint_aux (id, "type");
582:
583: sy = new_symbol (encpref, decpref, prfpref, mod, id);
584: sy -> sy_type = yp;
585: mytypes = add_symbol (mytypes, sy);
586: }
587:
588: /* PASS2 */
589:
590: pass2 () {
591: int i;
592: register SY sy,
593: sy2;
594: register YP yp;
595:
596: if (!bflag)
597: bflag = mymodule;
598: if (!sflag)
599: (void) fflush (stderr);
600:
601: if(!mymodulename)
602: mymodulename = mymodule;
603: modsym_aux (mymodulename, mymodaux);
604: if (oplistorig[0]) {
605: opvc = sstr2arg (oplistorig, NOPS, opvp, ", \n");
606: if (opvc < 0)
607: opvc = 0;
608: }
609:
610: (void) sprintf (sysdef, "%s-ops.h", bflag);
611: if ((fdef = fopen (sysdef, "w")) == NULL)
612: myyerror ("unable to write %s", sysdef);
613: fprintf (fdef, "/* automatically generated by %s, do not edit! */\n\n",
614: autogen);
615: (void) sprintf (systbl, "%s-ops.c", bflag);
616: if ((ftbl = fopen (systbl, "w")) == NULL)
617: myyerror ("unable to write %s", systbl);
618: fprintf (ftbl, "/* automatically generated by %s, do not edit! */\n\n",
619: autogen);
620:
621: if (!Pepsyflag) {
622: fprintf (fdef, "#include %s\n\n\n",
623: mflag ? "\"rosy.h\"" : "<isode/rosy.h>");
624: } else {
625: fprintf (ftbl, "#include \"%s-types.h\"\n\n", bflag); /* XXX */
626: fprintf (fdef, "#include %s\n\n\n",
627: mflag ? "\"rosy.h\"" : "<isode/rosy.h>");
628: }
629:
630: fprintf (ftbl, "#include <stdio.h>\n");
631: fprintf (ftbl, "#include \"%s\"\n\n\n", sysdef);
632: if (!Pepsyflag) {
633: fprintf (ftbl, "#include \"%s-types.h\"\n\n", bflag); /* XXX */
634: }
635:
636: (void) sprintf (systub, "%s-stubs.c", bflag);
637: if ((fstb = fopen (systub, "w")) == NULL)
638: myyerror ("unable to write %s", systbl);
639: fprintf (fstb, "/* automatically generated by %s, do not edit! */\n\n",
640: autogen);
641: fprintf (fstb, "#include <stdio.h>\n");
642: fprintf (fstb, "#include \"%s\"\n", sysdef);
643: fprintf (fstb, "#include \"%s-types.h\"\n\n", bflag); /* XXX */
644:
645: fprintf (fdef, "\t\t\t\t\t/* OPERATIONS */\n\n");
646: fprintf (fdef, "extern struct RyOperation table_%s_Operations[];\n\n",
647: mymodaux);
648:
649: fprintf (ftbl, "\t\t\t\t\t/* OPERATIONS */\n\n");
650:
651: yymode = "operation";
652: for (sy = myoperations; sy; sy = sy -> sy_next) {
653: if (sy -> sy_module == NULLCP)
654: yyerror ("no module name associated with symbol");
655:
656: eval = sy -> sy_name;
657: if ((i = sy -> sy_op -> yo_opcode) < 0)
658: yyerror_aux ("negative operation code (warning)");
659: for (sy2 = sy -> sy_next; sy2; sy2 = sy2 -> sy_next)
660: if (i == sy2 -> sy_op -> yo_opcode) {
661: yyerror_aux ("non-unique operation codes (warning)");
662: fprintf (stderr, "\tvalue=%d op1=%s op2=%s\n", i,
663: sy -> sy_op -> yo_name, sy2 -> sy_op -> yo_name);
664: }
665: if (opvc) {
666: for (i = 0; i < opvc; i++)
667: if (strcmp (opvp[i], sy -> sy_op -> yo_name) == 0)
668: break;
669: if (i >= opvc)
670: continue;
671: }
672: do_op1 (sy -> sy_op, eval);
673: }
674:
675: fprintf (fdef, "\n#ifndef\tlint\n");
676: fprintf (fstb, "\n#ifdef\tlint\n");
677: fprintf (ftbl, "struct RyOperation table_%s_Operations[] = {\n", mymodaux);
678: for (sy = myoperations; sy; sy = sy -> sy_next) {
679: if (opvc) {
680: for (i = 0; i < opvc; i++)
681: if (strcmp (opvp[i], sy -> sy_op -> yo_name) == 0)
682: break;
683: if (i >= opvc)
684: continue;
685: }
686: do_op2 (sy -> sy_op, eval = sy -> sy_name);
687: }
688: fprintf (fdef, "#endif\n");
689: fprintf (fstb, "#endif\n");
690: fprintf (ftbl, " NULL\n};\n\n");
691:
692: fprintf (fdef, "\n\n\t\t\t\t\t/* ERRORS */\n\n");
693: fprintf (fdef, "extern struct RyError table_%s_Errors[];\n\n", mymodaux);
694:
695: fprintf (ftbl, "\n\t\t\t\t\t/* ERRORS */\n\n");
696:
697: yymode = "error";
698: for (sy = myerrors; sy; sy = sy -> sy_next) {
699: if (sy -> sy_module == NULLCP)
700: yyerror ("no module name associated with symbol");
701:
702: eval = sy -> sy_name;
703: if ((i = sy -> sy_err -> ye_errcode) < 0)
704: yyerror_aux ("negative error code (warning)");
705: for (sy2 = sy -> sy_next; sy2; sy2 = sy2 -> sy_next)
706: if (i == sy2 -> sy_err -> ye_errcode) {
707: yyerror_aux ("non-unique error codes (warning)");
708: fprintf (stderr, "\tvalue=%d err1=%s err2=%s\n", i,
709: sy -> sy_err -> ye_name, sy2 -> sy_err -> ye_name);
710: }
711: do_err1 (sy -> sy_err, eval);
712: }
713:
714: fprintf (ftbl, "struct RyError table_%s_Errors[] = {\n", mymodaux);
715: for (sy = myerrors; sy; sy = sy -> sy_next)
716: do_err2 (sy -> sy_err, eval = sy -> sy_name);
717: fprintf (ftbl, " NULL\n};\n");
718:
719: if (Cflag)
720: printf ("\n");
721: printf ("BEGIN\n");
722:
723: yymode = "type";
724: yyencpref = yydecpref = yyprfpref = "none";
725: for (sy = mytypes; sy; sy = sy -> sy_next) {
726: eval = sy -> sy_name;
727: yp = sy -> sy_type;
728: if (sy -> sy_module == NULLCP)
729: yyerror ("no module name associated with symbol");
730: if (yp -> yp_flags & YP_IMPORTED)
731: continue;
732:
733: if (!dflag) {
734: if (!(yp -> yp_direction & YP_ENCODER))
735: sy -> sy_encpref = "none";
736: if (!(yp -> yp_direction & YP_DECODER))
737: sy -> sy_decpref = "none";
738: if (!(yp -> yp_direction & YP_PRINTER))
739: sy -> sy_prfpref = "none";
740: if (strcmp (yyencpref, sy -> sy_encpref)
741: || strcmp (yydecpref, sy -> sy_decpref)
742: || strcmp (yyprfpref, sy -> sy_prfpref))
743: printf ("\nSECTIONS %s %s %s\n",
744: yyencpref = sy -> sy_encpref,
745: yydecpref = sy -> sy_decpref,
746: yyprfpref = sy -> sy_prfpref);
747: }
748: printf ("\n%s", sy -> sy_name);
749: if (yp -> yp_action0)
750: act2prf (yp -> yp_action0, 1, "\n%*s%%{", "%%}\n%*s");
751: else
752: printf (" ");
753: printf ("::=\n");
754: if (!dflag && !(yp -> yp_flags & YP_PULLEDUP) && yp -> yp_action1) {
755: act2prf (yp -> yp_action1, 1, "%*s%%{", "%%}\n");
756: yp -> yp_flags |= YP_PULLEDUP;
757: }
758: do_type (yp, (yp -> yp_flags & YP_TAG) ? 1 : 2, eval);
759: printf ("\n");
760:
761: if (ferror (stdout) || ferror (fdef) || ferror (ftbl) || ferror (fstb))
762: myyerror ("write error - %s", sys_errname (errno));
763:
764: }
765:
766: printf ("\nEND\n");
767:
768: (void) fflush (stdout);
769: (void) fflush (fdef);
770: (void) fclose (ftbl);
771: (void) fclose (fstb);
772:
773: if (ferror (stdout) || ferror (fdef) || ferror (ftbl) || ferror (fstb))
774: myyerror ("write error - %s", sys_errname (errno));
775:
776: (void) fclose (fdef);
777:
778: (void) fclose (ftbl);
779:
780: (void) fclose (fstb);
781: }
782:
783: /* */
784:
785: /* ARGSUSED */
786:
787: static do_op1 (yo, id)
788: register YO yo;
789: char *id;
790: {
791: register YE ye;
792: register YP yp;
793: register YV yv;
794:
795: fprintf (fdef, "\t\t\t\t\t/* OPERATION %s */\n", yo -> yo_name);
796: fprintf (fdef, "#define operation_%s\t%d\n\n",
797: modsym (mymodule, yo -> yo_name, NULLCP), yo -> yo_opcode);
798:
799: fprintf (ftbl, "\t\t\t\t\t/* OPERATION %s */\n", yo -> yo_name);
800:
801: normalize (&yo -> yo_arg, yo -> yo_name);
802: if (!Pepsyflag && (yp = yo -> yo_arg)) {
803: fprintf (ftbl, "int\t%s (),\n",
804: modsym (yp -> yp_module, yp -> yp_identifier, "encode"));
805: fprintf (ftbl, "\t%s (),\n",
806: modsym (yp -> yp_module, yp -> yp_identifier, "decode"));
807: fprintf (ftbl, "\t%s ();\n",
808: modsym (yp -> yp_module, yp -> yp_identifier, "free"));
809: }
810:
811: normalize (&yo -> yo_result, yo -> yo_name);
812: if (!Pepsyflag && (yp = yo -> yo_result)) {
813: fprintf (ftbl, "int\t%s (),\n",
814: modsym (yp -> yp_module, yp -> yp_identifier, "encode"));
815: fprintf (ftbl, "\t%s (),\n",
816: modsym (yp -> yp_module, yp -> yp_identifier, "decode"));
817: fprintf (ftbl, "\t%s ();\n\n",
818: modsym (yp -> yp_module, yp -> yp_identifier, "free"));
819: }
820:
821: if (!Pepsyflag) {
822: fprintf (fdef, "#ifdef\tINVOKER\n");
823: }
824: if (!Pepsyflag || Defsflag) {
825: fprintf (fdef, "#define\t%s_argument\t",
826: modsym (mymodule, yo -> yo_name, "encode"));
827: if (yp = yo -> yo_arg)
828: fprintf (fdef, "%s\n",
829: modsym (yp -> yp_module, yp -> yp_identifier, "encode"));
830: else
831: fprintf (fdef, "NULLIFP\n");
832: fprintf (fdef, "#define\t%s_result\t",
833: modsym (mymodule, yo -> yo_name, "decode"));
834: if (yp = yo -> yo_result)
835: fprintf (fdef, "%s\n",
836: modsym (yp -> yp_module, yp -> yp_identifier, "decode"));
837: else
838: fprintf (fdef, "NULLIFP\n");
839: fprintf (fdef, "#define\t%s_result\t",
840: modsym (mymodule, yo -> yo_name, "free"));
841: if (yp = yo -> yo_result)
842: fprintf (fdef, "%s\n",
843: modsym (yp -> yp_module, yp -> yp_identifier, "free"));
844: else
845: fprintf (fdef, "NULLIFP\n");
846: }
847: if (!Pepsyflag) {
848: fprintf (fdef, "#else\n");
849: fprintf (fdef, "#define\t%s_argument\tNULLIFP\n",
850: modsym (mymodule, yo -> yo_name, "encode"));
851: fprintf (fdef, "#define\t%s_result\tNULLIFP\n",
852: modsym (mymodule, yo -> yo_name, "decode"));
853: fprintf (fdef, "#define\t%s_result\tNULLIFP\n",
854: modsym (mymodule, yo -> yo_name, "free"));
855: fprintf (fdef, "#endif\n\n");
856:
857: fprintf (fdef, "#ifdef\tPERFORMER\n");
858: }
859: if (!Pepsyflag || Defsflag) {
860: fprintf (fdef, "#define\t%s_argument\t",
861: modsym (mymodule, yo -> yo_name, "decode"));
862: if (yp = yo -> yo_arg)
863: fprintf (fdef, "%s\n",
864: modsym (yp -> yp_module, yp -> yp_identifier, "decode"));
865: else
866: fprintf (fdef, "NULLIFP\n");
867: fprintf (fdef, "#define\t%s_argument\t",
868: modsym (mymodule, yo -> yo_name, "free"));
869: if (yp = yo -> yo_arg)
870: fprintf (fdef, "%s\n",
871: modsym (yp -> yp_module, yp -> yp_identifier, "free"));
872: else
873: fprintf (fdef, "NULLIFP\n");
874: fprintf (fdef, "#define\t%s_result\t",
875: modsym (mymodule, yo -> yo_name, "encode"));
876: if (yp = yo -> yo_result)
877: fprintf (fdef, "%s\n",
878: modsym (yp -> yp_module, yp -> yp_identifier, "encode"));
879: else
880: fprintf (fdef, "NULLIFP\n");
881: }
882: if (!Pepsyflag) {
883: fprintf (fdef, "#else\n");
884: fprintf (fdef, "#define\t%s_argument\tNULLIFP\n",
885: modsym (mymodule, yo -> yo_name, "decode"));
886: fprintf (fdef, "#define\t%s_argument\tNULLIFP\n",
887: modsym (mymodule, yo -> yo_name, "free"));
888: fprintf (fdef, "#define\t%s_result\tNULLIFP\n",
889: modsym (mymodule, yo -> yo_name, "encode"));
890: fprintf (fdef, "#endif\n\n");
891: }
892:
893: if (yv = yo -> yo_errors) {
894: if (yv -> yv_code != YV_VALIST)
895: myyerror ("unexpected value: %d", yv -> yv_code);
896: fprintf (ftbl, "static struct RyError *errors_%s[] = {\n",
897: modsym (mymodulename, yo -> yo_name, NULLCP));
898: for (yv = yv -> yv_idlist; yv; yv = yv -> yv_next) {
899: ye = lookup_err (yv);
900: fprintf (ftbl, " &table_%s_Errors[%d]%s\n", mymodaux,
901: ye -> ye_offset, yv -> yv_next ? "," : "");
902: }
903: fprintf (ftbl, "};\n\n");
904: }
905:
906: fprintf (ftbl, "\n");
907: }
908:
909: /* */
910:
911: /* ARGSUSED */
912:
913: static do_op2 (yo, id)
914: register YO yo;
915: char *id;
916: {
917: register YP yp;
918:
919: fprintf (fdef, "\n#define stub_%s(sd,id,in,rfx,efx,class,roi)\\\n",
920: modsym (mymodule, yo -> yo_name, NULLCP));
921: fprintf (fdef, "RyStub ((sd), table_%s_Operations,", mymodaux);
922: fprintf (fdef, " operation_%s, (id), NULLIP,\\\n",
923: modsym (mymodule, yo -> yo_name, NULLCP));
924: fprintf (fdef, "\t(caddr_t) (in), (rfx), (efx), (class), (roi))\n");
925:
926: fprintf (fdef, "\n#define op_%s(sd,in,out,rsp,roi)\\\n",
927: modsym (mymodule, yo -> yo_name, NULLCP));
928: fprintf (fdef, "RyOperation ((sd), table_%s_Operations,", mymodaux);
929: fprintf (fdef,
930: " operation_%s,\\\n\t(caddr_t) (in), (out), (rsp), (roi))\n",
931: modsym (mymodule, yo -> yo_name, NULLCP));
932:
933: fprintf (fstb, "\nint\tstub_%s (sd, id, in, rfx, efx, class, roi)\n",
934: modsym (mymodule, yo -> yo_name, NULLCP));
935: fprintf (fstb, "int\tsd,\n\tid,\n\tclass;\n");
936: if (yp = yo -> yo_arg)
937: fprintf (fstb, "struct %s*",
938: modsym (yp -> yp_module, yp -> yp_identifier, "type"));
939: else
940: fprintf (fstb, "caddr_t");
941: fprintf (fstb, " in;\n");
942: fprintf (fstb,
943: "IFP\trfx,\n\tefx;\nstruct RoSAPindication *roi;\n");
944: fprintf (fstb, "{\n return RyStub (sd, table_%s_Operations, ",
945: mymodaux);
946: fprintf (fstb,
947: "operation_%s, id, NULLIP,\n\t\t(caddr_t) in, rfx, efx, class, roi);\n",
948: modsym (mymodule, yo -> yo_name, NULLCP));
949: fprintf (fstb, "}\n");
950:
951: fprintf (fstb, "\nint\top_%s (sd, in, out, rsp, roi)\n",
952: modsym (mymodule, yo -> yo_name, NULLCP));
953: fprintf (fstb, "int\tsd;\n");
954: if (yp = yo -> yo_arg)
955: fprintf (fstb, "struct %s*",
956: modsym (yp -> yp_module, yp -> yp_identifier, "type"));
957: else
958: fprintf (fstb, "caddr_t");
959: fprintf (fstb, " in;\n");
960: fprintf (fstb,
961: "caddr_t *out;\nint *rsp;\nstruct RoSAPindication *roi;\n");
962: fprintf (fstb, "{\n return RyOperation (sd, table_%s_Operations, ",
963: mymodaux);
964: fprintf (fstb, "operation_%s,\n\t\t(caddr_t) in, out, rsp, roi);\n",
965: modsym (mymodule, yo -> yo_name, NULLCP));
966: fprintf (fstb, "}\n");
967:
968: fprintf (ftbl, "\t\t\t\t\t/* OPERATION %s */\n", yo -> yo_name);
969:
970: fprintf (ftbl, " \"%s\", operation_%s,\n",
971: yo -> yo_name, modsym (mymodule, yo -> yo_name, NULLCP));
972: if (Pepsyflag) {
973: if ((yp = yo->yo_arg)) {
974: if (yp->yp_code != YP_IDEFINED) {
975: fprintf(stderr, "\ndo_op2:arg: internal error for %s\n",
976: yo->yo_name);
977: exit(1);
978: }
979: fprintf (ftbl, "\t&%s,\n ",
980: cmodsym(yp->yp_module, MODTYP_SUFFIX, PREFIX));
981: fprintf (ftbl, "\t%s,\n",
982: csymmod(yp->yp_module, yp->yp_identifier, PREFIX));
983: } else {
984: fprintf (ftbl, "\tNULL,\n ");
985: fprintf (ftbl, "\tNULL,\n");
986: }
987: } else {
988: fprintf (ftbl, "\t%s_argument,\n ",
989: modsym (mymodule, yo -> yo_name, "encode"));
990: fprintf (ftbl, "\t%s_argument,\n",
991: modsym (mymodule, yo -> yo_name, "decode"));
992: fprintf (ftbl, "\t%s_argument,\n",
993: modsym (mymodule, yo -> yo_name, "free"));
994: }
995:
996: if (Pepsyflag) {
997: fprintf (ftbl, "\t%d,\n", yo -> yo_result ? 1 : 0);
998: if ((yp = yo->yo_result)) {
999: if (yp->yp_code != YP_IDEFINED) {
1000: fprintf(stderr, "\ndo_op2:result: internal error for %s\n",
1001: yo->yo_name);
1002: exit(1);
1003: }
1004: fprintf (ftbl, "\t&%s,\n ",
1005: cmodsym(yp->yp_module, MODTYP_SUFFIX, PREFIX));
1006: fprintf (ftbl, "\t%s,\n",
1007: csymmod(yp->yp_module, yp->yp_identifier, PREFIX));
1008: } else {
1009: fprintf (ftbl, "\tNULL,\n ");
1010: fprintf (ftbl, "\tNULL,\n");
1011: }
1012: } else {
1013: fprintf (ftbl, "\t%d, %s_result,\n",
1014: yo -> yo_result ? 1 : 0,
1015: modsym (mymodule, yo -> yo_name, "encode"));
1016: fprintf (ftbl, "\t %s_result,\n",
1017: modsym (mymodule, yo -> yo_name, "decode"));
1018: fprintf (ftbl, "\t %s_result,\n",
1019: modsym (mymodule, yo -> yo_name, "free"));
1020: }
1021:
1022: if (yo -> yo_errors)
1023: fprintf (ftbl, "\terrors_%s",
1024: modsym (mymodule, yo -> yo_name, NULLCP));
1025: else
1026: fprintf (ftbl, "\tNULL");
1027: fprintf (ftbl, ",\n\n");
1028: }
1029:
1030: /* */
1031:
1032: /* ARGSUSED */
1033:
1034: static do_err1 (ye, id)
1035: register YE ye;
1036: char *id;
1037: {
1038: register YP yp;
1039:
1040: fprintf (fdef, "\t\t\t\t\t/* ERROR %s */\n", ye -> ye_name);
1041: fprintf (fdef, "#define error_%s\t%d\n\n",
1042: modsym (mymodule, ye -> ye_name, NULLCP), ye -> ye_errcode);
1043:
1044: normalize (&ye -> ye_param, ye -> ye_name);
1045: if (!Pepsyflag) {
1046: if (yp = ye -> ye_param) {
1047: fprintf (ftbl, "int\t%s (),\n",
1048: modsym (yp -> yp_module, yp -> yp_identifier, "encode"));
1049: fprintf (ftbl, "\t%s (),\n",
1050: modsym (yp -> yp_module, yp -> yp_identifier, "decode"));
1051: fprintf (ftbl, "\t%s ();\n",
1052: modsym (yp -> yp_module, yp -> yp_identifier, "free"));
1053: }
1054: fprintf (fdef, "#ifdef\tINVOKER\n");
1055: fprintf (fdef, "#define\t%s_parameter\t",
1056: modsym (mymodule, ye -> ye_name, "decode"));
1057: if (yp = ye -> ye_param)
1058: fprintf (fdef, "%s\n",
1059: modsym (yp -> yp_module, yp -> yp_identifier, "decode"));
1060: else
1061: fprintf (fdef, "NULLIFP\n");
1062: fprintf (fdef, "#define\t%s_parameter\t",
1063: modsym (mymodule, ye -> ye_name, "free"));
1064: if (yp = ye -> ye_param)
1065: fprintf (fdef, "%s\n",
1066: modsym (yp -> yp_module, yp -> yp_identifier, "free"));
1067: else
1068: fprintf (fdef, "NULLIFP\n");
1069: fprintf (fdef, "#else\n");
1070: fprintf (fdef, "#define\t%s_parameter\tNULLIFP\n",
1071: modsym (mymodule, ye -> ye_name, "decode"));
1072: fprintf (fdef, "#define\t%s_parameter\tNULLIFP\n",
1073: modsym (mymodule, ye -> ye_name, "free"));
1074: fprintf (fdef, "#endif\n\n");
1075:
1076: fprintf (fdef, "#ifdef\tPERFORMER\n");
1077: fprintf (fdef, "#define\t%s_parameter\t",
1078: modsym (mymodule, ye -> ye_name, "encode"));
1079: if (yp = ye -> ye_param)
1080: fprintf (fdef, "%s\n",
1081: modsym (yp -> yp_module, yp -> yp_identifier, "encode"));
1082: else
1083: fprintf (fdef, "NULLIFP\n");
1084: fprintf (fdef, "#else\n");
1085: fprintf (fdef, "#define\t%s_parameter\tNULLIFP\n",
1086: modsym (mymodule, ye -> ye_name, "encode"));
1087: fprintf (fdef, "#endif\n\n\n");
1088: }
1089: }
1090:
1091: /* */
1092:
1093: /* ARGSUSED */
1094:
1095: static do_err2 (ye, id)
1096: register YE ye;
1097: char *id;
1098: {
1099: register YP yp;
1100:
1101: fprintf (ftbl, "\t\t\t\t\t/* ERROR %s */\n", ye -> ye_name);
1102:
1103: fprintf (ftbl, " \"%s\", error_%s,\n",
1104: ye -> ye_name, modsym (mymodule, ye -> ye_name, NULLCP));
1105:
1106: if (Pepsyflag) {
1107: if ((yp = ye->ye_param)) {
1108: fprintf (ftbl, "\t&%s,\n ",
1109: cmodsym(yp->yp_module, MODTYP_SUFFIX, PREFIX));
1110: fprintf (ftbl, "\t%s,\n",
1111: csymmod(yp->yp_module, yp->yp_identifier, PREFIX));
1112: } else {
1113: fprintf (ftbl, "\tNULL,\n\tNULL,\n");
1114: }
1115: } else {
1116: fprintf (ftbl, "\t%s_parameter,\n",
1117: modsym (mymodule, ye -> ye_name, "encode"));
1118: fprintf (ftbl, "\t%s_parameter,\n",
1119: modsym (mymodule, ye -> ye_name, "decode"));
1120: fprintf (ftbl, "\t%s_parameter,\n\n",
1121: modsym (mymodule, ye -> ye_name, "free"));
1122: }
1123: }
1124:
1125: /* */
1126:
1127: /* ARGSUSED */
1128:
1129: static do_type (yp, level, id)
1130: register YP yp;
1131: int level;
1132: char *id;
1133: {
1134: register YP y;
1135: register YV yv;
1136: register YT yt;
1137:
1138: printf ("%*s", level * 4, "");
1139:
1140: if (yp -> yp_flags & YP_ID) {
1141: printf ("%s", yp -> yp_id);
1142: if (!(yp -> yp_flags & YP_TAG)) {
1143: printf ("\n%*s", ++level * 4, "");
1144: if (!dflag
1145: && !(yp -> yp_flags & YP_PULLEDUP)
1146: && yp -> yp_action1) {
1147: act2prf (yp -> yp_action1, level, "%%{", "%%}\n%*s");
1148: yp -> yp_flags |= YP_PULLEDUP;
1149: }
1150: }
1151: }
1152:
1153: if (yp -> yp_flags & YP_TAG) {
1154: if (!(yt = yp -> yp_tag))
1155: myyerror ("lost tag");
1156: printf ("[%s%d]\n", classes[yt -> yt_class], val2int (yt -> yt_value));
1157: level++;
1158: printf ("%*s", level * 4, "");
1159: if (!dflag && !(yp -> yp_flags & YP_PULLEDUP) && yp -> yp_action1) {
1160: act2prf (yp -> yp_action1, level, "%%{", "%%}\n%*s");
1161: yp -> yp_flags |= YP_PULLEDUP;
1162: }
1163: if (yp -> yp_flags & YP_IMPLICIT)
1164: printf ("IMPLICIT ");
1165: }
1166: if (yp -> yp_flags & YP_BOUND)
1167: printf ("%s < ", yp -> yp_bound);
1168: if (yp -> yp_flags & YP_COMPONENTS)
1169: printf ("COMPONENTS OF ");
1170: if (yp -> yp_flags & YP_ENCRYPTED)
1171: printf ("ENCRYPTED ");
1172:
1173: switch (yp -> yp_code) {
1174: case YP_BOOL:
1175: printf ("BOOLEAN");
1176: if (!dflag && yp -> yp_intexp)
1177: printf ("\n%*s[[b %s]]", level * 4, "", yp -> yp_intexp);
1178: break;
1179:
1180: case YP_INT:
1181: printf ("INTEGER");
1182: if (!dflag && yp -> yp_intexp)
1183: printf ("\n%*s[[i %s]]", level * 4, "", yp -> yp_intexp);
1184: break;
1185:
1186: case YP_INTLIST:
1187: case YP_ENUMLIST:
1188: if (yp -> yp_code == YP_ENUMLIST)
1189: printf ("ENUMERATED");
1190: else
1191: printf ("INTEGER");
1192: if (!dflag && yp -> yp_intexp)
1193: printf ("\n%*s[[i %s]]\n%*s{\n",
1194: level * 4, "", yp -> yp_intexp, level * 4, "");
1195: else
1196: printf (" {\n");
1197: level++;
1198: for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
1199: if (!(yv -> yv_flags & YV_NAMED))
1200: myyerror ("lost named number");
1201: printf ("%*s%s(%d)", level * 4, "", yv -> yv_named,
1202: val2int (yv));
1203: if (!dflag && yv -> yv_action)
1204: printf (" %%{%s%%}", yv -> yv_action);
1205: printf ("%s\n", yv -> yv_next ? "," : "");
1206: }
1207: level--;
1208: printf ("%*s}", level * 4, "");
1209: break;
1210:
1211: case YP_BIT:
1212: printf ("BIT STRING");
1213: if (!dflag && yp -> yp_strexp)
1214: printf ("\n%*s[[x %s$%s]]", level * 4, "", yp -> yp_strexp,
1215: yp -> yp_intexp);
1216: break;
1217:
1218: case YP_BITLIST:
1219: if (!dflag && yp -> yp_strexp)
1220: printf ("BIT STRING\n%*s[[x %s$%s]]\n%*s{\n",
1221: level * 4, "", yp -> yp_strexp, yp -> yp_intexp,
1222: level * 4, "");
1223: else
1224: printf ("BIT STRING {\n");
1225: level++;
1226: for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
1227: if (!(yv -> yv_flags & YV_NAMED))
1228: myyerror ("lost named number");
1229: printf ("%*s%s(%d)", level * 4, "", yv -> yv_named,
1230: val2int (yv));
1231: if (!dflag && yv -> yv_action)
1232: printf (" %%{%s%%}", yv -> yv_action);
1233: printf ("%s\n", yv -> yv_next ? "," : "");
1234: }
1235: level--;
1236: printf ("%*s}", level * 4, "");
1237: break;
1238:
1239: case YP_OCT:
1240: printf ("OCTET STRING");
1241: if (dflag)
1242: break;
1243: if (yp -> yp_intexp)
1244: printf ("\n%*s[[o %s$%s]]", level * 4, "", yp -> yp_strexp,
1245: yp -> yp_intexp);
1246: else
1247: if (yp -> yp_strexp)
1248: printf ("\n%*s[[%c %s]]", level * 4, "", yp -> yp_prfexp,
1249: yp -> yp_strexp);
1250: break;
1251:
1252: case YP_NULL:
1253: printf ("NULL");
1254: break;
1255:
1256: case YP_REAL:
1257: printf ("REAL");
1258: if (!dflag && yp -> yp_strexp)
1259: printf ("\n%*s[[r %s ]]", level * 4, "", yp -> yp_strexp);
1260: break;
1261:
1262: case YP_SEQ:
1263: printf ("SEQUENCE");
1264: break;
1265:
1266: case YP_SEQTYPE:
1267: printf ("SEQUENCE OF");
1268: if (yp -> yp_structname) {
1269: printf (" %%[ %s ", yp -> yp_structname);
1270: if (yp -> yp_ptrname)
1271: printf ("$ %s ", yp -> yp_ptrname);
1272: printf ("%%]\n");
1273: }
1274: else
1275: printf ("\n");
1276: if (!dflag && yp -> yp_action3)
1277: act2prf (yp -> yp_action3, level + 1, "%*s%%{", "%%}\n");
1278: if (yp -> yp_flags & YP_CONTROLLED)
1279: printf ("%*s<<%s>>\n", (level + 1) * 4, "", yp -> yp_control);
1280: if (!yp -> yp_type)
1281: myyerror ("lost sequence type");
1282: do_type (yp -> yp_type, level + 1, "element");
1283: break;
1284:
1285: case YP_SEQLIST:
1286: printf ("SEQUENCE");
1287: if (yp -> yp_structname) {
1288: printf (" %%[ %s ", yp -> yp_structname);
1289: if (yp -> yp_ptrname)
1290: printf ("$ %s ", yp -> yp_ptrname);
1291: printf ("%%]");
1292: }
1293: if (!dflag && !(yp -> yp_flags & YP_PULLEDUP) && yp -> yp_action1)
1294: act2prf (yp -> yp_action1, level, "\n%*s %%{",
1295: " %%}\n%*s{\n");
1296: else
1297: printf (yp -> yp_type ? " {\n" : " {");
1298: for (y = yp -> yp_type; y; y = y -> yp_next) {
1299: do_type (y,
1300: level + ((y -> yp_flags & (YP_ID | YP_TAG)) ? 1 : 2),
1301: "element");
1302: printf ("%s\n", y -> yp_next ? ",\n" : "");
1303: }
1304: printf (yp -> yp_type ? "%*s}" : "}", level * 4, "");
1305: break;
1306:
1307: case YP_SET:
1308: printf ("SET");
1309: break;
1310:
1311: case YP_SETTYPE:
1312: printf ("SET OF");
1313: if (yp -> yp_structname) {
1314: printf (" %%[ %s ", yp -> yp_structname);
1315: if (yp -> yp_ptrname)
1316: printf ("$ %s ", yp -> yp_ptrname);
1317: printf ("%%]\n");
1318: }
1319: else
1320: printf ("\n");
1321: if (!dflag && yp -> yp_action3)
1322: act2prf (yp -> yp_action3, level + 1, "%*s%%{", "%%}\n");
1323: if (yp -> yp_flags & YP_CONTROLLED)
1324: printf ("%*s<<%s>>\n", (level + 1) * 4, "", yp -> yp_control);
1325: if (!yp -> yp_type)
1326: myyerror ("lost set type");
1327: do_type (yp -> yp_type, level + 1, "member");
1328: break;
1329:
1330: case YP_SETLIST:
1331: printf ("SET");
1332: if (yp -> yp_structname) {
1333: printf (" %%[ %s ", yp -> yp_structname);
1334: if (yp -> yp_ptrname)
1335: printf ("$ %s ", yp -> yp_ptrname);
1336: printf ("%%]");
1337: }
1338: if (!dflag && !(yp -> yp_flags & YP_PULLEDUP) && yp -> yp_action1)
1339: act2prf (yp -> yp_action1, level, "\n%*s %%{",
1340: " %%}\n%*s{\n");
1341: else
1342: printf (yp -> yp_type ? " {\n" : " {");
1343: for (y = yp -> yp_type; y; y = y -> yp_next) {
1344: do_type (y,
1345: level + ((y -> yp_flags & (YP_ID | YP_TAG)) ? 1 : 2),
1346: "member");
1347: printf ("%s\n", y -> yp_next ? ",\n" : "");
1348: }
1349: printf (yp -> yp_type ? "%*s}" : "}", level * 4, "");
1350: break;
1351:
1352: case YP_CHOICE:
1353: printf ("CHOICE");
1354: if (yp -> yp_structname) {
1355: printf (" %%[ %s ", yp -> yp_structname);
1356: if (yp -> yp_ptrname)
1357: printf ("$ %s ", yp -> yp_ptrname);
1358: printf ("%%]");
1359: }
1360: if (!dflag
1361: && !(yp -> yp_flags & YP_PULLEDUP)
1362: && yp -> yp_action1) {
1363: act2prf (yp -> yp_action1, level, "\n%*s %%{",
1364: " %%}\n%*s");
1365: if (yp -> yp_flags & YP_CONTROLLED)
1366: printf (" ");
1367: }
1368: else
1369: printf (" ");
1370: if (yp -> yp_flags & YP_CONTROLLED)
1371: printf ("<<%s>> ", yp -> yp_control);
1372: printf ("{\n");
1373: for (y = yp -> yp_type; y; y = y -> yp_next) {
1374: do_type (y,
1375: level + ((y -> yp_flags & (YP_ID | YP_TAG)) ? 1 : 2),
1376: "choice");
1377: printf ("%s\n", y -> yp_next ? ",\n" : "");
1378: }
1379: printf ("%*s}", level * 4, "");
1380: break;
1381:
1382: case YP_ANY:
1383: printf ("ANY");
1384: break;
1385:
1386: case YP_OID:
1387: printf ("OBJECT IDENTIFIER");
1388: if (!dflag && yp -> yp_strexp)
1389: printf ("\n%*s[[O %s]]", level * 4, "", yp -> yp_strexp);
1390: break;
1391:
1392: case YP_IDEFINED:
1393: if (yp -> yp_module && strcmp (yp -> yp_module, mymodule))
1394: printf ("%s.", yp -> yp_module);
1395: printf ("%s", yp -> yp_identifier);
1396: if (yp -> yp_intexp) {
1397: if (yp -> yp_strexp)
1398: printf ("\n%*s[[%c %s$%s]]", level * 4, "",
1399: yp -> yp_prfexp, yp -> yp_strexp, yp -> yp_intexp);
1400: else
1401: printf ("\n%*s[[%c %s]]", level * 4, "",
1402: yp -> yp_prfexp, yp -> yp_intexp);
1403: }
1404: else
1405: if (yp -> yp_strexp)
1406: printf ("\n%*s[[%c %s]]", level * 4, "",
1407: yp -> yp_prfexp, yp -> yp_strexp);
1408: if (yp -> yp_flags & YP_PARMVAL)
1409: printf ("\n%*s[[p %s]]", level * 4, "", yp -> yp_parm);
1410: break;
1411:
1412: default:
1413: myyerror ("unknown type: %d", yp -> yp_code);
1414: }
1415:
1416: if (!dflag && yp -> yp_action2)
1417: act2prf (yp -> yp_action2, level, "\n%*s%%{", "%%}");
1418:
1419: if (yp -> yp_flags & YP_OPTIONAL)
1420: printf ("\n%*sOPTIONAL", level * 4, "");
1421: else
1422: if (yp -> yp_flags & YP_DEFAULT) {
1423: if (!yp -> yp_default)
1424: myyerror ("lost default");
1425: printf ("\n%*sDEFAULT ", level * 4, "");
1426: val2prf (yp -> yp_default, level + 2);
1427: }
1428: if (yp -> yp_flags & YP_OPTCONTROL)
1429: printf (" <<%s>>", yp -> yp_optcontrol);
1430: }
1431:
1432: /* ERROR HANDLING */
1433:
1434: static YE lookup_err (yv)
1435: YV yv;
1436: {
1437: register char *id,
1438: *mod;
1439: register SY sy;
1440:
1441: if (yv -> yv_code != YV_IDEFINED)
1442: myyerror ("unexpected value: %d", yv -> yv_code);
1443: id = yv -> yv_identifier;
1444: mod = yv -> yv_module;
1445:
1446: for (sy = myerrors; sy; sy = sy -> sy_next) {
1447: if (mod) {
1448: if (strcmp (sy -> sy_module, mod))
1449: continue;
1450: }
1451: else
1452: if (strcmp (sy -> sy_module, mymodule))
1453: continue;
1454:
1455: if (strcmp (sy -> sy_name, id) == 0)
1456: return sy -> sy_err;
1457: }
1458:
1459: if (mod)
1460: myyerror ("error %s.%s undefined", mod, id);
1461: else
1462: myyerror ("error %s undefined", id);
1463: /* NOTREACHED */
1464: }
1465:
1466: /* TYPE HANDLING */
1467:
1468: static YP lookup_type (mod, id)
1469: register char *mod,
1470: *id;
1471: {
1472: register SY sy;
1473:
1474: for (sy = mytypes; sy; sy = sy -> sy_next) {
1475: if (mod) {
1476: if (strcmp (sy -> sy_module, mod))
1477: continue;
1478: }
1479: else
1480: if (strcmp (sy -> sy_module, mymodule)
1481: && strcmp (sy -> sy_module, "UNIV"))
1482: continue;
1483:
1484: if (strcmp (sy -> sy_name, id) == 0)
1485: return sy -> sy_type;
1486: }
1487:
1488: return NULLYP;
1489: }
1490:
1491: /* */
1492:
1493: static normalize (yp, id)
1494: YP *yp;
1495: char *id;
1496: {
1497: int i;
1498: register YP y,
1499: z;
1500: char buffer[BUFSIZ];
1501:
1502: if ((y = *yp) == NULLYP || y -> yp_code == YP_IDEFINED)
1503: return;
1504: y -> yp_id = NULLCP;
1505: y -> yp_flags &= ~YP_ID;
1506:
1507: (void) sprintf (buffer, "Pseudo-%s", id);
1508: for (i = 1; lookup_type (mymodule, buffer); i++)
1509: (void) sprintf (buffer, "Pseudo-%s-%d", id, i);
1510:
1511: z = new_type (YP_IDEFINED);
1512: z -> yp_identifier = new_string (buffer);
1513: *yp = z;
1514:
1515: pass1_type (yyencpref, yydecpref, yyprfpref, mymodule, new_string (buffer),
1516: y);
1517: }
1518:
1519: /* VALUE HANDLING */
1520:
1521: static int val2int (yv)
1522: register YV yv;
1523: {
1524: switch (yv -> yv_code) {
1525: case YV_BOOL:
1526: case YV_NUMBER:
1527: return yv -> yv_number;
1528:
1529: case YV_STRING:
1530: yyerror ("need an integer, not a string");
1531:
1532: case YV_IDEFINED:
1533: case YV_IDLIST:
1534: yyerror ("haven't written symbol table for values yet");
1535:
1536: case YV_VALIST:
1537: yyerror ("need an integer, not a list of values");
1538:
1539: case YV_NULL:
1540: yyerror ("need an integer, not NULL");
1541:
1542: case YV_REAL:
1543: yyerror ("need and integer, not a REAL");
1544:
1545: default:
1546: myyerror ("unknown value: %d", yv -> yv_code);
1547: }
1548: /* NOTREACHED */
1549: }
1550:
1551: /* */
1552:
1553: static val2prf (yv, level)
1554: register YV yv;
1555: int level;
1556: {
1557: register YV y;
1558:
1559: if (yv -> yv_flags & YV_ID)
1560: printf ("%s ", yv -> yv_id);
1561:
1562: if (yv -> yv_flags & YV_TYPE) /* will this REALLY work??? */
1563: do_type (yv -> yv_type, level, NULLCP);
1564:
1565: switch (yv -> yv_code) {
1566: case YV_BOOL:
1567: printf (yv -> yv_number ? "TRUE" : "FALSE");
1568: break;
1569:
1570: case YV_NUMBER:
1571: if (yv -> yv_named)
1572: printf ("%s", yv -> yv_named);
1573: else
1574: printf ("%d", yv -> yv_number);
1575: break;
1576:
1577: case YV_STRING:
1578: printf ("\"%s\"", yv -> yv_string);
1579: break;
1580:
1581: case YV_IDEFINED:
1582: if (yv -> yv_module)
1583: printf ("%s.", yv -> yv_module);
1584: printf ("%s", yv -> yv_identifier);
1585: break;
1586:
1587: case YV_IDLIST:
1588: case YV_VALIST:
1589: printf ("{");
1590: for (y = yv -> yv_idlist; y; y = y -> yv_next) {
1591: printf (" ");
1592: val2prf (y, level + 1);
1593: printf (y -> yv_next ? ", " : " ");
1594: }
1595: printf ("}");
1596: break;
1597:
1598: case YV_NULL:
1599: printf ("NULL");
1600: break;
1601:
1602: case YV_REAL:
1603: dump_real (yv -> yv_real);
1604: break;
1605:
1606: default:
1607: myyerror ("unknown value: %d", yv -> yv_code);
1608: /* NOTREACHED */
1609: }
1610: }
1611:
1612: static dump_real (r)
1613: double r;
1614: {
1615: #ifndef BSD44
1616: extern char *ecvt ();
1617: char *cp;
1618: char sbuf[128];
1619: int decpt, sign;
1620:
1621: cp = ecvt (r, 20, &decpt, &sign);
1622: (void) strcpy (sbuf, cp); /* cp gets overwritten by printf */
1623: printf ("{ %s%s, 10, %d }", sign ? "-" : "", sbuf,
1624: decpt - strlen (sbuf));
1625: #else
1626: register char *cp,
1627: *dp,
1628: *sp;
1629: char sbuf[128];
1630:
1631: (void) sprintf (sbuf, "%.19e", r);
1632: if (*(dp = sbuf) == '-')
1633: sp = "-", dp++;
1634: else
1635: sp = "";
1636:
1637: if (dp[1] != '.' || (cp = index (dp, 'e')) == NULL) {
1638: printf ("{ 0, 10, 0 } -- %s --", sbuf);
1639: return;
1640: }
1641: *cp++ = NULL;
1642: printf ("{ %s%c%s, 10, %d }",
1643: sp, *dp, dp + 2, atoi (cp) - strlen (dp + 2));
1644: #endif
1645: }
1646:
1647:
1648: /* ACTION HANDLING */
1649:
1650: static act2prf (cp, level, e1, e2)
1651: char *cp,
1652: *e1,
1653: *e2;
1654: int level;
1655: {
1656: register int i,
1657: j,
1658: l4;
1659: register char *dp,
1660: *ep,
1661: *fp;
1662: char *gp;
1663:
1664: if (e1)
1665: printf (e1, level * 4, "");
1666:
1667: if (!(ep = index (dp = cp, '\n'))) {
1668: printf ("%s", dp);
1669: goto out;
1670: }
1671:
1672: for (;;) {
1673: i = expand (dp, ep, &gp);
1674: if (gp) {
1675: if (i == 0)
1676: printf ("%*.*s\n", ep - dp, ep - dp, dp);
1677: else
1678: break;
1679: }
1680:
1681: if (!(ep = index (dp = ep + 1, '\n'))) {
1682: printf ("%s", dp);
1683: return;
1684: }
1685: }
1686:
1687:
1688: printf ("\n");
1689: l4 = (level + 1) * 4;
1690: for (; *dp; dp = fp) {
1691: if (ep = index (dp, '\n'))
1692: fp = ep + 1;
1693: else
1694: fp = ep = dp + strlen (dp);
1695:
1696: j = expand (dp, ep, &gp);
1697: if (gp == NULL) {
1698: if (*fp)
1699: printf ("\n");
1700: continue;
1701: }
1702:
1703: if (j < i)
1704: j = i;
1705: if (j)
1706: printf ("%*s", l4 + j - i, "");
1707: printf ("%*.*s\n", ep - gp, ep - gp, gp);
1708: }
1709:
1710: printf ("%*s", level * 4, "");
1711: out: ;
1712: if (e2)
1713: printf (e2, level * 4, "");
1714: }
1715:
1716:
1717: static expand (dp, ep, gp)
1718: register char *dp,
1719: *ep;
1720: char **gp;
1721: {
1722: register int i;
1723:
1724: *gp = NULL;
1725: for (i = 0; dp < ep; dp++) {
1726: switch (*dp) {
1727: case ' ':
1728: i++;
1729: continue;
1730:
1731: case '\t':
1732: i += 8 - (i % 8);
1733: continue;
1734:
1735: default:
1736: *gp = dp;
1737: break;
1738: }
1739: break;
1740: }
1741:
1742: return i;
1743: }
1744:
1745: /* DEBUG */
1746:
1747: static print_op (yo, level)
1748: register YO yo;
1749: register int level;
1750: {
1751: if (yo == NULLYO)
1752: return;
1753:
1754: fprintf (stderr, "%*sname=%s opcode=%d\n", level * 4, "",
1755: yo -> yo_name, yo -> yo_opcode);
1756:
1757: if (yo -> yo_arg) {
1758: fprintf (stderr, "%*sargument\n", level * 4, "");
1759: print_type (yo -> yo_arg, level + 1);
1760: }
1761: if (yo -> yo_result) {
1762: fprintf (stderr, "%*sresult\n", level * 4, "");
1763: print_type (yo -> yo_result, level + 1);
1764: }
1765: if (yo -> yo_errors) {
1766: fprintf (stderr, "%*serrors\n", level * 4, "");
1767: print_value (yo -> yo_errors, level + 1);
1768: }
1769: }
1770:
1771: /* */
1772:
1773: static print_err (ye, level)
1774: register YE ye;
1775: register int level;
1776: {
1777: if (ye == NULLYE)
1778: return;
1779:
1780: fprintf (stderr, "%*sname=%s opcode=%d\n", level * 4, "",
1781: ye -> ye_name, ye -> ye_errcode);
1782:
1783: if (ye -> ye_param) {
1784: fprintf (stderr, "%*sparameter\n", level * 4, "");
1785: print_type (ye -> ye_param, level + 1);
1786: }
1787: }
1788:
1789: /* */
1790:
1791: print_type (yp, level)
1792: register YP yp;
1793: register int level;
1794: {
1795: register YP y;
1796: register YV yv;
1797:
1798: if (yp == NULLYP)
1799: return;
1800:
1801: fprintf (stderr, "%*scode=0x%x flags=%s direction=0x%x\n", level * 4, "",
1802: yp -> yp_code, sprintb (yp -> yp_flags, YPBITS),
1803: yp -> yp_direction);
1804: fprintf (stderr,
1805: "%*sintexp=\"%s\" strexp=\"%s\" prfexp=0%o declexp=\"%s\" varexp=\"%s\"\n",
1806: level * 4, "", yp -> yp_intexp, yp -> yp_strexp, yp -> yp_prfexp,
1807: yp -> yp_declexp, yp -> yp_varexp);
1808: if (yp -> yp_param_type)
1809: fprintf (stderr, "%*sparameter type=\"%s\"\n", level * 4, "",
1810: yp -> yp_param_type);
1811: if (yp -> yp_action0)
1812: fprintf (stderr, "%*saction0 at line %d=\"%s\"\n", level * 4, "",
1813: yp -> yp_act0_lineno, yp -> yp_action0);
1814: if (yp -> yp_action05)
1815: fprintf (stderr, "%*saction05 at line %d=\"%s\"\n", level * 4, "",
1816: yp -> yp_act05_lineno, yp -> yp_action05);
1817: if (yp -> yp_action1)
1818: fprintf (stderr, "%*saction1 at line %d=\"%s\"\n", level * 4, "",
1819: yp -> yp_act1_lineno, yp -> yp_action1);
1820: if (yp -> yp_action2)
1821: fprintf (stderr, "%*saction2 at line %d=\"%s\"\n", level * 4, "",
1822: yp -> yp_act2_lineno, yp -> yp_action2);
1823: if (yp -> yp_action3)
1824: fprintf (stderr, "%*saction3 at line %d=\"%s\"\n", level * 4, "",
1825: yp -> yp_act3_lineno, yp -> yp_action3);
1826:
1827: if (yp -> yp_flags & YP_TAG) {
1828: fprintf (stderr, "%*stag class=0x%x value=0x%x\n", level * 4, "",
1829: yp -> yp_tag -> yt_class, yp -> yp_tag -> yt_value);
1830: print_value (yp -> yp_tag -> yt_value, level + 1);
1831: }
1832:
1833: if (yp -> yp_flags & YP_DEFAULT) {
1834: fprintf (stderr, "%*sdefault=0x%x\n", level * 4, "", yp -> yp_default);
1835: print_value (yp -> yp_default, level + 1);
1836: }
1837:
1838: if (yp -> yp_flags & YP_ID)
1839: fprintf (stderr, "%*sid=\"%s\"\n", level * 4, "", yp -> yp_id);
1840:
1841: if (yp -> yp_flags & YP_BOUND)
1842: fprintf (stderr, "%*sbound=\"%s\"\n", level * 4, "", yp -> yp_bound);
1843:
1844: if (yp -> yp_offset)
1845: fprintf (stderr, "%*soffset=\"%s\"\n", level * 4, "", yp -> yp_offset);
1846:
1847: switch (yp -> yp_code) {
1848: case YP_INTLIST:
1849: case YP_ENUMLIST:
1850: case YP_BITLIST:
1851: fprintf (stderr, "%*svalue=0x%x\n", level * 4, "", yp -> yp_value);
1852: for (yv = yp -> yp_value; yv; yv = yv -> yv_next) {
1853: print_value (yv, level + 1);
1854: fprintf (stderr, "%*s----\n", (level + 1) * 4, "");
1855: }
1856: break;
1857:
1858: case YP_SEQTYPE:
1859: case YP_SEQLIST:
1860: case YP_SETTYPE:
1861: case YP_SETLIST:
1862: case YP_CHOICE:
1863: fprintf (stderr, "%*stype=0x%x\n", level * 4, "", yp -> yp_type);
1864: for (y = yp -> yp_type; y; y = y -> yp_next) {
1865: print_type (y, level + 1);
1866: fprintf (stderr, "%*s----\n", (level + 1) * 4, "");
1867: }
1868: break;
1869:
1870: case YP_IDEFINED:
1871: fprintf (stderr, "%*smodule=\"%s\" identifier=\"%s\"\n",
1872: level * 4, "", yp -> yp_module ? yp -> yp_module : "",
1873: yp -> yp_identifier);
1874: break;
1875:
1876: default:
1877: break;
1878: }
1879: }
1880:
1881: /* */
1882:
1883: static print_value (yv, level)
1884: register YV yv;
1885: register int level;
1886: {
1887: register YV y;
1888:
1889: if (yv == NULLYV)
1890: return;
1891:
1892: fprintf (stderr, "%*scode=0x%x flags=%s\n", level * 4, "",
1893: yv -> yv_code, sprintb (yv -> yv_flags, YVBITS));
1894:
1895: if (yv -> yv_action)
1896: fprintf (stderr, "%*saction at line %d=\"%s\"\n", level * 4, "",
1897: yv -> yv_act_lineno, yv -> yv_action);
1898:
1899: if (yv -> yv_flags & YV_ID)
1900: fprintf (stderr, "%*sid=\"%s\"\n", level * 4, "", yv -> yv_id);
1901:
1902: if (yv -> yv_flags & YV_NAMED)
1903: fprintf (stderr, "%*snamed=\"%s\"\n", level * 4, "", yv -> yv_named);
1904:
1905: if (yv -> yv_flags & YV_TYPE) {
1906: fprintf (stderr, "%*stype=0x%x\n", level * 4, "", yv -> yv_type);
1907: print_type (yv -> yv_type, level + 1);
1908: }
1909:
1910: switch (yv -> yv_code) {
1911: case YV_NUMBER:
1912: case YV_BOOL:
1913: fprintf (stderr, "%*snumber=0x%x\n", level * 4, "",
1914: yv -> yv_number);
1915: break;
1916:
1917: case YV_STRING:
1918: fprintf (stderr, "%*sstring=0x%x\n", level * 4, "",
1919: yv -> yv_string);
1920: break;
1921:
1922: case YV_IDEFINED:
1923: if (yv -> yv_flags & YV_BOUND)
1924: fprintf (stderr, "%*smodule=\"%s\" identifier=\"%s\"\n",
1925: level * 4, "", yv -> yv_module, yv -> yv_identifier);
1926: else
1927: fprintf (stderr, "%*sbound identifier=\"%s\"\n",
1928: level * 4, "", yv -> yv_identifier);
1929: break;
1930:
1931: case YV_IDLIST:
1932: case YV_VALIST:
1933: for (y = yv -> yv_idlist; y; y = y -> yv_next) {
1934: print_value (y, level + 1);
1935: fprintf (stderr, "%*s----\n", (level + 1) * 4, "");
1936: }
1937: break;
1938:
1939: default:
1940: break;
1941: }
1942: }
1943:
1944: /* SYMBOLS */
1945:
1946: static SY new_symbol (encpref, decpref, prfpref, mod, id)
1947: register char *encpref,
1948: *decpref,
1949: *prfpref,
1950: *mod,
1951: *id;
1952: {
1953: register SY sy;
1954:
1955: if ((sy = (SY) calloc (1, sizeof *sy)) == NULLSY)
1956: yyerror ("out of memory");
1957: sy -> sy_encpref = encpref;
1958: sy -> sy_decpref = decpref;
1959: sy -> sy_prfpref = prfpref;
1960: sy -> sy_module = mod;
1961: sy -> sy_name = id;
1962:
1963: return sy;
1964: }
1965:
1966:
1967: static SY add_symbol (s1, s2)
1968: register SY s1,
1969: s2;
1970: {
1971: register SY sy;
1972:
1973: if (s1 == NULLSY)
1974: return s2;
1975:
1976: for (sy = s1; sy -> sy_next; sy = sy -> sy_next)
1977: continue;
1978: sy -> sy_next = s2;
1979:
1980: return s1;
1981: }
1982:
1983: /* TYPES */
1984:
1985: YP new_type (code)
1986: int code;
1987: {
1988: register YP yp;
1989:
1990: if ((yp = (YP) calloc (1, sizeof *yp)) == NULLYP)
1991: yyerror ("out of memory");
1992: yp -> yp_code = code;
1993:
1994: return yp;
1995: }
1996:
1997:
1998: YP add_type (y, z)
1999: register YP y,
2000: z;
2001: {
2002: register YP yp;
2003:
2004: for (yp = y; yp -> yp_next; yp = yp -> yp_next)
2005: continue;
2006: yp -> yp_next = z;
2007:
2008: return y;
2009: }
2010:
2011: /* VALUES */
2012:
2013: YV new_value (code)
2014: int code;
2015: {
2016: register YV yv;
2017:
2018: if ((yv = (YV) calloc (1, sizeof *yv)) == NULLYV)
2019: yyerror ("out of memory");
2020: yv -> yv_code = code;
2021:
2022: return yv;
2023: }
2024:
2025:
2026: YV add_value (y, z)
2027: register YV y,
2028: z;
2029: {
2030: register YV yv;
2031:
2032: for (yv = y; yv -> yv_next; yv = yv -> yv_next)
2033: continue;
2034: yv -> yv_next = z;
2035:
2036: return y;
2037: }
2038:
2039: /* TAGS */
2040:
2041: YT new_tag (class)
2042: PElementClass class;
2043: {
2044: register YT yt;
2045:
2046: if ((yt = (YT) calloc (1, sizeof *yt)) == NULLYT)
2047: yyerror ("out of memory");
2048: yt -> yt_class = class;
2049:
2050: return yt;
2051: }
2052:
2053: /* STRINGS */
2054:
2055: char *new_string (s)
2056: register char *s;
2057: {
2058: register char *p;
2059:
2060: if ((p = malloc ((unsigned) (strlen (s) + 1))) == NULLCP)
2061: yyerror ("out of memory");
2062:
2063: (void) strcpy (p, s);
2064: return p;
2065: }
2066:
2067: /* SYMBOLS */
2068:
2069: static struct triple {
2070: char *t_name;
2071: PElementClass t_class;
2072: PElementID t_id;
2073: } triples[] = {
2074: "IA5String", PE_CLASS_UNIV, PE_DEFN_IA5S,
2075: "ISO646String", PE_CLASS_UNIV, PE_DEFN_IA5S,
2076: "NumericString", PE_CLASS_UNIV, PE_DEFN_NUMS,
2077: "PrintableString", PE_CLASS_UNIV, PE_DEFN_PRTS,
2078: "T61String", PE_CLASS_UNIV, PE_DEFN_T61S,
2079: "TeletexString", PE_CLASS_UNIV, PE_DEFN_T61S,
2080: "VideotexString", PE_CLASS_UNIV, PE_DEFN_VTXS,
2081: "GeneralizedTime", PE_CLASS_UNIV, PE_DEFN_GENT,
2082: "GeneralisedTime", PE_CLASS_UNIV, PE_DEFN_GENT,
2083: "UTCTime", PE_CLASS_UNIV, PE_DEFN_UTCT,
2084: "UniversalTime", PE_CLASS_UNIV, PE_DEFN_UTCT,
2085: "GraphicString", PE_CLASS_UNIV, PE_DEFN_GFXS,
2086: "VisibleString", PE_CLASS_UNIV, PE_DEFN_VISS,
2087: "GeneralString", PE_CLASS_UNIV, PE_DEFN_GENS,
2088: "EXTERNAL", PE_CLASS_UNIV, PE_CONS_EXTN,
2089: "ObjectDescriptor", PE_CLASS_UNIV, PE_PRIM_ODE,
2090:
2091: NULL
2092: };
2093:
2094: /* */
2095:
2096: static char *modsym (module, id, prefix)
2097: register char *module,
2098: *id;
2099: char *prefix;
2100: {
2101: char buf1[BUFSIZ],
2102: buf2[BUFSIZ],
2103: buf3[BUFSIZ];
2104: register struct triple *t;
2105: static char buffer[BUFSIZ];
2106:
2107: if (module == NULLCP)
2108: for (t = triples; t -> t_name; t++)
2109: if (strcmp (t -> t_name, id) == 0) {
2110: module = "UNIV";
2111: break;
2112: }
2113:
2114: if (prefix)
2115: modsym_aux (prefix, buf1);
2116: modsym_aux (module ? module : mymodule, buf2);
2117: modsym_aux (id, buf3);
2118: if (prefix)
2119: (void) sprintf (buffer, "%s_%s_%s", buf1, buf2, buf3);
2120: else
2121: (void) sprintf (buffer, "%s_%s", buf2, buf3);
2122:
2123: return buffer;
2124: }
2125:
2126:
2127: /*
2128: * we do the same as modsym except we generate a more "compress" name,
2129: * no underscores between components and dash is translated to only one
2130: * underscore to be compatiable with pepsy. Hence name Compress MODule SYMbol
2131: */
2132: static char *cmodsym (module, id, prefix)
2133: register char *module,
2134: *id;
2135: char *prefix;
2136: {
2137: char buf1[BUFSIZ],
2138: buf2[BUFSIZ],
2139: buf3[BUFSIZ];
2140: register struct triple *t;
2141: static char buffer[BUFSIZ];
2142:
2143: if (module == NULLCP)
2144: for (t = triples; t -> t_name; t++)
2145: if (strcmp (t -> t_name, id) == 0) {
2146: module = "UNIV";
2147: break;
2148: }
2149:
2150: if (prefix)
2151: cmodsym_aux (prefix, buf1);
2152: cmodsym_aux (module ? module : mymodule, buf2);
2153: cmodsym_aux (id, buf3);
2154: if (prefix)
2155: (void) sprintf (buffer, "%s%s%s", buf1, buf2, buf3);
2156: else
2157: (void) sprintf (buffer, "%s%s", buf2, buf3);
2158:
2159: return buffer;
2160: }
2161:
2162:
2163: /* like cmodsym except we put identifier (sym) then the module (mod) hence its
2164: * name symmod
2165: */
2166: static char *csymmod (module, id, prefix)
2167: register char *module,
2168: *id;
2169: char *prefix;
2170: {
2171: char buf1[BUFSIZ],
2172: buf2[BUFSIZ],
2173: buf3[BUFSIZ];
2174: register struct triple *t;
2175: static char buffer[BUFSIZ];
2176:
2177: if (module == NULLCP)
2178: for (t = triples; t -> t_name; t++)
2179: if (strcmp (t -> t_name, id) == 0) {
2180: module = "UNIV";
2181: break;
2182: }
2183:
2184: if (prefix)
2185: cmodsym_aux (prefix, buf1);
2186: cmodsym_aux (id, buf2);
2187: cmodsym_aux (module ? module : mymodule, buf3);
2188: if (prefix)
2189: (void) sprintf (buffer, "%s%s%s", buf1, buf2, buf3);
2190: else
2191: (void) sprintf (buffer, "%s%s", buf2, buf3);
2192:
2193: return buffer;
2194: }
2195:
2196: static modsym_aux (name, bp)
2197: register char *name,
2198: *bp;
2199: {
2200: register char c;
2201:
2202: while (c = *name++)
2203: switch (c) {
2204: case '-':
2205: *bp++ = '_';
2206: *bp++ = '_';
2207: break;
2208:
2209: default:
2210: *bp++ = c;
2211: break;
2212: }
2213:
2214: *bp = NULL;
2215: }
2216:
2217: static cmodsym_aux (name, bp)
2218: register char *name,
2219: *bp;
2220: {
2221: register char c;
2222:
2223: while (c = *name++)
2224: switch (c) {
2225: case '-':
2226: *bp++ = '_';
2227: break;
2228:
2229: default:
2230: *bp++ = c;
2231: break;
2232: }
2233:
2234: *bp = NULL;
2235: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.