SUBROUTINE CMSCAN(LINE) NOLINEUP C C THIS IS THE TOP LEVEL ROUTINE IN THE SCANLIB COMMAND PROCESSOR C LIBRARY. IT PARSES THE COMMAND KEYWORD, LOOKS UP THE COMMAND, C AND PARSES THE ARGUMENT LIST(S). C C INPUT -- LINE() - LINE OF CHARACTERS TO BE SCANNED - CHAR*1(N) C C OUTPUT -- NONE C C 16 JAN 80 - JWB C CONVERTED TO FORTRAN 77 - 1 DEC 80 - JWB C INCLUDE,L (SCANLIB.PARAMS) INCLUDE,L (SCANLIB.CMLIST) INCLUDE,L (SCANLIB.CMTABL) C CHARACTER*1 LINE(1) CHARACTER*1 TOKEN(TOKNSZ) INTEGER SCAN,SCNTRM,TRMTYP INTEGER CMDNDX,KWDNDX C SCAN = 1 DO WHILE (SCAN.LT.EOL) CALL CMTOKN(LINE,SCAN, SCNTRM,TOKEN,NCHARS,TRMTYP) SCAN = SCNTRM + 1 IF (NCHARS.GT.0) THEN CALL CMLKUP(TOKEN,NCHARS,CMDTBL,1,CMTBSZ, CMDNDX) IF (CMDNDX.GT.0) THEN CMDFND(CMDNDX) = 1 DO (PROCESS COMMAND) ELSE C *** ERROR 1 - UNRECOGNIZED COMMAND CALL CMERMS(1,TOKEN,NCHARS) DO WHILE (TRMTYP.LT.CMTERM .AND. SCAN.LT.EOL) CALL CMTOKN(LINE,SCAN, SCNTRM,TOKEN,NCHARS,TRMTYP) SCAN = SCNTRM + 1 END WHILE ENDIF ENDIF END WHILE RETURN C C$CCC -------------------------------------------------- C PROCEDURE (PROCESS COMMAND) LSTLNG = MIN0( IABS(CNARGS(CMDNDX)) , LSTLEN ) IF (LSTLNG.GT.0 .AND. TRMTYP.LT.ARGSEP) THEN DO (PROCESS INITIAL NONKEYWORD LIST) ENDIF DO WHILE (TRMTYP.LT.CMTERM .AND. SCAN.LT.EOL) DO (PROCESS KEYWORD ARGUMENT) END WHILE END PROCEDURE C C$CCC -------------------------------------------------- C PROCEDURE (PROCESS INITIAL NONKEYWORD LIST) LSTYPE = CARGTP(CMDNDX) LSTNDX = CLSTDX(CMDNDX) IF (CNARGS(CMDNDX).LT.0) LSTLNG = -LSTLNG DO CASE (LSTYPE,4) CASE 1 @ INTEGER LIST CALL CMLSTI(LSTLNG,LINE,SCAN, SCNTRM,TRMTYP,ILIST(1,LSTNDX)) CASE 2 @ REAL LIST CALL CMLSTR(LSTLNG,LINE,SCAN, SCNTRM,TRMTYP,RLIST(1,LSTNDX)) CASE 3 @ NAME LIST CALL CMLSTN(LSTLNG,LINE,SCAN,0, SCNTRM,TRMTYP,NLIST(1,LSTNDX)) CASE 4 @ STRING LIST CALL CMLSTS(LSTLNG,LINE,SCAN, SCNTRM,TRMTYP,SLIST(1,1,LSTNDX), *STLENG(1,LSTNDX)) END CASE SCAN = SCNTRM + 1 END PROCEDURE C C$CCC -------------------------------------------------- C PROCEDURE (PROCESS KEYWORD ARGUMENT) CALL CMTOKN(LINE,SCAN, SCNTRM,TOKEN,NCHARS,TRMTYP) SCAN = SCNTRM + 1 IF (NCHARS.GT.0) THEN CALL CMLKUP(TOKEN,NCHARS,KWDTBL,KWSTRT(CMDNDX),KWSTOP(CMDNDX) *, KWDNDX) IF (KWDNDX.GT.0) THEN KWDFND(KWDNDX) = 1 IF (TRMTYP.LT.ARGSEP) THEN LSTYPE = KARGTP(KWDNDX) LSTLNG = MAX0( MIN0(KNARGS(KWDNDX),LSTLEN) , -LSTLEN ) LSTNDX = KLSTDX(KWDNDX) DO CASE (LSTYPE,4) CASE 1 @ INTEGER LIST CALL CMLSTI(LSTLNG,LINE,SCAN, SCNTRM,TRMTYP,ILIST(1,LSTNDX)) CASE 2 @ REAL LIST CALL CMLSTR(LSTLNG,LINE,SCAN, SCNTRM,TRMTYP,RLIST(1,LSTNDX)) CASE 3 @ NAME LIST CALL CMLSTN(LSTLNG,LINE,SCAN,KWDNDX *, SCNTRM,TRMTYP,NLIST(1,LSTNDX)) CASE 4 @ STRING LIST CALL CMLSTS(LSTLNG,LINE,SCAN, SCNTRM,TRMTYP,SLIST(1,1,LSTNDX) *,STLENG(1,LSTNDX)) END CASE SCAN = SCNTRM + 1 ENDIF ELSE C *** ERROR 2 - UNRECOGNIZED KEYWORD ARGUMENT CALL CMERMS(2,TOKEN,NCHARS) DO WHILE (TRMTYP.LT.ARGSEP .AND. SCAN.LT.EOL) CALL CMTOKN(LINE,SCAN, SCNTRM,TOKEN,NCHARS,TRMTYP) SCAN = SCNTRM + 1 END WHILE ENDIF ENDIF END PROCEDURE C END