
      HED SYNTAX SUBROUTINES
      SPC 2 
**                      **
***  SUBSCRIPT SYNTAX  ***
**                      **
* 
*  SBSCK ASSUMES A PRIOR ARRAY OPERAND REFERENCED THROUGH 
*  THE POINTER ARYAD.  ENTRY IS MADE WITH A CHARACTER IN
*  (A); EXIT TO (P+1) IF THIS CHARACTER IS NOT '(' OR '[',
*  OTHERWISE ANALYZE THE SUBSCRIPT WHICH MUST FOLLOW, 
*  EXITING TO (P+2).  SBSCK HANDLES BOTH SINGLE AND DOUBLE
*  SUBSCRIPTS.  IF DFLAG=0 THE SUBSCRIPT IS FROM A
*  <DIM STATEMENT> AND THE BOUNDS MUST BE POSITIVE
*  INTEGERS.  IF DFLAG=1 THE SUBSCRIPT RE-DIMENSIONS A
*  MATRIX AND A COMMA SEPARATES THE TWO BOUNDS OF A 
*  DOUBLE SUBSCRIPT AND AN END-OF-FORMULA OPERATOR
*  FOLLOWS THE LAST BOUND.  OTHERWISE A 'SUBSCRIPT' 
*  COMMA SEPARATES THE TWO PARTS OF A DOUBLE SUBSCRIPT
*  AND NO END-OF-FORMULA OPERATOR APPEARS.  IN ALL CASES, 
*  THE ARRAY OPERAND IS MARKED AS ONE- OR TWO-DIMENSIONAL.
*  IF THE SUBSCRIPT BELONGS TO A STRING VARIABLE IN A 
*  <DIM STATEMENT>, IT MUST HAVE ONE AND ONLY ONE BOUND 
* CONSISTING OF A POSITIVE INTEGER NOT LARGER THAN 72.
*  IN THIS CASE ARYAD HOLDS A DUMMY POINTER SINCE STRING
*  VARIABLES ARE NOT MARKED WITH DIMENSIONALITY.
* 
#SBCK LDB .-2       '(' 
      JSB SYMCK       OR
      DEF LBRAC-1       '[' ? 
      JMP SBSCK,I   NO, RETURN TO (P+1) 
      ISZ SBSCK     YES, SET RETURN TO (P+2)
      LDA ARYAD,I   SET 
      ADA .-2         ARRAY TO
      STA ARYAD,I       SINGLE DIMENSION
      LDA LBOP      RECORD
      STA SBPTR,I     '[' 
      ISZ DFLAG     BUMP MAGIC FLAG 
      CLB,INB       DIM 
      CPB DFLAG       STATEMENT?
      JMP SBSC5     YES 
      LDB .+7       NO, SAVE FSC
      JSB FRCUR       LOCAL VARIABLES 
      LDB SBSCK     SAVE
      STB SSTAK,I     RETURN
      ISZ SSTAK         ADDRESS 
      LDB ARYAD     SAVE ARRAY
      STB SSTAK,I     REFERENCE 
      ISZ SSTAK     RESERVE SPACE FOR '(' COUNT 
      LDA .-9       TURN OFF 'STORE 
      STA MSFLG       ALLOWED' MODE 
      JSB FSC       DEMAND SUBSCRIPT
      CCB           RESTORE 
      ADB SSTAK 
      STB SSTAK       ARRAY 
      LDB 1,I 
      STB ARYAD         REFERENCE 
      LDB DFLAG     'MATRIX SUBSCRIPT'
      CPB .+2         MODE? 
      JMP SBSC4     YES 
SBSC1 CCB           NO, SEEK
      JSB SYMCK       'SUBSCRIPT' 
      DEF SCMMA-1       COMMA 
      JMP SBSC3+1   NONE FOUND
      ISZ ARYAD,I   SET ARRAY AS DOUBLY-SUBSCRIPTED 
      CLB,INB       DIM 
      CPB DFLAG       STATEMENT?
      JMP SBSC3     YES 
      JSB FSC       NO, DEMAND SECOND SUBSCRIPT 
      RSS 
