4 %term NAME SHELLINE START MACRODEF COLON DOUBLECOLON GREATER AMPER AMPERAMPER
7 struct shblock *yshblock;
12 %type <yshblock> SHELLINE, shlist, shellist
13 %type <ynameblock> NAME, namelist
14 %type <ydepblock> deplist, dlist
21 static struct shblock *prevshp;
23 static struct nameblock *lefts[NLEFTS];
24 struct nameblock *leftp;
27 struct lineblock *lp, *lpp;
28 static struct depblock *prevdep;
37 } filestack[MAXINCLUDE];
38 static int ninclude = 0;
48 | START namelist deplist shellist = {
53 leftp = lefts[nlefts];
54 if(wp = iswild(leftp->namep))
56 leftp->septype = SOMEDEPS;
64 if(leftp->septype == 0)
65 leftp->septype = sepc;
66 else if(leftp->septype != sepc)
70 "Inconsistent rules lines for `%s'\n",
73 else if(sepc==ALLDEPS && leftp->namep[0]!='.' && $4!=0)
75 for(lp=leftp->linep; lp->nxtlineblock; lp=lp->nxtlineblock)
78 "Multiple rules lines for `%s'\n",
82 lp = ALLOC(lineblock);
83 lp->nxtlineblock = NULL;
89 if(equal(leftp->namep, ".SUFFIXES") && $3==0)
91 else if(leftp->linep == 0)
94 for(lpp = leftp->linep; lpp->nxtlineblock;
95 lpp = lpp->nxtlineblock) ;
96 if(sepc==ALLDEPS && leftp->namep[0]=='.')
98 lpp->nxtlineblock = lp;
105 namelist: NAME = { lefts[0] = $1; nlefts = 1; }
106 | namelist NAME = { lefts[nlefts++] = $2;
107 if(nlefts>=NLEFTS) fatal("Too many lefts"); }
113 sprintf(junk, "%s:%d", filestack[ninclude-1].fname, yylineno);
114 fatal1("Must be a separator on rules line %s", junk);
119 dlist: sepchar = { prevdep = 0; $$ = 0; allnowait = NO; }
120 | sepchar AMPER = { prevdep = 0; $$ = 0; allnowait = YES; }
122 pp = ALLOC(depblock);
123 pp->nxtdepblock = NULL;
125 pp->nowait = allnowait;
126 if(prevdep == 0) $$ = pp;
127 else prevdep->nxtdepblock = pp;
130 | dlist AMPER = { if(prevdep) prevdep->nowait = YES; }
134 sepchar: COLON = { sepc = ALLDEPS; }
135 | DOUBLECOLON = { sepc = SOMEDEPS; }
138 shellist: = {$$ = 0; }
139 | shlist = { $$ = $1; }
142 shlist: SHELLINE = { $$ = $1; prevshp = $1; }
143 | shlist SHELLINE = { $$ = $1;
144 prevshp->nxtshblock = $2;
151 static char *zznextc; /* null if need another line;
152 otherwise points to next char */
155 static int retsh(char *);
156 static int nextlin(void);
157 static int isinclude(char *);
169 name = "(builtin-rules)";
171 else if(equal(name, "-"))
176 else if( (stream = fopen(name, "r")) == NULL)
178 filestack[0].fname = copys(name);
185 fatal("Description file error");
202 while( isspace(*zznextc) )
217 if(*++zznextc == ':')
227 if(*++zznextc == '&')
234 return retsh(zznextc) ;
240 while( ! ( funny[*p] & TERMINAL) )
246 if((yylval.ynameblock=srchname(word))==0)
247 yylval.ynameblock = makename(word);
254 sprintf(junk, "Bad character %c (octal %o), line %d of file %s",
255 *zznextc, *zznextc, yylineno, filestack[ninclude-1].fname);
258 return 0; /* never executed */
270 for(p=q+1 ; *p==' '||*p=='\t' ; ++p) ;
273 sp->nxtshblock = NULL;
274 sp->shbp = (fin ? copys(p) : p );
275 yylval.yshblock = sp;
283 static char yytext[INMAX];
284 static char *yytextl = yytext+INMAX;
285 char *text, templin[INMAX];
288 char lastch, *lastchp;
289 extern char **linesptr;
300 if( (text = *linesptr++) == 0)
306 for(p = text = yytext ; p<yytextl ; *p++ = kc)
307 switch(kc = getc(fin))
325 if(p==yytext || p[-1]!='\\')
331 while( (kc=getc(fin))=='\t' || kc==' ' || kc=='\n')
341 register struct fstack *stp;
344 stp = filestack + ninclude;
346 yylineno = stp->lineno;
353 fatal("line too long");
358 if((c = text[0]) == '\t')
361 if(isalpha(c) || isdigit(c) || c==' ' || c=='.'|| c=='_')
362 for(p=text+1; *p!='\0'; )
371 /* substitute for macros on dependency line up to the semicolon if any */
373 for(t = yytext ; *t!='\0' && *t!=';' ; ++t)
378 *t = '\0'; /* replace the semi with a null so subst will stop */
380 subst(yytext, templin); /* Substitute for macros on dependency lines */
382 if(lastch) /* copy the stuff after the semicolon */
385 strcat(templin, lastchp);
388 strcpy(yytext, templin);
390 /* process include files after macro substitution */
391 if(strncmp(text, "include", 7) == 0) {
392 if (isinclude(text+7))
396 for(p = zznextc = text ; *p ; ++p )
397 if(*p!=' ' && *p!='\t')
409 for(t=s; *t==' ' || *t=='\t' ; ++t)
414 for(s = t; *s!='\n' && *s!='#' && *s!='\0' ; ++s)
419 if(ninclude >= MAXINCLUDE)
420 fatal("include depth exceeded");
421 p = filestack + ninclude;
423 p->lineno = yylineno;
425 if( (fin = fopen(t, "r")) == NULL)
426 fatal1("Cannot open include file %s", t);
434 yyerror(char *s, ...)
438 sprintf(buf, "line %d of file %s: %s",
439 yylineno, filestack[ninclude-1].fname, s);