1 /*- 2 * %sccs.include.proprietary.c% 3 * 4 * @(#)r.y 1.2 (Berkeley) 04/16/91 5 */ 6 7 %{ 8 extern int transfer; 9 extern int indent; 10 %} 11 12 %term IF ELSE FOR WHILE BREAK NEXT 13 %term DIGITS DO 14 %term GOK DEFINE INCLUDE 15 %term REPEAT UNTIL 16 %term RETURN 17 %term SWITCH CASE DEFAULT 18 %% 19 20 statl : statl stat 21 | 22 ; 23 stat : if stat ={ indent--; outcont($1); } 24 | ifelse stat ={ indent--; outcont($1+1); } 25 | switch fullcase '}' ={ endsw($1, $2); } 26 | while stat ={ whilestat($1); } 27 | for stat ={ forstat($1); } 28 | repeat stat UNTIL ={ untils($1,1); } 29 | repeat stat ={ untils($1,0); } 30 | BREAK ={ breakcode(); } 31 | NEXT ={ nextcode(); } 32 | do stat ={ dostat($1); } 33 | GOK ={ gokcode($1); } 34 | RETURN ={ retcode(); } 35 | ';' 36 | '{' statl '}' 37 | label stat 38 | error ={ errcode(); yyclearin; } 39 ; 40 switch : sw '{' 41 ; 42 sw : SWITCH ={ swcode(); } 43 ; 44 fullcase: caselist ={ $$ = 0; } 45 | caselist defpart ={ $$ = 1; } 46 ; 47 caselist: casepart 48 | caselist casepart 49 ; 50 defpart : default statl 51 ; 52 default : DEFAULT ={ getdefault(); } 53 ; 54 casepart: case statl 55 ; 56 case : CASE ={ getcase(); } 57 ; 58 label : DIGITS ={ transfer = 0; outcode($1); } 59 ; 60 if : IF ={ ifcode(); } 61 ; 62 ifelse : if stat ELSE ={ elsecode($1); } 63 ; 64 while : WHILE ={ whilecode(); } 65 ; 66 for : FOR ={ forcode(); } 67 ; 68 repeat : REPEAT ={ repcode(); } 69 ; 70 do : DO ={ docode(); } 71 ; 72 %% 73