SBSC3 JSB PRGIN     DEMAND SECOND BOUND 
      CCB           RESTORE 
      ADB DFLAG       ORIGINAL
      STB DFLAG         DFLAG VALUE 
      CPB .+1       'MATRIX SUBSCRIPT' MODE?
      JSB SBPUD     YES 
      LDB .-2       DEMAND
      JSB SYMCK       ')' OR
      DEF RPARN-1       ']' 
      JSB SERRS+23,I  NOT FOUND 
      LDA RBOP      RECORD
      STA SBPTR,I     ']' 
      JSB SBPUD     UPDATE POINTER
      JSB GETCR     FETCH NEXT
      NOP             CHARACTER 
      CLB           DIM 
      CPB DFLAG       STATEMENT?
      JMP SBSCK,I   YES 
      CCB           NO, 
      ADB SSTAK       RESTORE 
      STB SSTAK         THE 
      LDB SSTAK,I         RETURN
      STB SBSCK             ADDRESS 
      JSB FPOP      RESTORE FSC 
      JMP SBSCK,I     LOCAL VARIABLES 
SBSC4 CCB 
      JSB SYMCK     COMMA?
      DEF COMMA-1 
      JMP SBSC3+1   NO
      JMP SBSC1+4   YES 
SBSC5 JSB PRGIN     DEMAND DECLARED BOUND 
      ISZ SFLAG     STRING VARIABLE?
      JMP SBSC1     NO
      ADB M73        YES, DOES BOUND
      SSB,RSS            EXCEED 72? 
      JSB SERRS+30,I  YES 
      JMP SBSC3+1   NO
      SKP 
**                             ** 
***  RECORD ARRAY IDENTIFIER  *** 
**                             ** 
* 
*  ARRAY IDENTIFIER LEFT IN TEMP+1, ARRAY OPERAND ADDRESS 
*  PUT IN ARYAD.  EXIT WITH FOLLOWING CHARACTER IN TEMP+2 
*  AND IN (A).
* 
#ARID JSB LTR       FETCH IDENTIFIER
      JSB SERRS+26,I  NONE FOUND
      LDB ARRID     SET 
      STB STRID       EXIT
**                              **
***  RECORD STRING IDENTIFIER  ***
**                              **
* 
*  STRING IDENTIFIER LEFT IN TEMP+1, SFLAG SET TO -1. 
*  EXIT WITH FOLLOWING CHARACTER IN (A).  EXIT TO ERROR 
*  IF A STRING VARIABLE IS NOT PERMITTED IN THIS CONTEXT. 
* 
#STRI CPA .+44B     '$' ? 
      JMP STRI1     YES 
      LDA SBPTR     NO, SET POINTER TO
      STA ARYAD       VARIABLE LOCATION 
      LDA TEMP+1    RECORD
      LDB .+56B       ARRAY 
      JSB STROP         VARIABLE
      LDA TEMP+2    RETRIEVE FOLLOWING
      JMP STRID,I     CHARACTER 
STRI1 LDA SFLAG     STRING VARIABLE 
      CPA SBPTR       PERMITTED?
      CCA,RSS       YES 
      JSB SERRS+27,I  NO
      STA SFLAG     SET FLAG TO 'STRING OCCURRED' 
      LDA TEMP+1    RECORD
      LDB .+53B       STRING
      JSB STROP         VARIABLE
      LDA SSTAK     SET POINTER TO DUMMY
      STA ARYAD       VARIABLE LOCATION 
      JSB GETCR     FETCH 
      NOP             NEXT
      JMP STRID,I       CHARACTER 
