SUBROUTINE CMPOSL(LINE,SCANPT, SCNTRM,TOKEN,NCHARS,TRMTYP) NOLINEUP C C SCAN COMMAND LINE AND PICK UP NEXT TOKEN. THIS ROUTINE IS C USED FOR POSITIONAL LISTS, SO A TOKEN MAY BE NULL. A TOKEN C IS DEFINED AS A STRING OF NON-PUNCTUATION CHARACTERS BETWEEN C TWO PUNCTUATION CHARACTERS, WITH CHARACTERS AND COMMENT C STRINGS REMOVED. A QUOTED STRING IS RETURNED WITHOUT DELIMITING C QUOTES. INTERIOR QUOTES ARE RETURNED ONE-FOR-TWO. C C INPUTS-- C . LINE() - INPUT LINE - CHAR*1(N) C . SCANPT - INDEX TO LINE OF FIRST CHARACTER TO SCAN C C OUTPUTS-- C . SCNTRM - INDEX TO LINE OF CHARACTER WHICH STOPPED SCAN C . TOKEN()- CHARACTERS COMPRISING THE TOKEN - CHAR*1(NCHARS) C . NCHARS - NUMBER OF CHARACTERS IN TOKEN C . TRMTYP - PUNCTUATION TYPE CODE OF LINE(SCNTRM) C INCLUDE (SCANLIB.PARAMS) INCLUDE (SCANLIB.CMTABL) C CHARACTER*1 LINE(1), TOKEN(TOKNSZ) INTEGER SCANPT, SCNTRM,NCHARS,TRMTYP INTEGER SCAN LOGICAL STRING,EVENQ,BADSTR C C SKIP ANY LEADING NOISE OR COMMENT FIELDS -- C CALL CMSKIP(LINE,SCANPT, SCNTRM) SCAN = SCNTRM C C AT THIS POINT WE HAVE ONE OF , , OR C BEGINNING OF TOKEN -- C STRING = .FALSE. EVENQ = .TRUE. IF (SCAN.LT.EOL) THEN IF (LINE(SCAN).EQ.QUOTE) THEN STRING = .TRUE. EVENQ = .NOT.EVENQ SCAN = SCAN + 1 ENDIF ENDIF C BADSTR = .FALSE. NCHARS = 0 TRMTYP = NOPUNC DO WHILE (NCHARS.LT.TOKNSZ .AND. TRMTYP.EQ.NOPUNC) DO (CHECK FOR PUNCTUATION) IF (STRING) THEN IF (SCAN.GE.EOL) THEN C *** ERROR 9 - UNTERMINATED STRING AT EOL CALL CMERMS(9,TOKEN,NCHARS) ELSEIF (LINE(SCAN).EQ.QUOTE) THEN IF (EVENQ) THEN DO (COPY CHARACTER) ELSE SCAN = SCAN + 1 ENDIF EVENQ = .NOT.EVENQ ELSEIF (.NOT.EVENQ) THEN DO (COPY CHARACTER) TRMTYP = NOPUNC ELSEIF (TRMTYP.EQ.NOPUNC) THEN C *** ERROR 7 - MISSING PUNCTUATION AFTER STRING CALL CMERMS(7,TOKEN,NCHARS) SCAN = SCAN - 1 TRMTYP = ARGSEP BADSTR = .TRUE. ELSE C PUNCTUATION FOLLOWING EVEN QUOTE - END OF ITEM CONTINUE ENDIF ELSEIF (LINE(SCAN).EQ.QUOTE) THEN C *** ERROR 8 - UNEXPECTED QUOTE ENCOUNTERED CALL CMERMS(8,TOKEN,NCHARS) SCAN = SCAN + 1 ELSEIF (TRMTYP.EQ.NOPUNC) THEN DO (COPY CHARACTER) ELSE C PUNCTUATION - END OF ITEM CONTINUE ENDIF END WHILE C C SKIP OVER ANY EXCESS NON-PUNCT CHARACTERS IN TOKEN -- C DO WHILE (TRMTYP.EQ.NOPUNC) SCAN = SCAN + 1 DO (CHECK FOR PUNCTUATION) END WHILE C C SKIP ANY TRAILING NOISE OR COMMENT FIELD(S) -- C CALL CMSKIP(LINE,SCAN, SCNTRM) SCAN = SCNTRM IF (.NOT.BADSTR) THEN DO (CHECK FOR PUNCTUATION) C C SPECIAL MOD TO ALLOW AS DELIMITER -- (22MAY81,JWB) C IF (TRMTYP.EQ.NOPUNC) SCNTRM = SCAN - 1 C ENDIF C RETURN C C$CCC ----------------------------------------- C PROCEDURE (COPY CHARACTER) NCHARS = NCHARS + 1 TOKEN(NCHARS) = LINE(SCAN) SCAN = SCAN + 1 END PROCEDURE C C$CCC ----------------------------------------- C PROCEDURE (CHECK FOR PUNCTUATION) NDXPUN = 0 DO FOR I=1,PNTBSZ IF (LINE(SCAN).EQ.PUNTBL(I)) NDXPUN = I END FOR IF (NDXPUN.LE.0) THEN TRMTYP = NOPUNC ELSE TRMTYP = PNCODE(NDXPUN) ENDIF IF (SCAN.GE.EOL) TRMTYP = CMTERM END PROCEDURE C END