add EGP
[unix-history] / usr / src / old / ratfor / r.y
CommitLineData
5bd4a919
CC
1Original BTL Ratfor System for 4.2
2/* @(#)r.y 1.1 (Berkeley) %G% */
3%{
4extern int transfer;
5extern 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
16statl : statl stat
17 |
18 ;
19stat : 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 ;
36switch : sw '{'
37 ;
38sw : SWITCH ={ swcode(); }
39 ;
40fullcase: caselist ={ $$ = 0; }
41 | caselist defpart ={ $$ = 1; }
42 ;
43caselist: casepart
44 | caselist casepart
45 ;
46defpart : default statl
47 ;
48default : DEFAULT ={ getdefault(); }
49 ;
50casepart: case statl
51 ;
52case : CASE ={ getcase(); }
53 ;
54label : DIGITS ={ transfer = 0; outcode($1); }
55 ;
56if : IF ={ ifcode(); }
57 ;
58ifelse : if stat ELSE ={ elsecode($1); }
59 ;
60while : WHILE ={ whilecode(); }
61 ;
62for : FOR ={ forcode(); }
63 ;
64repeat : REPEAT ={ repcode(); }
65 ;
66do : DO ={ docode(); }
67 ;
68%%