**                             ** 
***  RECORD A STRING OPERAND  *** 
**                             ** 
* 
*  DEMAND A STRING VARIABLE OR A STRING CONSTANT.  EXIT 
*  TO ERROR IF NEITHER IS FOUND, ELSE EXIT WITH THE NEXT
*  CHARACTER IN (A).
* 
#RSTO LDA SBPTR     SEEK
      STA SFLAG       STRING
      JSB VAROP         OPERAND 
      JMP RSTO1     1ST CHARACTER NOT A LETTER
      ISZ SFLAG     STRING VARIABLE?
      JSB SERRS+28,I  NO
      JMP RSTOP,I   YES 
RSTO1 JSB SBPUD     DEMAND A
      JSB GETST       STRING
      JMP RSTOP,I       CONSTANT
**                             ** 
***  FETCH A STRING CONSTANT  *** 
**                             ** 
* 
*  EXIT TO ERROR IF (A) # " UPON ENTRY.  ELSE SAVE CURRENT
*  BUFFER POINTER AND PACK THE INPUT STRING INTO THE BUFFER 
*  FOLLOWING THE INITIAL BUFFER WORD.  EXIT TO ERROR IF NO
*  CLOSING " IS FOUND.  RECORD THE OPENING " ALONG WITH A 
*  COUNT OF THE STRING CHARACTERS AND EXIT WITH THE NEXT
*  CHARACTER IN (A).  EXIT TO ERROR IF STRING EXCEEDS 
*   72 CHARACTERS.
* 
#GTST LDB SBPTR     SAVE SYNTAX 
      STB ARYAD       BUFFER POINTER
      CPA .+42B     " ? 
      CLB,RSS       YES, SET (B) = 0
      JSB SERRS+28,I  NO
      JSB CHRST     RECORD STRING CONSTANT
      JSB SERRS+29,I  NO CLOSING QUOTE
      LDA QUOTE     RECORD CHARACTER COUNT
      ADA TEMP+1      ALONG WITH
      STA ARYAD,I       OPENING QUOTE 
      ADA D1111      MORE THAN 72 
      SSA,RSS         CHARACTERS? 
      JSB SERRS+30,I  YES 
      JSB GETCR     NO, FETCH 
      NOP             NEXT
      JMP GETST,I       CHARACTER 
**                               ** 
***  CHECK FOR USING STATEMENT  *** 
**                               ** 
* 
*  SCAN THE INPUT STRING FOR A USING OPERATOR. IF NONE FOUND, EXIT
*  TO (P+1) WITH THE INPUT STRING AND SYNTAX BUFFER AS UPON ENTRY.
*  OTHERWISE, CHECK FOR A LEGAL OPERATOR FOLLOWING THE 'USING' AND
*  EXIT TO (P+2) AFTER SAVING IT IN THE SYNTAX BUFFER, WITH (A) 
*  = THE NEXT CHARACTER.
#USCK STA SBPTR,I   (A) = NEXT CHARACTER
      LDA .+5       5 CHARACTERS
      STA MAXCR       ALLOWED 
      CCB           LOOK
      LDA USTMA     LOOK
      JSB TBSRH         'USING' 
      JMP USCK3     NOT FOUND 
      ISZ USTCK 
      JSB LTR       NEXT CHARACTER LETTER?
      JMP USCK1     NO
      CPA .+44B     YES, '$' FOLLOWS? 
      RSS           YES 
      JSB SERRS+34,I  NO
      LDB SBPTR     ENABLE STRING 
      STB SFLAG       VARIABLE
      JSB STRID     STORE STRING
      JSB SBSCK 
      NOP 
      JMP USTCK,I 
USCK1 CPA .+42B     QUOTE?
      JMP USCK2     YES 
      JSB BCKSP     SEARCH
      CCB             FOR 
      STB GFLAG         STATEMENT 
      JSB PRGIN           NUMBER
      JMP USTCK,I   FOUND ONE 
      JSB SERRS+34,I  NOT FOUND, ERROR
