1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
%{
#ifndef lint
static char *rcs = "$Header: qmsopc.y,v 1.1 88/01/15 12:19:09 simpson Rel $";
#endif
/*
$Log: qmsopc.y,v $
* Revision 1.1 88/01/15 12:19:09 simpson
* initial release
*
* Revision 0.1 87/12/11 17:12:03 simpson
* beta test
*
*/
#include <stdio.h>
#include <setjmp.h>
#include <local/standard.h>
#include "qms.h"
extern FILE *_Ifp, *_Ofp;
extern Boolean _FirstChar;
static jmp_buf Env;
char *malloc();
static struct qmsopc Opc;
static struct optnode *P;
%}
%token NONE ENDLINE
%token <i> OC INTEGER
%type <p> numlist
%union {
int i;
struct optnode *p;
}
%%
opclines : opclines opcline | opcline ;
opcline :
OC NONE ENDLINE
{
switch ($1) {
case 1:
Opc.OC1 = NULL;
break;
case 2:
Opc.OC2 = NULL;
break;
case 3:
Opc.OC3 = NULL;
break;
case 4:
Opc.OC4 = NULL;
break;
case 5:
Opc.OC5 = NULL;
break;
}
}
|
OC numlist ENDLINE
{
switch ($1) {
case 1:
Opc.OC1 = $2;
break;
case 2:
Opc.OC2 = $2;
break;
case 3:
Opc.OC3 = $2;
break;
case 4:
Opc.OC4 = $2;
break;
case 5:
Opc.OC5 = $2;
break;
}
}
;
numlist :
numlist INTEGER optcomma
{
if ($1 == NULL) {
$1 = (struct optnode *)malloc((unsigned)
sizeof(struct optnode));
$1->option = $2;
$1->next = NULL;
} else {
for (P = $1; P->next; P = P->next)
;
P->next = (struct optnode *)malloc((unsigned)
sizeof(struct optnode));
P = P->next;
P->option = $2;
P->next = NULL;
}
$$ = $1;
}
|
{
/* epsilon */
$$ = NULL;
}
;
optcomma : ',' | /* epsilon */ ;
%%
#include "qmsopclex.c"
struct qmsopc *qmsopc()
{
_FirstChar = TRUE;
fputs(QUICON, _Ofp);
fprintf(_Ofp, "%s00000", SYNTAX);
fprintf(_Ofp, "%sOPC%s", INFO, ENDCMD);
fputs(QUICOFF, _Ofp);
(void)fflush(_Ofp);
if (setjmp(Env)) {
while (timedgetc(_Ifp) != EOF) /* Discard remaining input */
;
return NULL;
}
if (yyparse() != 0)
return NULL;
yysptr = yysbuf; /* Resets lex lookahead buffer */
return &Opc;
}
static yyerror(s)
char *s;
{
longjmp(Env, TRUE);
}
|