BSD 4 release
[unix-history] / usr / src / cmd / f77 / gram.io
CommitLineData
853979d9
BJ
1 /* Input/Output Statements */
2
3io: io1
4 { endio(); }
5 ;
6
7io1: iofmove ioctl
8 | iofmove unpar_fexpr
9 { ioclause(IOSUNIT, $2); endioctl(); }
10 | iofmove SSTAR
11 { ioclause(IOSUNIT, PNULL); endioctl(); }
12 | iofmove SPOWER
13 { ioclause(IOSUNIT, IOSTDERR); endioctl(); }
14 | iofctl ioctl
15 | read ioctl
16 { doio(PNULL); }
17 | read infmt
18 { doio(PNULL); }
19 | read ioctl inlist
20 { doio($3); }
21 | read infmt SCOMMA inlist
22 { doio($4); }
23 | read ioctl SCOMMA inlist
24 { doio($4); }
25 | write ioctl
26 { doio(PNULL); }
27 | write ioctl outlist
28 { doio($3); }
29 | print
30 { doio(PNULL); }
31 | print SCOMMA outlist
32 { doio($3); }
33 ;
34
35iofmove: fmkwd end_spec in_ioctl
36 ;
37
38fmkwd: SBACKSPACE
39 { iostmt = IOBACKSPACE; }
40 | SREWIND
41 { iostmt = IOREWIND; }
42 | SENDFILE
43 { iostmt = IOENDFILE; }
44 ;
45
46iofctl: ctlkwd end_spec in_ioctl
47 ;
48
49ctlkwd: SINQUIRE
50 { iostmt = IOINQUIRE; }
51 | SOPEN
52 { iostmt = IOOPEN; }
53 | SCLOSE
54 { iostmt = IOCLOSE; }
55 ;
56
57infmt: unpar_fexpr
58 {
59 ioclause(IOSUNIT, PNULL);
60 ioclause(IOSFMT, $1);
61 endioctl();
62 }
63 | SSTAR
64 {
65 ioclause(IOSUNIT, PNULL);
66 ioclause(IOSFMT, PNULL);
67 endioctl();
68 }
69 ;
70
71ioctl: SLPAR fexpr SRPAR
72 { if($2->headblock.vtype == TYCHAR)
73 {
74 ioclause(IOSUNIT, PNULL);
75 ioclause(IOSFMT, $2);
76 }
77 else
78 ioclause(IOSUNIT, $2);
79 endioctl();
80 }
81 | SLPAR ctllist SRPAR
82 { endioctl(); }
83 ;
84
85ctllist: ioclause
86 | ctllist SCOMMA ioclause
87 ;
88
89ioclause: fexpr
90 { ioclause(IOSPOSITIONAL, $1); }
91 | SSTAR
92 { ioclause(IOSPOSITIONAL, PNULL); }
93 | SPOWER
94 { ioclause(IOSPOSITIONAL, IOSTDERR); }
95 | nameeq expr
96 { ioclause($1, $2); }
97 | nameeq SSTAR
98 { ioclause($1, PNULL); }
99 | nameeq SPOWER
100 { ioclause($1, IOSTDERR); }
101 ;
102
103nameeq: SNAMEEQ
104 { $$ = iocname(); }
105 ;
106
107read: SREAD end_spec in_ioctl
108 { iostmt = IOREAD; }
109 ;
110
111write: SWRITE end_spec in_ioctl
112 { iostmt = IOWRITE; }
113 ;
114
115print: SPRINT end_spec fexpr in_ioctl
116 {
117 iostmt = IOWRITE;
118 ioclause(IOSUNIT, PNULL);
119 ioclause(IOSFMT, $3);
120 endioctl();
121 }
122 | SPRINT end_spec SSTAR in_ioctl
123 {
124 iostmt = IOWRITE;
125 ioclause(IOSUNIT, PNULL);
126 ioclause(IOSFMT, PNULL);
127 endioctl();
128 }
129 ;
130
131inlist: inelt
132 { $$ = mkchain($1, CHNULL); }
133 | inlist SCOMMA inelt
134 { $$ = hookup($1, mkchain($3, CHNULL)); }
135 ;
136
137inelt: lhs
138 { $$ = (tagptr) $1; }
139 | SLPAR inlist SCOMMA dospec SRPAR
140 { $$ = (tagptr) mkiodo($4,$2); }
141 ;
142
143outlist: uexpr
144 { $$ = mkchain($1, CHNULL); }
145 | other
146 { $$ = mkchain($1, CHNULL); }
147 | out2
148 ;
149
150out2: uexpr SCOMMA uexpr
151 { $$ = mkchain($1, mkchain($3, CHNULL) ); }
152 | uexpr SCOMMA other
153 { $$ = mkchain($1, mkchain($3, CHNULL) ); }
154 | other SCOMMA uexpr
155 { $$ = mkchain($1, mkchain($3, CHNULL) ); }
156 | other SCOMMA other
157 { $$ = mkchain($1, mkchain($3, CHNULL) ); }
158 | out2 SCOMMA uexpr
159 { $$ = hookup($1, mkchain($3, CHNULL) ); }
160 | out2 SCOMMA other
161 { $$ = hookup($1, mkchain($3, CHNULL) ); }
162 ;
163
164other: complex_const
165 { $$ = (tagptr) $1; }
166 | SLPAR uexpr SCOMMA dospec SRPAR
167 { $$ = (tagptr) mkiodo($4, mkchain($2, CHNULL) ); }
168 | SLPAR other SCOMMA dospec SRPAR
169 { $$ = (tagptr) mkiodo($4, mkchain($2, CHNULL) ); }
170 | SLPAR out2 SCOMMA dospec SRPAR
171 { $$ = (tagptr) mkiodo($4, $2); }
172 ;
173
174in_ioctl:
175 { startioctl(); }
176 ;