USCK2 JSB SBPUD     ADVANCE BUFFER POINTER
      JSB GETST     RECORD STRING CONTSTANT 
      JMP USTCK,I 
USCK3 CCB           RESTORE 
      ADB SBPTR       BUFFER
      STB SBPTR         POINTER 
      LDA .+3       RESET FOR 
      STA MAXCR       3 CHARACTERS
      JSB BCKSP     RESTORE INPUT STRING
      JMP USTCK,I 
      SKP 
USTMA DEF USTMT 
STTYP DEF STYPS 
MCREL DEF MRELS 
LENCN OCT 100337
TOOP  OCT 76000 
INPOP OCT 63000 
EXPOP OCT 24000 
D1111 OCT -1111 
D577  OCT -577
B133  OCT 133 
      HED STATEMENT SYNTAX PROCESSORS 
      ORG 34000B
BB133 OCT 133 
D133  OCT -133
DCOM0 DEF COMS0 
SFLGA DEF SFLAG 
D53   OCT -53 
M103  DEC -103
EOSTA DEF EOST
***                            ** 
**  <RESTORE STATEMENT> SYNTAX  **
***                            ** 
* 
RSTRS JSB GETCR     END OF STATEMENT? 
      JMP RSTR1     YES 
      JSB BCKSP     NO, DEMAND
      JSB PRGIN       SEQUENCE NUMBER 
      JMP EOSTA,I   DEMAND END OF STATEMENT 
RSTR1 ISZ SBPTR     RECORD DUMMY OPERAND
      JMP ACCSA,I 
* 
***                          ** 
**  <FILES STATEMENT> SYNTAX  **
***                          ** 
* 
FILES CLA,RSS       SUPPRESS BLANKS 
* 
***                        ** 
**  <REM STATEMENT> SYNTAX  **
***                        ** 
* 
REMS  LDA .+15B     DUMMY STATEMENT TERMINATOR
      CLB,INB       SET CHARACTER FLAG TO 'LOW HALF'
      JSB CHRST     RECORD REMAINDER OF STATEMENT 
      JMP ACCSA,I     AS A STRING 
***                          ** 
**  <CHAIN STATEMENT> SYNTAX  **
***                          ** 
* 
CHANS JSB RSTOP     REQUEST STRING OPERAND
      CCB 
      JSB SYMCK     COMMA FOLLOWS?
      DEF COMMA-1     A COMMA?
      JMP EOSTA,I   NO, DEMAND END-OF-STATEMENT 
      CCB           DISALLOW
      STB SFLGA,I     STRING VARIABLES
      JSB FSC       GET A FORMULA FOR LINE NO.
      JMP EOSTA,I   DEMAND END-OF-STATEMENT 
* 
***                          ** 
**  <ENTER STATEMENT> SYNTAX  **
***                          ** 
* 
ENTRS JSB GETCR     FETCH FIRST CHARACTER 
      JSB SERRS+35,I NONE FOUND 
      ISZ SBPTR 
      CCB 
      JSB SYMCK     FIRST CHARACTER A '#'?
      DEF HATCH-1 
      JMP ENTR1     NO
      JSB VAROP     YES, SEEK SIMPLE VARIABLE 
      JSB SERRS+35,I  NONE FOUND
      NOP 
      CPA .+15B     CR FOLLOWS? 
      JMP ACCST     YES, ACCEPT STATMENT
      CCB           NO
      JSB SYMCK     COMMA?
      DEF COMMA-1 
      JSB SERRS+6,I NO
      JMP  ENTR2
ENTR1 EQU * 
      JSB BCKSP     BACKUP ONE CHARACTER
      CCB           RESTORE 
      ADB SBPTR       BUFFER
      STB SBPTR         POINTER 
