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