       SUBROUTINE PC.MATCH(OBJ,NODE.0,E.FLG,FLG,NODE.ID,ELS,POS)
*PRE-COMPILER
*
*DEV TRIAL RT
*BASIC
*N
*     PRECISION 6
*
************************************************************************
************************************************************************
***                                                                  ***
*** PICK PARSING PRE-COMPILER SYSTEM                                 ***
***                                                                  ***
*** COPYRIGHT 1988 MODULAR SOFTWARE                                  ***
***                P.O. BOX 204                                      ***
***                ATLANTA, GA  30291                                ***
***                (404) 964 - 7171                                  ***
***                                                                  ***
*** THIS PROGRAM IS PROPRIETARY TO MODULAR SOFTWARE AND MAY NOT BE   ***
*** USED, COPIED, EXAMINED, OR DISCLOSED WITHOUT A VALID LICENSE     ***
*** FROM MODULAR SOFTWARE.                                           ***
***                                                                  ***
************************************************************************
************************************************************************
*
*
* Subroutine to look for a match
*
* OBJ     - Parsed object that we are looking in
* NODE    - First node to look into
* E.FLG   - Indicates whether match must go all the way to the end of OBJ
* FLG     - YES if match found.  NO otherwise.
* NODE.ID - Syntax that was found.
* ELS     - Extracted elements.
* I       - Next position we would have looked at
*
* The format of the syntax file is:
*
*     001 unused
*     002 match on this keyword
*     003 match on future keyword with var/fmt string
*     004 match on future keyword with string
*     005 match on end-of-statement loading string
*     006 match on end-of-statement loading var/fmt
*
*
       $INCLUDE PC.COMMON
*
       NO.PAR = 0
       NO.DA = 0
       EL.NO = 0
       ELS = ''
       FLG = -1
       POS = 0
*
       NODE = NODE.0
*
       I1 = DCOUNT(OBJ,SVM)
       I = 1
       LOOP WHILE I <= I1 AND FLG = -1 DO
          EL = OBJ<1,1,I>
          IF EL = '' THEN
             I = I + 1
          END ELSE
*
* Check to see if element is in ATTR 2 (immediate matches)
*
             LOCATE EL IN NODE<2,1,1> SETTING LOC THEN
                IF NODE<2,3,LOC> THEN
                   GOSUB 200
                   ELS<EL.NO> = EL
                END
                NODE.ID = NODE<2,2,LOC>
                GOSUB 100
                I = I + 1
*
             END ELSE
                BEGIN CASE
                   CASE EL = ' ' AND ELS<EL.NO> = ''
                      I = I + 1
                   CASE NODE<3> <> '' OR NODE<4> <> ''
                      GOSUB 200
                      ELS<EL.NO,-1> = EL
                      DA.FLG = 0
                      NO.PAR = ( EL = '(' ) - ( EL = ')' )
                      NO.DA = ( EL = '<' ) - ( EL = '>' )
                      I = I + 1
                      F = NO
                      LOOP WHILE I <= I1 AND NOT(F) DO
                         EL = OBJ<1,1,I>
                         IF NO.PAR OR NO.DA THEN
                            ELS<EL.NO,-1> = EL
                            NO.PAR = NO.PAR + ( EL = '(' ) - ( EL = ')' )
                            NO.DA = NO.DA + ( EL = '<' ) - ( EL = '>' )
                         END ELSE
                            IF NODE<3> <> '' THEN
                               LOCATE EL IN NODE<3,1,1> SETTING LOC THEN
                                  GOSUB 300
                                  IF (ELS<EL.NO,1>)[1,1] MATCHES '1A' AND (ELS<EL.NO,2> <> '' OR ELS<EL.NO,3> <> '' ) THEN
                                     GOSUB 400
                                     IF NODE<3,3,LOC> THEN
                                        ELS<EL.NO> = EL
                                        GOSUB 200
                                     END
                                     NODE.ID = NODE<3,2,LOC>
                                     GOSUB 100
                                     GOSUB 200
                                     F = YES
                                  END
                               END
                            END
                            IF NODE<4> <> '' AND NOT(F) THEN
                               LOCATE EL IN NODE<4,1,1> SETTING LOC THEN
                                  GOSUB 200
                                  IF NODE<4,3,LOC> THEN
                                     ELS<EL.NO> = EL
                                     GOSUB 200
                                  END
                                  NODE.ID = NODE<4,2,LOC>
                                  GOSUB 100
                                  GOSUB 200
                                  F = YES
                               END
                            END
                            IF NOT(F) THEN
                               ELS<EL.NO,-1> = EL
                               NO.PAR = NO.PAR + ( EL = '(' ) - ( EL = ')' )
                               NO.DA = NO.DA + ( EL = '<' ) - ( EL = '>' )
                            END
                         END
                         I = I + 1
                      REPEAT
