001000$CONTROL USLINIT, NOLIST, POST85
001100 IDENTIFICATION DIVISION.
001200 PROGRAM-ID. ESIS.
002600 AUTHOR.  MARK WONSIL.
002700 INSTALLATION. 4M.
002800 DATE-WRITTEN. FRI, FEB 16, 2001.
002900 DATE-COMPILED.
003000 ENVIRONMENT DIVISION.
003100 CONFIGURATION SECTION.
003200 SOURCE-COMPUTER. HP-3000.
003300 OBJECT-COMPUTER. HP-3000.
003400 INPUT-OUTPUT SECTION.
003500 FILE-CONTROL.
003600     SELECT ESISIN ASSIGN TO "ESISIN".
003700 DATA DIVISION.
003800 FILE SECTION.
003900
004000 FD ESISIN
004100    RECORDING MODE IS F
004200    RECORD CONTAINS 1024 CHARACTERS.
004300 01 SRCREC               PIC X(1024).
004400
004500 WORKING-STORAGE SECTION.
004600 77 ILEN                 PIC S9(4) COMP.
004700 77 SITEM                PIC S9(4) COMP.
004800
004900 01 I                    PIC S9(4) COMP.
005000 01 SP                   PIC S9(4) COMP.
005100 01 ELEMENT-ARRAY.
005200    03  ELEMENT-STACK    PIC X(80) OCCURS 100 TIMES.
005300 01 RECCNT               PIC 9999999.
005400
005500 01 ESISREC.
005600    03  ESIS-TYPE        PIC X.
005700        88  IS-ATTR      VALUE "A".
005800        88  IS-DATA      VALUE "-".
005900        88  IS-START-TAG VALUE "(".
006000        88  IS-END-TAG   VALUE ")".
006100        88  IS-PI        VALUE "?".
006200    03  ESIS-DATA        PIC X(1023).
006300
006400 01 EOF-STAT             PIC X(1) VALUE SPACES.
006500    88 EOF-INPUT                  VALUE "Y".
006600
006700 PROCEDURE DIVISION.
006800 ESIS.
006900
007000     OPEN INPUT ESISIN.
007100
007200     MOVE ZEROS TO RECCNT.
007300     PERFORM UNTIL EOF-INPUT
007400       READ ESISIN
007500         AT END
007600           MOVE "Y" TO EOF-STAT
007700         NOT AT END
007800           PERFORM PROCESS-RECORD
007900       END-READ
008000     END-PERFORM.
008100
008200     CLOSE ESISIN.
008300
008400     STOP RUN.
008500
008600******************************************************************
008700
008800 PROCESS-RECORD.
008900
009000     IF IS-START-TAG
009100       IF (SP = 100)
009200         DISPLAY "ELEMENT STACK OVERFLOW"
009300*        EXIT PROGRAM
009400       ELSE
009500         ADD 1 TO SP
009600         MOVE ESIS-DATA TO ELEMENT-STACK (SP)
009700       END-IF
009800     END-IF.
009900
010000     IF IS-END-TAG
010100       SUBTRACT 1 FROM SP
010200     END-IF.