xref: /csrg-svn/old/ratfor/r.y (revision 62206)
148064Sbostic /*-
248064Sbostic  * %sccs.include.proprietary.c%
348064Sbostic  *
4*62206Sbostic  *	@(#)r.y	8.1 (Berkeley) 06/06/93
548064Sbostic  */
648064Sbostic 
79723Sclemc %{
89723Sclemc extern int transfer;
99723Sclemc extern	int	indent;
109723Sclemc %}
119723Sclemc 
129723Sclemc %term	IF ELSE FOR WHILE BREAK NEXT
139723Sclemc %term	DIGITS DO
149723Sclemc %term	GOK DEFINE INCLUDE
159723Sclemc %term	REPEAT UNTIL
169723Sclemc %term	RETURN
179723Sclemc %term	SWITCH CASE DEFAULT
189723Sclemc %%
199723Sclemc 
209723Sclemc statl	: statl  stat
219723Sclemc 	|
229723Sclemc 	;
239723Sclemc stat	: if stat	={ indent--; outcont($1); }
249723Sclemc 	| ifelse stat	={ indent--; outcont($1+1); }
259723Sclemc 	| switch fullcase '}'	={ endsw($1, $2); }
269723Sclemc 	| while stat	={ whilestat($1); }
279723Sclemc 	| for stat	={ forstat($1); }
289723Sclemc 	| repeat stat UNTIL	={ untils($1,1); }
299723Sclemc 	| repeat stat		={ untils($1,0); }
309723Sclemc 	| BREAK	={ breakcode(); }
319723Sclemc 	| NEXT		={ nextcode(); }
329723Sclemc 	| do stat	={ dostat($1); }
339723Sclemc 	| GOK		={ gokcode($1); }
349723Sclemc 	| RETURN	={ retcode(); }
359723Sclemc 	| ';'
369723Sclemc 	| '{' statl '}'
379723Sclemc 	| label stat
389723Sclemc 	| error		={ errcode(); yyclearin; }
399723Sclemc 	;
409723Sclemc switch	: sw '{'
419723Sclemc 	;
429723Sclemc sw	: SWITCH	={ swcode(); }
439723Sclemc 	;
449723Sclemc fullcase: caselist	={ $$ = 0; }
459723Sclemc 	| caselist defpart	={ $$ = 1; }
469723Sclemc 	;
479723Sclemc caselist: casepart
489723Sclemc 	| caselist casepart
499723Sclemc 	;
509723Sclemc defpart	: default statl
519723Sclemc 	;
529723Sclemc default	: DEFAULT	={ getdefault(); }
539723Sclemc 	;
549723Sclemc casepart: case statl
559723Sclemc 	;
569723Sclemc case	: CASE	={ getcase(); }
579723Sclemc 	;
589723Sclemc label	: DIGITS	={ transfer = 0; outcode($1); }
599723Sclemc 	;
609723Sclemc if	: IF		={ ifcode(); }
619723Sclemc 	;
629723Sclemc ifelse	: if stat ELSE	={ elsecode($1); }
639723Sclemc 	;
649723Sclemc while	: WHILE	={ whilecode(); }
659723Sclemc 	;
669723Sclemc for	: FOR		={ forcode(); }
679723Sclemc 	;
689723Sclemc repeat	: REPEAT	={ repcode(); }
699723Sclemc 	;
709723Sclemc do	: DO		={ docode(); }
719723Sclemc 	;
729723Sclemc %%
73