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