#-h- findsym 479 asc 08-may-80 10:33:25 ## definitions for the FIND tool # put on a file named 'findsym' # Used by the find, ch, and tr tools define(ANY,QMARK) define(BOL,PERCENT) define(CCL,LBRACK) define(CCLEND,RBRACK) define(CHAR,LETA) define(CLOSIZE,4) define(CLOSURE,STAR) define(COUNT,1) define(EOL,DOLLAR) define(MAXARG,128) define(MAXPAT,128) define(NCCL,LETN) define(PREVCL,2) define(START,3) define(NEXPR,10) # maximum number of expressions allowed on cmd line #-h- resolve.r 2357 asc 08-may-80 10:33:27 #-h- main 600 asc 08-may-80 10:33:17 #--------------------------------------------------------------------- # include symbol definitions # include symbols include findsym #--------------------------------------------------------------------- ## resolv -- main program #BKY subroutine driver # call initr4 # call resolv # call endr4 # end #BKY #assembly code main program (used to avoid loading fortran I/O) #BKY % #BKY ident main #BKY entry main #BKY vfd 42/0lmain,18/main #BKY ext driver #BKY rj uzero00 #BKY rj driver #BKY end main #BKY% #-h- resolves 1510 asc 08-may-80 10:33:18 # subroutine resolv subroutine main character exp(MAXARG,NEXPR), pat(MAXPAT,NEXPR), lin(MAXLINE), arg(MAXARG), infile(FILENAMESIZE) integer i, getarg, except, andpat, count, elevel, itoc, getpat, mcount, getlin, matchd, status, gmatch, index, int, open data except/NO/ data andpat/NO/ data count /NO/ data elevel/0/ call adrfil(infile) int = open(infile, READ) if (int == ERR) call cant(infile) for (i=1; getarg(i, arg, MAXARG) != EOF; i=i+1) if (arg(1) == QMARK & arg(2) == EOS) call reserr else if (arg(1) == MINUS) { call scopy(arg, 1, lin, 1) call fold(lin) if (index(lin, LETA) > 0) andpat = YES if (index(lin, LETC) > 0) count = YES if (index(lin, LETX) > 0) except = YES } else if (elevel < NEXPR) { elevel = elevel + 1 call fold(arg) call scopy(arg, 1, exp(1, elevel), 1) } else { call putlin("Maximum number of expressions permitted is ", ERROUT) status = itoc(NEXPR, arg, MAXARG) call error(arg) } if (elevel == 0) call reserr for (i=1; i <= elevel; i=i+1) if (getpat(exp(1,i), pat(1,i)) == ERR) { call putlin("illegal pattern: ", ERROUT) call error(exp(1,i)) } mcount = 0 while (getlin(lin, int) != EOF) { matchd = gmatch(lin, pat, elevel, andpat) if ((matchd == YES & except == NO) | (matchd == NO & except == YES)) if (count == YES) mcount = mcount + 1 else call putlin(lin, STDOUT) } if (count == YES) { call putdec(mcount, 1) call putc(NEWLINE) } return end #-h- reserr 100 asc 08-may-80 10:33:20 subroutine reserr call error("usage: resolve [-acx] expression [expression ...]") return end