*
                      IF NODE<6> <> '' AND NOT(F) THEN
                         GOSUB 300
                         IF (ELS<EL.NO,1>)[1,1] MATCHES '1A' AND (ELS<EL.NO,2> <> '' OR ELS<EL.NO,3> <> '' ) THEN
                            GOSUB 400
                            NODE.ID = NODE<6>
                            FLG = 1
                            F = YES
                         END
                      END
*
                      IF NODE<5> <> '' AND NOT(F) THEN
                         NODE.ID = NODE<5>
                         FLG = 1
                      END
                   CASE NODE<5> <> '' OR NODE<6> <> ''
                      GOSUB 200
                      ELS<EL.NO,-1> = EL
                      LOOP
                         I = I + 1
                      UNTIL I > I1 DO
                         ELS<EL.NO,-1> = OBJ<1,1,I>
                      REPEAT
                      IF NODE<6> <> '' THEN
                         GOSUB 300
                         IF (ELS<EL.NO,1>)[1,1] MATCHES '1A' AND (ELS<EL.NO,2> <> '' OR ELS<EL.NO,3> <> '' ) THEN
                            GOSUB 400
                            NODE.ID = NODE<6>
                            FLG = 1
                         END
                      END
                      IF NODE<5> <> '' AND FLG <> 1 THEN
                         NODE.ID = NODE<5>
                         FLG = 1
                      END
                   CASE YES
                      FLG = 0
                END CASE
             END
          END
       REPEAT
*
       IF FLG = -1 THEN
          BEGIN CASE
             CASE NODE<6> <> ''
                NODE.ID = NODE<6>
                FLG = 1
             CASE YES
                FLG = 0
          END CASE
       END
*
       IF NOT(POS) THEN POS = I + 1
*
       IF FLG THEN
          I1 = DCOUNT(ELS,AM)
          FOR I = 1 TO I1
             T = ELS<I>
             IF TRIM(T<1,1>) = '' THEN
                T = DELETE(T,1,1,0)
             END
             J1 = DCOUNT(T,VM)
             IF TRIM(T<1,J1>) = '' THEN
                T = DELETE(T,1,J1,0)
                J1 = J1 - 1
             END
             TT = ''
             FOR J = 1 TO J1
                TT = TT : T<1,J>
             NEXT J
             ELS<I> = TT
          NEXT I
       END
*
       RETURN
*
100 REM NEXT NODE
*
       READ NODE FROM OBJ.FD , NODE.ID ELSE STOP 'PC','Cannot read OBJ tree element ' : NODE.ID
       IF NODE<6> <> '' AND E.FLG THEN
          FLG = 1
          NODE.ID = NODE<6>
          POS = I + 1
       END
*
       RETURN
*
200 REM BUMP EL.NO
*
       IF NOT(EL.NO) THEN
          EL.NO = 1
       END ELSE
          IF TRIM(ELS<EL.NO>) = '' THEN ELS<EL.NO> = ''
          IF ELS<EL.NO> <> '' THEN
             EL.NO = EL.NO + 1
          END
       END
*
       RETURN
*
300 REM trim ELS value array
*
       IF TRIM(ELS<EL.NO,1>) = '' THEN
          ELS = DELETE(ELS,EL.NO,1,0)
       END
       I1 = DCOUNT(ELS<EL.NO>,VM)
       IF TRIM(ELS<EL.NO,I1>) = '' THEN
          ELS = DELETE(ELS,EL.NO,I1,0)
       END
*
       RETURN
*
400 REM load ELS from {V} operator
*
       I1 = DCOUNT(ELS<EL.NO>,VM)
       FOR I = 2 TO I1
          ELS<EL.NO+1,-1> = ELS<EL.NO,I>
       NEXT I
       ELS<EL.NO> = ELS<EL.NO,1>
       EL.NO = EL.NO + 2
*
       RETURN
*
      CW = '(C) Copyright 1985-1989 Modular Software.  All rights reserved.'
   END