ENTR2 EQU * 
      JSB FSC       DEMAND A FORMULA
      CCB 
      JSB SYMCK     COMMA FOLLOWS?
      DEF COMMA-1 
      JSB SERRS+6,I NO
      JSB VAROP     DEMAND A SIMPLE VARIABLE
      JSB SERRS+35,I  NONE FOUND
      NOP 
      CCB 
      JSB SYMCK     COMMA FOLLOWS?
      DEF COMMA-1 
      JSB SERRS+6,I NO
      LDB SBPTR     YES, ENABLE 
      STB SFLGA,I     STRING VARIABLE 
      JSB VAROP     SEEK VARIABLE OPERAND 
      JSB SERRS+35,I  NONE FOUND
      NOP 
      JMP EOSTA,I   DEMNAD END-OF-STATEMENT 
* 
***                          ** 
**  <USING STATEMENT> SYNTAX  **
***                          ** 
* 
USINS JSB  SERRS+33,I  USING ILLEGAL AS FIRST WORD
* 
***                           **
**  <ASSIGN STATEMENT> SYNTAX  ** 
***                           **
* 
ASNS  JSB RSTOP 
      CCB 
      JSB SYMCK     RECORD
      DEF COMMA-1     A COMMA 
      JSB SERRS+6,I NOT A COMMA 
      CCB           DISALLOW
      STB SFLGA,I   STRING VARIABLE 
      JSB FSC       RECORD FORMULA
      CCB 
      JSB SYMCK     RECORD
      DEF COMMA-1     A COMMA 
      JSB SERRS+6,I NOT A COMMA 
      JSB VAROP     SEEK A NUMERIC OPERAND
      JSB SERRS+35,I   NONE FOUND 
      NOP 
      CCB 
      JSB SYMCK     COMMA 
      DEF COMMA-1     NEXT? 
      RSS 
      JSB RSTOP     DEMAND A STRING OPERAND 
      JMP EOSTA,I   DEMAND END-OF-STATEMENT 
      HED SYNTAX SUBROUTINES
**                             ** 
***  SEEK A VARIABLE OPERAND  *** 
**                             ** 
* 
*  VAROP SCANS FOR AND RECORDS A VARIABLE OPERAND.  IF
*  THE FIRST CHARACTER IS NOT A LETTER, EXIT IS TO (P+1)
*  WITH THE CHARACTER IN (A).  OTHERWISE A VARIABLE 
*  OPERAND IS RECORDED AND UPON EXIT (A) CONTAINS THE 
*  FOLLOWING CHARACTER.  EXIT IS TO (P+2) AFTER FINDING 
*  AN ARRAY OR STRING VARIABLE ALONG WITH ANY FOLLOWING 
*  SUBSCRIPT.  IF A STRING VARIABLE IS FOUND AND SFLAG =
*  SBPTR, SET SFLAG = -1; IF SFLAG # SBPTR, NO STRING 
*  VARIABLE IS PERMITTED AT THIS POINT: EXIT TO ERROR.
*  AFTER FINDING A SIMPLE VARIABLE EXIT TO (P+3) WITH 
*  TEMP+2 = (A) AND THE LAST CHARACTER OF THE SIMPLE
*  VARIABLE IN TEMP+1.  IF INSIDE A <DEF STATEMENT>,
*  SIMPLE VARIABLES ARE COMPARED WITH THE PARAMETER AND 
*  MATCHES ARE MARKED.
* 
#VROP JSB LTR       LETTER? 
      JMP VAROP,I   NO, EXIT VIA (P+1)
      ISZ VAROP     YES 
      CPA .+50B     '(' ? 
      JMP VARO4     YES 
      CPA BB133     NO, '[' ? 
      JMP VARO4     YES 
      CPA .+44B     NO, '$' ? 
      JMP VARO4     YES 
      ISZ VAROP     NO
      JSB DIGCK     DIGIT NEXT? 
      JMP VARO1     NO
      LDA TEMP+1    YES, LOAD LETTER, 
      ADB .+48        RESTORE DIGIT,
      STB TEMP+1        AND RECORD
      JSB STROP           SIMPLE VARIABLE 
      JSB GETCR     FETCH 
      NOP             AND SAVE
      STA TEMP+2        NEXT
      JMP VARO2           CHARACTER 
