1
/****************************************************************
2
Copyright 1990, 1993 by AT&T Bell Laboratories, Bellcore.
4
Permission to use, copy, modify, and distribute this software
5
and its documentation for any purpose and without fee is hereby
6
granted, provided that the above copyright notice appear in all
7
copies and that both that the copyright notice and this
8
permission notice and warranty disclaimer appear in supporting
9
documentation, and that the names of AT&T Bell Laboratories or
10
Bellcore or any of their entities not be used in advertising or
11
publicity pertaining to distribution of the software without
12
specific, written prior permission.
14
AT&T and Bellcore disclaim all warranties with regard to this
15
software, including all implied warranties of merchantability
16
and fitness. In no event shall AT&T or Bellcore be liable for
17
any special, indirect or consequential damages or any damages
18
whatsoever resulting from loss of use, data or profits, whether
19
in an action of contract, negligence or other tortious action,
20
arising out of or in connection with the use or performance of
22
****************************************************************/
28
static int nstars; /* Number of labels in an
29
alternate return CALL */
34
static ftnint varleng;
35
static struct Dims dims[MAXDIM+1];
36
extern struct Labelblock **labarray; /* Labels in an alternate
38
extern int maxlablist;
40
/* The next two variables are used to verify that each statement might be reached
41
during runtime. lastwasbranch is tested only in the defintion of the
44
int lastwasbranch = NO;
45
static int thiswasbranch = NO;
48
static chainp datastack;
49
extern long laststfcn, thisstno;
50
extern int can_include; /* for netlib */
51
extern struct Primblock *primchk Argdcl((expptr));
53
#define ESNULL (Extsym *)0
54
#define NPNULL (Namep)0
55
#define LBNULL (struct Listblock *)0
59
chainp d0 = datastack;
61
curdtp = (chainp)d0->datap;
62
datastack = d0->nextp;
69
/* Specify precedences and associativities. */
78
struct Labelblock *labval;
79
struct Nameblock *namval;
80
struct Eqvchain *eqvval;
91
%nonassoc SLT SGT SLE SGE SEQ SNE
98
%type <labval> thislabel label assignlabel
99
%type <tagval> other inelt
100
%type <ival> type typespec typename dcl letter addop relop stop nameeq
101
%type <lval> lengspec
102
%type <charpval> filename
103
%type <chval> datavar datavarlist namelistlist funarglist funargs
104
%type <chval> dospec dospecw
105
%type <chval> callarglist arglist args exprlist inlist outlist out2 substring
106
%type <namval> name arg call var
107
%type <expval> lhs expr uexpr opt_expr fexpr unpar_fexpr
108
%type <expval> ubound simple value callarg complex_const simple_const bit_const
109
%type <extval> common comblock entryname progname
110
%type <eqvval> equivlist
118
stat: thislabel entry
120
/* stat: is the nonterminal for Fortran statements */
122
lastwasbranch = NO; }
125
{ /* forbid further statement function definitions... */
126
if (parstate == INDATA && laststfcn != thisstno)
129
if($1 && ($1->labelno==dorange))
131
if(lastwasbranch && thislabel==NULL)
132
warn("statement cannot be reached");
133
lastwasbranch = thiswasbranch;
137
if($1->labtype == LABFORMAT)
138
err("label already that of a format");
140
$1->labtype = LABEXEC;
144
| thislabel SINCLUDE filename
148
fprintf(diagfile, "Cannot open file %s\n", $3);
152
| thislabel SEND end_spec
155
endproc(); /* lastwasbranch = NO; -- set in endproc() */
160
/* flline flushes the current line, ignoring the rest of the text there */
164
{ flline(); needkwd = NO; inioctl = NO;
165
yyerrok; yyclearin; }
172
$$ = thislabel = mklabel(yystno);
174
if (procclass == CLUNKNOWN)
176
puthead(CNULL, procclass);
178
if(thislabel->labdefined)
179
execerr("label %s already defined",
180
convic(thislabel->stateno) );
182
if(thislabel->blklevel!=0 && thislabel->blklevel<blklevel
183
&& thislabel->labtype!=LABFORMAT)
184
warn1("there is a branch to label %s from outside block",
185
convic( (ftnint) (thislabel->stateno) ) );
186
thislabel->blklevel = blklevel;
187
thislabel->labdefined = YES;
188
if(thislabel->labtype != LABFORMAT)
189
p1_label((long)(thislabel - labeltab));
192
else $$ = thislabel = NULL;
196
entry: SPROGRAM new_proc progname
197
{startproc($3, CLMAIN); }
198
| SPROGRAM new_proc progname progarglist
199
{ warn("ignoring arguments to main program");
201
startproc($3, CLMAIN); }
202
| SBLOCK new_proc progname
203
{ if($3) NO66("named BLOCKDATA");
204
startproc($3, CLBLOCK); }
205
| SSUBROUTINE new_proc entryname arglist
206
{ entrypt(CLPROC, TYSUBR, (ftnint) 0, $3, $4); }
207
| SFUNCTION new_proc entryname arglist
208
{ entrypt(CLPROC, TYUNKNOWN, (ftnint) 0, $3, $4); }
209
| type SFUNCTION new_proc entryname arglist
210
{ entrypt(CLPROC, $1, varleng, $4, $5); }
211
| SENTRY entryname arglist
212
{ if(parstate==OUTSIDE || procclass==CLMAIN
213
|| procclass==CLBLOCK)
214
execerr("misplaced entry statement", CNULL);
215
entrypt(CLENTRY, 0, (ftnint) 0, $2, $3);
224
{ $$ = newentry($1, 1); }
228
{ $$ = mkname(token); }
231
progname: { $$ = NULL; }
237
| SLPAR progargs SRPAR
241
| progargs SCOMMA progarg
245
| SNAME SEQUALS SNAME
251
{ NO66(" () argument list");
258
{ $$ = ($1 ? mkchain((char *)$1,CHNULL) : CHNULL ); }
260
{ if($3) $1 = $$ = mkchain((char *)$3, $1); }
264
{ if($1->vstg!=STGUNKNOWN && $1->vstg!=STGARG)
265
dclerr("name declared as argument after use", $1);
269
{ NO66("altenate return argument");
271
/* substars means that '*'ed formal parameters should be replaced.
272
This is used to specify alternate return labels; in theory, only
273
parameter slots which have '*' should accept the statement labels.
274
This compiler chooses to ignore the '*'s in the formal declaration, and
275
always return the proper value anyway.
277
This variable is only referred to in proc.c */
279
$$ = 0; substars = YES; }
287
s = copyn(toklen+1, token);