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