home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / ratfor / r.g < prev    next >
Encoding:
Text File  |  1979-01-10  |  1.2 KB  |  67 lines

  1. %{
  2. extern int transfer;
  3. extern    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.  
  14. statl    : statl  stat
  15.     |
  16.     ;
  17. stat    : 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.     ;
  34. switch    : sw '{'
  35.     ;
  36. sw    : SWITCH    ={ swcode(); }
  37.     ;
  38. fullcase: caselist    ={ $$ = 0; }
  39.     | caselist defpart    ={ $$ = 1; }
  40.     ;
  41. caselist: casepart
  42.     | caselist casepart
  43.     ;
  44. defpart    : default statl
  45.     ;
  46. default    : DEFAULT    ={ getdefault(); }
  47.     ;
  48. casepart: case statl
  49.     ;
  50. case    : CASE    ={ getcase(); }
  51.     ;
  52. label    : DIGITS    ={ transfer = 0; outcode($1); }
  53.     ;
  54. if    : IF        ={ ifcode(); }
  55.     ;
  56. ifelse    : if stat ELSE    ={ elsecode($1); }
  57.     ;
  58. while    : WHILE    ={ whilecode(); }
  59.     ;
  60. for    : FOR        ={ forcode(); }
  61.     ;
  62. repeat    : REPEAT    ={ repcode(); }
  63.     ;
  64. do    : DO        ={ docode(); }
  65.     ;
  66. %%
  67.