VARO4 JSB STRID     RECORD ARRAY OR STRING VARIABLE 
      JSB SBSCK     FETCH THE SUBSCRIPT 
      RSS           NO SUBSCRIPT
      JMP VAROP,I   EXIT VIA (P+2)
      LDB VAROP     WAS VAROP CALLED FOR
      CPB DCOM0       DIM OR COM SYNTAX?
      JSB SERRS+5,I YES--ERROR
      JMP VAROP,I   NO--EXIT
VARO1 LDA TEMP+1    RETRIEVE LETTER,
      LDB .+57B       SET 'NO DIGIT', 
      JSB STROP         AND RECORD
      LDA TEMP+2          SIMPLE VARIABLE 
VARO2 CLB           INSIDE A
      CPB PFLAG       'DEF' STATEMENT?
      JMP VAROP,I   NO, EXIT VIA (P+3)
      CCB           YES,
      ADB SBPTR       ISOLATE 
      LDA 1,I           LATEST
      AND B777            OPERAND 
      CPA PFLAG     IS IT THE PARAMETER?
      JMP *+3       YES 
VARO3 LDA TEMP+2    NO, RETRIEVE CHARACTER
      JMP VAROP,I     AND EXIT VIA (P+3)
      LDA 1,I       FLAG
      IOR FLGBT       OPERAND 
      STA 1,I           AS
      JMP VARO3           PARAMETER 
**                              **
***  PROCESS CHARACTER STRING  ***
**                              **
* 
*  UPON ENTRY (A) CONTAINS THE STRING DELIMITER AND (B) 
*  INDICATES WHETHER THE FIRST CHARACTER IS TO BE STORED
*  IN THE LOWER HALF OF THE CURRENT BUFFER WORD ( (B) = 1)
*  OR THE UPPER HALF OF THE NEXT BUFFER WORD ( (B) = 0).
*  EXIT TO (P+1) ON EMPTYING THE INPUT STRING. EXIT TO
*  (P+2) ON FINDING THE STRING DELIMITER.  BLANKS ARE NOT 
*  STRIPPED OUT OF THE INPUT STRING IF (A) # 0 UPON ENTRY.  UPON
*  EXIT SBPTR POINTS TO THE FIRST BUFFER WORD NOT CONTAINING PART OF
*  THE STRING WHILE TEMP+1 CONTAINS A COUNT OF THE STRING 
*  CHARACTERS BIASED BY THE VALUE OF (B) UPON ENTRY.
* 
#CRST STB TEMP+1    SET CHARACTER FLAG AND COUNTER
      STA TEMP+2    NOTE TERMINATOR CHARACTER 
      LDB .+10      IF (A) # 0
      SZA             STOP BLANK
      STB BLANK         SUPPRESSION 
CHRS1 JSB GETCR     FETCH CHARACTER 
      JMP CHRS3+1   NONE FOUND
      LDA B         ALLOW LOWER CASE
      CPA TEMP+2    TERMINATOR? 
      JMP CHRS3     YES 
      LDB TEMP+1    NO, COUNT CHARACTER 
      SLB,INB         AND SELECT WORD HALF
      JMP CHRS2     LOW HALF
      JSB SBPUD     HIGH HALF, MOVE TO NEXT WORD
      ALF,SLA,ALF   POSITION CHARACTER AND SKIP 
CHRS2 IOR SBPTR,I   COMBINE WITH PREVIOUS CHARACTER 
      STA SBPTR,I 
      STB TEMP+1    SAVE FLAG/COUNTER 
      JMP CHRS1 
