home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / f77 / gram.head < prev    next >
Encoding:
Text File  |  1979-05-05  |  3.2 KB  |  158 lines

  1. %{
  2. #include "defs"
  3.  
  4. static int nstars;
  5. static int ndim;
  6. static int vartype;
  7. static ftnint varleng;
  8. static struct { ptr lb, ub; } dims[8];
  9. static struct labelblock *labarray[MAXLABLIST];
  10. static int lastwasbranch = NO;
  11. static int thiswasbranch = NO;
  12. extern ftnint yystno;
  13.  
  14. ftnint convci();
  15. double convcd();
  16. struct addrblock *nextdata(), *mkbitcon();
  17. struct constblock *mklogcon(), *mkaddcon(), *mkrealcon();
  18. struct constblock *mkstrcon(), *mkcxcon();
  19. struct listblock *mklist();
  20. struct listblock *mklist();
  21. struct impldoblock *mkiodo();
  22. struct extsym *comblock();
  23.  
  24. %}
  25.  
  26. /* Specify precedences and associativies. */
  27.  
  28. %left SCOMMA
  29. %nonassoc SCOLON
  30. %right SEQUALS
  31. %left SEQV SNEQV
  32. %left SOR
  33. %left SAND
  34. %left SNOT
  35. %nonassoc SLT SGT SLE SGE SEQ SNE
  36. %left SCONCAT
  37. %left SPLUS SMINUS
  38. %left SSTAR SSLASH
  39. %right SPOWER
  40.  
  41. %%
  42.  
  43. program:
  44.     | program stat SEOS
  45.     ;
  46.  
  47. stat:      thislabel entry
  48.         { lastwasbranch = NO; }
  49.     | thislabel  spec
  50.     | thislabel  exec
  51.         { if($1 && ($1->labelno==dorange))
  52.             enddo($1->labelno);
  53.           if(lastwasbranch && thislabel==NULL)
  54.             warn1("statement cannot be reached");
  55.           lastwasbranch = thiswasbranch;
  56.           thiswasbranch = NO;
  57.         }
  58.     | thislabel SINCLUDE filename
  59.         { doinclude( $3 ); }
  60.     | thislabel  SEND  end_spec
  61.         { lastwasbranch = NO;  endproc(); }
  62.     | thislabel SUNKNOWN
  63.         { execerr("unclassifiable statement", 0);  flline(); };
  64.     | error
  65.         { flline();  needkwd = NO;  inioctl = NO; 
  66.           yyerrok; yyclearin; }
  67.     ;
  68.  
  69. thislabel:  SLABEL
  70.         {
  71.         if(yystno != 0)
  72.             {
  73.             $$ = thislabel =  mklabel(yystno);
  74.             if( ! headerdone )
  75.                 puthead(NULL, procclass);
  76.             if(thislabel->labdefined)
  77.                 execerr("label %s already defined",
  78.                     convic(thislabel->stateno) );
  79.             else    {
  80.                 if(thislabel->blklevel!=0 && thislabel->blklevel<blklevel
  81.                     && thislabel->labtype!=LABFORMAT)
  82.                     warn1("there is a branch to label %s from outside block",
  83.                           convic( (ftnint) (thislabel->stateno) ) );
  84.                 thislabel->blklevel = blklevel;
  85.                 thislabel->labdefined = YES;
  86.                 if(thislabel->labtype != LABFORMAT)
  87.                     putlabel(thislabel->labelno);
  88.                 }
  89.             }
  90.         else    $$ = thislabel = NULL;
  91.         }
  92.     ;
  93.  
  94. entry:      SPROGRAM new_proc progname
  95.         { startproc($3, CLMAIN); }
  96.     | SBLOCK new_proc progname
  97.         { startproc($3, CLBLOCK); }
  98.     | SSUBROUTINE new_proc entryname arglist
  99.         { entrypt(CLPROC, TYSUBR, (ftnint) 0,  $3, $4); }
  100.     | SFUNCTION new_proc entryname arglist
  101.         { entrypt(CLPROC, TYUNKNOWN, (ftnint) 0, $3, $4); }
  102.     | type SFUNCTION new_proc entryname arglist
  103.         { entrypt(CLPROC, $1, varleng, $4, $5); }
  104.     | SENTRY entryname arglist
  105.         { if(parstate==OUTSIDE || procclass==CLMAIN
  106.             || procclass==CLBLOCK)
  107.                 execerr("misplaced entry statement", 0);
  108.           entrypt(CLENTRY, 0, (ftnint) 0, $2, $3);
  109.         }
  110.     ;
  111.  
  112. new_proc:
  113.         { newproc(); }
  114.     ;
  115.  
  116. entryname:  name
  117.         { $$ = newentry($1); }
  118.     ;
  119.  
  120. name:      SNAME
  121.         { $$ = mkname(toklen, token); }
  122.     ;
  123.  
  124. progname:        { $$ = NULL; }
  125.     | entryname
  126.     ;
  127.  
  128. arglist:
  129.         { $$ = 0; }
  130.     | SLPAR SRPAR
  131.         { $$ = 0; }
  132.     | SLPAR args SRPAR
  133.         {$$ = $2; }
  134.     ;
  135.  
  136. args:      arg
  137.         { $$ = ($1 ? mkchain($1,0) : 0 ); }
  138.     | args SCOMMA arg
  139.         { if($3) $1 = $$ = hookup($1, mkchain($3,0)); }
  140.     ;
  141.  
  142. arg:      name
  143.         { $1->vstg = STGARG; }
  144.     | SSTAR
  145.         { $$ = 0;  substars = YES; }
  146.     ;
  147.  
  148.  
  149.  
  150. filename:   SHOLLERITH
  151.         {
  152.         char *s;
  153.         s = copyn(toklen+1, token);
  154.         s[toklen] = '\0';
  155.         $$ = s;
  156.         }
  157.     ;
  158.