|
|
1.1 root 1: /* mod.c */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/pepsy/RCS/mod.c,v 7.0 90/07/01 19:54:23 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/pepsy/RCS/mod.c,v 7.0 90/07/01 19:54:23 mrose Exp $
9: *
10: *
11: * $Log: mod.c,v $
12: * Revision 7.0 90/07/01 19:54:23 mrose
13: * *** empty log message ***
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: #include <stdio.h>
29: #include <ctype.h>
30: #include "pepsydefs.h"
31: #include "pass2.h"
32:
33: extern char *sysin;
34: extern char *proc_name();
35: extern char *my_strcat();
36:
37: char *calc_arg();
38:
39: #define MAXLENGTH 30
40:
41: /*
42: * output each of the actions associated with yp
43: */
44: do_sw_type(name, yp, fp, fpa)
45: char *name;
46: YP yp;
47: FILE *fp;
48: FILE *fpa;
49: {
50: static int curr = 0;
51: char *s, *t;
52: char *arg;
53:
54: s = proc_name(name, 0);
55: if (yp->yp_action1) {
56: (void) fprintf(fp, "\t\tcase %s%s:\n", s, ACT1);
57: arg = calc_arg(yp, 1);
58: my_do_action(fp, yp->yp_action1, 0, arg, yp->yp_act1_lineno, yp->yp_param_type);
59: /*
60: * fprintf(fpa, "#define %s%s\t%d\n", s, ACT1, curr++);
61: */
62: (void) fprintf(fp, "\t\t\tbreak;\n");
63: }
64: if (yp->yp_action2) {
65: (void) fprintf(fp, "\t\tcase %s%s:\n", s, ACT2);
66: arg = calc_arg(yp, 2);
67: my_do_action(fp, yp->yp_action2, 0, arg, yp->yp_act2_lineno, yp->yp_param_type);
68: /*
69: * fprintf(fpa, "#define %s%s\t%d\n", s, ACT2, curr++);
70: */
71: (void) fprintf(fp, "\t\t\tbreak;\n");
72: }
73: if (yp->yp_action05) {
74: (void) fprintf(fp, "\t\tcase %s%s:\n", s, ACT05);
75: arg = calc_arg(yp, 5);
76: my_do_action(fp, yp->yp_action05, 0, arg, yp->yp_act05_lineno, yp->yp_param_type);
77: /*
78: * fprintf(fpa, "#define %s%s\t%d\n", s, ACT05, curr++);
79: */
80: (void) fprintf(fp, "\t\t\tbreak;\n");
81: }
82: }
83:
84: my_do_action(fp, action, level, arg, lineno, new)
85: FILE *fp;
86: char *action;
87: int level;
88: char *arg;
89: int lineno;
90: char *new;
91: {
92: int i;
93: char t[MAXLENGTH];
94: char c, d;
95:
96: (void) fprintf(fp, "%*s{\n", level * 4, "");
97: Printf(4, ("\n"));
98:
99: if (*sysin)
100: (void) fprintf(fp, "# line %d \"%s\"\n", lineno, sysin);
101:
102: for (d = NULL; c = *action; d = c, action++) {
103: Printf(4, ("open char is %c\n", *action));
104: for (i = 0; i < MAXLENGTH - 1 && (isalpha(*action) || *action == '_'); action++, i++)
105: t[i] = *action;
106: t[i] = '\0';
107: Printf(4, ("WORD IS %s, %c, %d\n", t, *action, i));
108: if (strcmp(t, "")) {
109: if (!strcmp(t, "parm"))
110: (void) fprintf(fp, "(%s)%s", new, "parm");
111: else
112: (void) fprintf(fp, "%s", t);
113: c = *(action - 1);
114: action--;
115: continue;
116: /*
117: * OR d = *(action - 1); c = *action;
118: */
119: }
120: switch (d) {
121: case '$':
122: if (c == '$') {
123: (void) fprintf(fp, "%s", arg);
124: c = NULL;
125: break;
126: }
127: (void) fputc('$', fp); /* fall */
128:
129: default:
130: if (c != '$')
131: (void) fputc(c, fp);
132: break;
133: }
134: }
135:
136: switch (d) {
137: case '\n':
138: break;
139:
140: case '$':
141: (void) fputc('$', fp); /* fall */
142: default:
143: (void) fputc('\n', fp);
144: break;
145: }
146:
147: (void) fprintf(fp, "%*s}\n", level * 4, "");
148: }
149:
150: char *
151: calc_arg(yp, actno)
152: YP yp;
153: int actno;
154: {
155:
156: switch (actno) {
157: case 1:
158: return "";
159: break;
160: case 2:
161: if (yp->yp_direction & YP_ENCODER)
162: return "(pe)";
163: else
164: return "(pe)";
165: break;
166: case 5:
167: if (yp->yp_direction & YP_ENCODER)
168: return "";
169: else
170: return "(pe)";
171: break;
172: default:
173: return "";
174: }
175: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.