CHRS3 ISZ CHRST     SET EXIT TO (P+2) 
      JSB SBPUD     ADVANCE POINTER 
      LDB .+40B     RESTORE BLANK 
      STB BLANK       SUPPRESSION 
      JMP CHRST,I 
      SKP 
**                         ** 
***  DELETE SOME PROGRAM  *** 
**                         ** 
* 
*  THAT PART OF THE PROGRAM REFERENCED BY CORE LOCATIONS
*  (TEMP+1)+(A) THROUGH (TEMP+1)+(B)-1 INCLUSIVE IS 
*  DELETED BY SLIDING UP ALL OF THE PROGRAM FROM
*  (TEMP+1)+(B) TO (PBPTR)-1 (I.E., THE REST OF THE 
*  PROGRAM FOLLOWING THE 'GAP').  PBPTR IS THEN 
*  UPDATED TO POINT TO LAST WORD +1 OF THE PROGRAM. 
* 
#DLPR ADA TEMP+1    COMPUTE INITIAL 
      STA TEMP+2      DESTINATION ADDRESS 
      ADB TEMP+1    COMPUTE INITIAL SOURCE ADDRESS
DELP1 CPB PBPTR     DONE? 
      JMP DELP2     YES 
      LDA 1,I       NO, TRANSFER
      STA TEMP+2,I    A WORD
      ISZ TEMP+2    BUMP
      INB             POINTERS
      JMP DELP1 
DELP2 LDA TEMP+2    UPDATE
      STA PBPTR       END-OF-PROGRAM
      JMP DELPR,I       POINTER 
      SKP 
**                                   ** 
***  STATEMENT SYNTAX ENTRY POINTS  *** 
**                                   ** 
SYNTB DEF ASNS      ASSIGN
      DEF USINS     USING 
      DEF IMAGS     IMAGE 
      DEF COMS      COM 
      DEF LETS      LET 
      DEF DIMS      DIM 
      DEF DEFS      DEF 
      DEF REMS      REM 
      DEF GOTOS     GOTO
      DEF IFS       IF
      DEF FORS      FOR 
      DEF NEXTS     NEXT
      DEF GOTOS     GOSUB 
      DEF ENDS      RETURN
      DEF ENDS      END 
      DEF ENDS      STOP
      DEF DATAS     DATA
      DEF INPTS     INPUT 
      DEF READS     READ
      DEF PRINS     PRINT 
      DEF RSTRS     RESTORE 
      DEF MATS      MAT 
      DEF FILES     FILES 
      DEF CHANS     CHAIN 
      DEF ENTRS     ENTER 
      DEF LET0      'IMPLIED' LET 
