/************************************************************************ * incgen -generate code for include statement * * * * useage: call incgen * * notes: * * 1. incgen makes calls to scan to assemble a file * * name. It uses the fact that square brackets get translated * * properly to its advantage. * ************************************************************************/ subroutine incgen include ratfor.def include lineno.cmm #line numbers and file names include getlin.cmm #file luns and buffer character token(MAXTOKEN) #thing to hold file name character temp(MAXTOKEN) integer scan /*----->* If incgen discovers that the current include statement would * nest includes too deeply, the following things are done: * 1. print out a warning. * 2. flush the rest of the line * 3. and return */ if(lun + 1 > MAXLUN) [ call synerr(W_INC_OVR) for(i = scan(token);i ^= EOF & i ^= NEWLINE;i = scan(token)) ; return ] /*----->* A call to scan is made to get the next token. If the token * is a string, the quotes are stripped off. If the token is * not a string, repeated calls to scan are made until a * newline is found. */ if(scan(token) == LEXSTRING)[ call scopy(token,2,token,1) for(i = 1;token(i) ^= SQUOTE;i = i + 1) ; token(i) = EOS ] else [ for(i = scan(temp);i ^= NEWLINE & i ^= EOF;i = scan(temp)) call concat(token,temp) if(i == EOF) [ call synerr(S_EOF) type *,'incgen' ] ] ptr = INBUFSIZE + 1 #force a new getlin lun = lun + 1 #open up next file call scopy(token,1,inname(1,lun),1) #save file name open(unit=lun,type='OLD',carriagecontrol='LIST',readonly,name=token,err=100) lineno(lun)=0 #initialize line number return 100 lun = lun - 1 #restore lun call synerr(W_OPEN_FILE) #write out error return end