	SUBROUTINE DECIDE
C
C	Subroutine DECIDE is used to decide what kind of statement is
C	 currently being scanned by the IFTRAN processor.  A value is
C	 returned (KIND) in IFTCOM common which gives statement type.
C
C	KIND	STATEMENT TYPE
C	  0	Not an IFTRAN statement
C	  1	IF (logical)
C	  2	OR IF (logical)
C	  3	ELSE
C	  4	END IF
C	  5	WHILE (logical)
C	  6	END WHILE
C	  7	END
C	  8	EXIT IF
C	  9	EXIT WHILE
C	 10	DO
C	 11	UNTIL (logical)
C	 12	EXIT DO
C	 13	FOR var1 = var2, var3
C	 14	END FOR
C	 15	EXIT FOR
C
	IMPLICIT INTEGER (A - Z)
	LOGICAL*1 LABEL, LIST, CONLBL, LHEAD, T, LPAR, RPAR, CA
	LOGICAL*1 CZ, C0, C9, EQUAL, COMMA, BLANK
	COMMON /FORCOM/ ERRS, ITYPE, L, KIND, IP, INFILE, OUTFIL, LOUT,
     +	LISTNG, PLINES, LPPAGE, LABEL(66), LHEAD(6), LIST(1320), CONLBL(6)
	DIMENSION T(56), TN(56), V(56)
	DATA T /'I', 'F', '(', 'E', 'L', 'S', 'E', 'N', 'D', 'I',
     +          'F', 'W', 'H', 'I', 'L', 'E', 'X', 'I', 'T', 'I',
     +          'F', 'W', 'H', 'I', 'L', 'E', 'W', 'H', 'I', 'L',
     +          'E', '(', 'O', 'R', 'I', 'F', '(', 'D', 'O', 'U',
     +          'N', 'T', 'I', 'L', '(', 'D', 'O', 'F', 'O', 'R',
     +          'F', 'O', 'R', 'F', 'O', 'R'/
	DATA TN /4,  0,  0, 27,  8,  0,  0, 17,  0, 12,
     +           0, 51,  0,  0,  0,  0,  0,  0,  0, 22,
     +           0, 46,  0,  0,  0,  0, 33,  0,  0,  0,
     +           0,  0, 38,  0,  0,  0,  0, 40,  0, 48,
     +           0,  0,  0,  0,  0, 54,  0,  0,  0,  0,
     +           0,  0,  0,  0,  0,  0/
	DATA V /0,   0, -26,  0,   0,  0,   3,  0,  7,  0,
     +          4,   0,   0,  0,   0,  6,   0,  0,  0,  0,
     +         -8,   0,   0,  0,   0, -9,   0,  0,  0,  0,
     +          0, -30,   0,  0,   0,  0, -27,  0, 10,  0,
     +          0,   0,   0,  0, -36,  0, -12,  0,  0, 13,
     +          0,   0,  14,  0,   0, -15/
	DATA LOGINC/25/
	DATA LPAR/'('/
	DATA RPAR/')'/
	DATA BLANK/' '/
	DATA CA,CZ,C0,C9,EQUAL,COMMA/'A','Z','0','9','=',','/
C
C	***************************************************************
C
	X = 0
	I = 1
	SAVEX = 0
    1	J = 1
C
C	  If J = 0, token list examined and token not found; skip on
32098	IF (J .EQ. 0) GO TO 32097
C
C	  Find next nonblank character in LIST
32096	IF (LIST(I) .NE. BLANK) GO TO 32095
C	  I points at next nonblank character
	I = I + 1
	GO TO 32096
C
C	  If a possible match against token list, skip on
32095	IF (LIST(I) .EQ. T(J)) GO TO 32093
C	  No match, try next possible token
	J = TN(J)
	X = 0
	GO TO 32098
C
C	  Possible match; set X to V(J)
32093	X = V(J)
	IF ((I .EQ. L) .OR. ((X .NE. 0) .AND. (X .NE. 7))) GO TO 32097
C	  If exit conditions not met, continue processing
	I = I + 1
	J = J + 1
	GO TO 32098
C
32097	J = I
	IF (X .GE. 0) GO TO 32091
	X = -X
	IF (X .LE. LOGINC) GO TO 32089
	LEV = 1
	X = X - LOGINC
32088	IF (J .GT. L) GO TO 32092
C	  Increment search column
	J = J + 1
C	  Left paren?  Increment parenthesis level
	IF (LIST(J) .EQ. LPAR) LEV = LEV + 1
C	  Right paren?  Decrement parenthesis level
	IF (LIST(J) .EQ. RPAR) LEV = LEV - 1
C	  Parens balanced?  Skip on
	IF (LEV .EQ. 0) GO TO 32092
C	  Parens still unbalanced; keep looking for more
	GO TO 32088
C
32089	IF ((I .EQ. L) .OR. (SAVEX .NE. 0)) GO TO 32092
	SAVEI = I
	I = I + 1
	SAVEX = X
	GO TO 1
C
32091	IF (X .NE. 13) GO TO 32092
	DELIM = EQUAL
C
32085	IF (J .GT. L) GO TO 32084
	J = J + 1
	CHR = LIST(J)
C	  Valid alphabetic character?  Skip on
	IF ((CHR .GE. CA) .AND. (CHR .LE. CZ)) GO TO 32085
C	  Character = blank?  Skip on
	IF (CHR .EQ. BLANK) GO TO 32085
C	  Valid numeric character?  Skip on
	IF ((CHR .GE. C0) .AND. (CHR .LE. C9)) GO TO 32085
	IF (CHR .NE. DELIM) GO TO 32084
	IF (DELIM .EQ. COMMA) GO TO 10
	DELIM = COMMA
	GO TO 32085
C
32084	X = 0
32092	IF (SAVEX .EQ. 0) GO TO 32080
	IF (X .NE. 1) SAVEX = 0
	X = SAVEX
	I = SAVEI
32080	IF (J .NE. L) X = 0
   10	KIND = X
	IP = I + 6
	RETURN
	END