**                        **
***  ACCEPT A STATEMENT  ***
**                        **
* 
*  A CORRECT STATEMENT IS ADDED TO THE PROGRAM BUFFER.
*  IF ITS SEQUENCE NUMBER IS THE HIGHEST SO FAR, ONLY 
*  THE END-OF-PROGRAM POINTER REQUIRES CHANGE, SINCE THE
*  STATEMENT IS TRANSLATED IMMEDIATELY BELOW THE PREVIOUS 
*  PROGRAM.  OTHERWISE THE NEW STATEMENT IS INSERTED INTO 
*  THE PROGRAM IN PROPER SEQUENTIAL POSITION.  IF ITS 
*  SEQUENCE NUMBER COINCIDES WITH THAT OF A PREVIOUS
*  PROGRAM STATEMENT, IT REPLACES IT, WITH SPACE MADE OR
*  DELETED IN THE PROGRAM AS NECESSARY.  EXIT TO EXEC.
*  IF STATEMENT LENGTH = 0 THE STATEMENT WAS REJECTED DUE TO
*  A STORAGE OVERFLOW IN TAPE MODE.  IF IN KEYBOARD MODE AND
*  SYMTB = 4 AT LEAST ONE OVER/UNDERFLOW OCCURRED WHILE ANALYZING 
*  THE STATEMENT SO EMIT THE ERROR; OTHERWISE ECHO A LINE FEED. 
*  IF IN TAPE MODE MOVE THE START-OF-RECORD POINTER TO THE START
*  OF THE NEXT BUFFER AND IF IT IS COMPLETED SYNTAX IT NOW, ELSE
*  EXIT TO EXEC.
* 
ACCST LDB SBUFA 
      INB 
      LDA SBUFA     COMPUTE 
      CMA,INA         STATEMENT 
      ADA SBPTR         LENGTH
      SZA,RSS       UNPROCESSED STATEMENT?
      JMP ACCS6     YES 
      STA 1,I       NO, STORE LENGTH IN STATEMENT 
      STA TEMP+2    SAVE IT 
      LDA PBPTR     FIND STATEMENT'S
      LDB SBUFA,I     SEQUENTIAL
      JSB FNDPS         POSITION
      JMP ACCS4     APPEND STATEMENT TO PROGRAM 
      JMP ACCS2     INSERT STATEMENT INTO PROGRAM 
      INB           REPLACE PRIOR STATEMENT 
      LDA 1,I       COMPARE LENGTH
      CMA,INA         OF NEW STATEMENT
      ADA TEMP+2        WITH THAT OF OLD
      SZA,RSS       EQUAL?
      JMP ACCS1     YES 
      SSA,RSS       NO, LONGER? 
      JMP ACCS2+1   YES 
      LDA TEMP+2    NO, SHORTER 
      LDB 1,I       LOAD LENGTH OF OLD STATEMENT
      JSB DELPR     DELETE EXTRA LENGTH 
ACCS1 LDB SBUFA     LOAD FIRST SOURCE ADDRESS 
      LDA 1,I       TRANSFER
      STA TEMP+1,I    A WORD
      ISZ TEMP+1    ADVANCE DESTINATION 
      INB             AND SOURCE ADDRESSES
      CPB SBPTR     DONE? 
      JMP ACCS5     YES 
      JMP ACCS1+1   NO
ACCS2 LDA TEMP+2    LOAD SPACE REQUIREMENT
      ADA SBUFA     UPDATE POINTER
      STA SBUFA       TO NEW STATEMENT
      ADA TEMP+2    RESET 
      LDB SBPTR       END OF STATEMENT
      STA SBPTR         POINTER 
      STA TEMP+2    INITIALIZE DESTINATION ADDRESS
      CMA           USER
      ADA LWAUS       SPACE 
      SSA               OVERFLOW? 
      JSB SERRS,I   YES 
      LDA SBUFA     NO, UPDATE POINTER
      STA PBPTR       TO END-OF-PROGRAM 
ACCS3 CPB TEMP+1    EVERYTHING MOVED? 
      JMP ACCS1     YES 
      CCA           NO, BACK UP 
      ADA TEMP+2      SOURCE AND
      STA TEMP+2        DESTINATION 
      ADB .-1             ADDRESSES 
      LDA 1,I       TRANSFER
      STA TEMP+2,I    A WORD
      JMP ACCS3 
ACCS4 LDA SBPTR     RESET POINTER TO
      STA PBPTR       LAST WORD+1 OF PROGRAM
ACCS5 LDA TAPEF     TAPE
      AND MAIN,I
      SZA            MODE?
      JMP ACCS6     YES 
      LDB OFLAG     NO                           [B]
      STA OFLAG     RESET UNDER/OVERFLOW FLAG    [B]
      CPB .+4       UNDER/OVERFLOW ERROR(S)?
      JSB RERRS+32,I  YES 
      LDA .+12B     NO, 
      JSB OUTCR       OUTPUT A
      JMP SCHEN,I       LINE FEED 
ACCS6 LDB MAIN      ALLOW 
      INB 
      LDA 1,I         MORE
      IOR ALI 
      JSB S14SC,I       INPUT 
      JMP SCHEN,I 
