      HED FORMULA SYNTAX CHECKER
* 
***                          ** 
**  <FORMULA> SYNTAX CHECKER  **
***                          ** 
* 
* qq
*  FSC ANALYZES THE INPUT STRING UNDER THE ASSUMPTION 
*  THAT A LEGITIMATE FORMULA IS THERE.  EXIT TO ERROR ON
*  UNRECOGNIZABLE OR OBVIOUSLY INCORRECT INPUT.  EXIT TO
*  (P+1) WHEN CONTINUED INPUT CANNOT BE A PART OF THE 
*  FORMULA AND THE INPUT SCANNED SO FAR FORMS A COMPLETE
*  FORMULA IN ITSELF (I.E., ... A+B TO ... EXITS AFTER
*  THE 'B').  ON EXIT (A) HOLDS THE FIRST CHARACTER NOT 
*  PARSED INTO THE FORMULA, (B) = 0, AND SBPTR,I = 0
*  (END-OF-FORMULA OPERATOR).  DURING THE FORMULA PARSE,
*  SSTAK,I HOLDS THE COUNT OF UNMATCHED LEFT PARENTHESES. 
*  IF THE FIRST SYMBOL ENCOUNTERED IS A STRING VARIABLE,
*  EXIT TO ERROR IF IT IS NOT ENABLED ELSE RECORD THE 
*  VARIABLE AND ANY FOLLOWING SUBSCRIPT AND EXIT TO (P+1) 
*  WITH THE NEXT CHARACTER IN (A), (B) = -1, AND SFLAG = -1.
* 
#FSC  CLA           SET LEFT PARENTHESIS
      STA SSTAK,I     COUNT TO ZERO 
      LDA .+3       SET MULTICHARACTER SEARCH 
      STA MAXCR       TO MAXIMUM OF 3 CHARACTERS
FSC1  CCA           ENABLE
      STA UFLAG       UNARY OPERATORS 
*                         * 
**  LOOK FOR AN OPERAND  ** 
*                         * 
FSC2  JSB VAROP     SEEK VARIABLE OPERAND 
      JMP FSC7      FIRST CHARACTER NOT A LETTER
      JMP FSC13-3   SUBSCRIPTED OR STRING VARIABLE
      JSB LETCK     SIMPLE VARIABLE.  LETTER NEXT?
      JMP FSC13     NO
*                                              *
**  DOES 'AND', 'OR', 'MAX', OR 'MIN' FOLLOW  **
**    A SIMPLE VARIABLE?                      **
*                                              *
      LDB .-4 WW
      STA SBPTR,I   SEARCH FOR
      LDA MCBOP       'AND', 'OR',
      JSB TBSRH         'MAX', AND 'MIN'
      RSS           NONE FOUND
      JMP FSC6      FOUND 
*                                         * 
**  SEE IF OPERAND IS A FUNCTION RATHER  ** 
**    THAN A SIMPLE VARIABLE.            ** 
*                                         * 
      LDA TEMP+2
      ALF,ALF       WERE
      IOR TEMP+1      TWO LETTERS 
      CPA FN            'FN' ?
      JMP FSC4      YES 
      STA SBPTR,I   NO, 
      LDA PDFNS       PREDEFINED
      LDB .-14
      JSB TBSRH 
      JMP FSC11     NO
      ALF,ALF       YES,
      ALF,RAR         BUILD 
      IOR PDFFL         NAME
FSC3  STA TEMP+1    SAVE FUNCTION 
      CCB           RETRIEVE
      ADB SBPTR       PREVIOUS
      STB SBPTR         OPERATOR- 
      LDA 1,I             OPERAND 
      AND OPMSK     REPLACE 
      IOR TEMP+1      OPERAND 
      STA SBPTR,I       WITH FUNCTION 
      LDA TEMP+1
      CPA LENCN     'LEN' ? 
      JMP FSC0      YES 
      LDB .-9       NO, TURN OFF
      STB MSFLG       'MULTIPLE STORE' MODE 
      JSB GETPF     DEMAND PARENTHSIZED 
      JMP FSC13       FORMULA 
FSC4  JSB GETCR     DOES
      JSB SERRS+7,I   LETTER
      JSB LETCK         FOLLOW? 
      JSB SERRS+7,I NO
      ADA D100      YES,
      ALF             BUILD 
      ADA .+17B         FUNCTION
      JMP FSC3            NAME
FSC0  ISZ SBPTR     MOVE TO CORRECT PROGRAM WORD
      JSB GETCR     RECORD
      JSB SERRS+22,I  LEFT
      JSB LPCK          PARENTHESIS 
      JSB LTR       LETTER NEXT?
      JSB SERRS+24,I  NO
      CPA .+44B     YES, FOLLOWED BY '$' ?
      RSS           YES 
      JSB SERRS+24,I  NO
      LDA TEMP+1    RECORD
      LDB .+53B       STRING
      JSB STROP         VARIABLE
      JSB GETCR     RECORD
      JSB SERRS+23,I  RIGHT 
      JSB RPCK          PARENTHESIS 
      JMP FSC8
*                                *
**  CHECK FOR LEFT PARENTHESIS  **
*                                *
FSC5  LDA LPOP      RECORD
      STA SBPTR,I     A '(' 
      ISZ SSTAK,I   COUNT IT
FSC6  LDB .-9       TURN OFF
      STB MSFLG       'MULTIPLE STORE'
      JMP FSC1          MODE
FSC7  JSB SBPUD     UPDATE POINTER
      CPA .+40      '(' ? 
      JMP FSC5      YES 
      CPA B133      NO, '' ?
      JMP FSC5      YES 
      SKP 
*                        *
**  CHECK FOR A NUMBER  **
*                        *
      CLB           SET '+' 
      STB SIGN        AS SIGN 
      JSB NUMCK     SEEK A NUMBER 
      JMP FSC9      NOT FOUND 
      JSB SERRS+14,I  BAD EXPONENT
      LDB SBPTR     RETRIEVE
      ADB .-3         PRECEDING 
      LDA 1,I           OPERATOR
      IOR FLGBT     SET FLAG TO SAY 
      STA 1,I         NUMBER FOLLOWS
      LDA TEMP+1    RETRIEVE CHARACTER
FSC8  LDB .-9       TURN OFF
      STB MSFLG       'MULTIPLE STORE'
      JMP FSC13         MODE
*                                *
**  CHECK FOR A UNARY OPERATOR  **
*                                *
FSC9  ISZ UFLAG     UNARY OPERATORS PERMITTED?
      JSB SERRS+25,I  NO
      LDB UNMNC     YES LOAD UNARY MINUS OPCODE 
      CPA .+43      '+' ? 
      JMP *+4       YES 
      CPA .+45      NO, '-' ? 
      JMP *+3       YES 
      JSB SERRS+25,I  NO
      LDB UNPLC     CONVERT (B) TO UNARY '+' OPCODE 
      STB SBPTR,I   RECORD UNARY OPERATOR 
FSC10 LDB .-9       TURN OFF
      STB MSFLG       'MULTIPLE STORE'
      JMP FSC2          MODE
*                                            *
**  CHECK POSSIBILITY OF 'NOT' RATHER THAN  **
**    A SIMPLE VARIABLE                     **
*                                            *
FSC11 ISZ UFLAG     'NOT' PERMITTED?
      JMP FSC14-1   NO
      LDA SBPTR,I   YES 
      ALF,ALF 
      STA SBPTR,I 
      LDA ANOT      SEEK
      CCB Bd
      JSB TBSRH       'NOT' 
      JMP FSC14-1   'NOT' NOT FOUND 
      STA SBPTR,I   FOUND 
      CCB           ERASE 
      ADB SBPTR 
      LDA 1,I         SPURIOUS
      AND OPMSK 
      STA 1,I           OPERAND 
      JMP FSC10 
*                                 * 
**  CHECK FOR RIGHT PARENTHESIS  ** 
*                                 * 
FSC12 LDB .-2       ')' 
      JSB SYMCK       OR
      DEF RPARN-1       ']' ? 
      JMP FSC14     NO
      LDA RPOP      YES,
      STA SBPTR,I     RECORD ')'
      LDA .+41      RETRIEVE ')'
      CCB           MATCHING
      ADB SSTAK,I     LEFT
      SSB               PARENTHESIS?
      JMP FSC14     NO
      STB SSTAK,I   YES 
      JSB SBPUD     UPDATE POINTER
      JSB GETCR     FETCH NEXT
      JMP FSC14       CHARACTER 
      JMP FSC13 3>
*                                 * 
**  CHECK FOR A BINARY OPERATOR  ** 
*                                 * 
      CCB           STRING VARIABLE 
      CPB SFLAG       JUST FOUND? 
      JMP FSC,I     YES 
FSC13 CPA .+15B     NO, END OF STATEMENT? 
      JMP FSC14     YES 
      STA UFLAG     NO, DISABLE UNARY OPERATORS 
      STA TEMP+1    SAVE CHARACTER
      LDB .-7       SEARCH
      STA SBPTR,I     FOR A 
      LDA MCBOP         MULTICHARACTER
      JSB TBSRH           BINARY OPERATOR 
      RSS           NONE FOUND
      JMP FSC6      FOUND 
      LDA TEMP+1    NO, RECOVER A CHARACTER 
      LDB MSFLG     SINGLE
      JSB SYMCK       CHARACTER 
      DEF PLUS-1        BINARY OPERATOR?
      JMP *+4       NO
      CPA EXPOP     YES, '^' ?
      JMP FSC10     YES 
      JMP FSC6      NO
      CCB           ASSIGNMENT
      JSB SYMCK 
      DEF ASSOP-1     OPERATOR? 
      JMP FSC12     NO
      LDA .-2       YES, SET FLAG 
      STA SFLAG       TO SAY
      JMP FSC1          STORE OCCURRED
*                    *
**  END OF FORMULA  **
*                    *
      LDA TEMP+2    RETRIEVE CHARACTER
FSC14 CLB           RECORD
      STB SBPTR,I     END-OF-FORMULA
      CPB SSTAK,I   ALL LEFT PARENTHESES MATCHED? 
      JMP FSC,I     YES 
      JSB SERRS+23,I  NO
      SKP 
**                                 ** 
***  SAVE LOCAL VARIABLES OF FSC  *** 
**                                 ** 
* {q
*  SAVING MSFLG, UFLAG, VAROP, GETPF, AND FSC MAKES FSC A 
*  RE-ENTRANT SUBROUTINE.  THEY ARE SAVED ON THE SYNTAX 
*  STACK BELOW THE ACTIVE SYNTAX BUFFER.  ON ENTRY (B)
*  CONTAINS THE NUMBER OF WORDS TO BE SAVED.
* 
#FRCR ISZ SSTAK     SAVE PREVIOUS '(' COUNT 
      ADB SSTAK     SUFFICIENT
      CMB             USER
      ADB LWAUS         SPACE 
      SSB                 LEFT? 
      JSB SERRS,I   NO
      LDB MSFLG     YES, SAVE 
      STB SSTAK,I     'MULTIPLE STORE'
      ISZ SSTAK         FLAG
      LDB UFLAG     SAVE
      STB SSTAK,I     'UNARY OPERATOR'
      ISZ SSTAK         FLAG
      LDB VAROP     SAVE
      STB SSTAK,I     VAROP 
      ISZ SSTAK         RETURN ADDRESS
      LDB GETPF     SAVE
      STB SSTAK,I     GETPF 
      ISZ SSTAK         RETURN ADDRESS
      LDB FSC       SAVE
      STB SSTAK,I     FSC 
      ISZ SSTAK         RETURN ADDRESS
      CCA           DISABLE 
      ADA SFLAG       SFLAG 
      STA SFLAG         VALUE 
      JMP FRCUR,I I+
**                                 ** 
***  RESTORE FSC LOCAL VARIABLES  *** 
**                                 ** 
* qqq{
*  INVERSE OF FRCUR.  (A) IS SAVED BUT (B) IS NOT.
* 
#FPOP STA TEMP+1    SAVE (A)
      LDB SSTAK     RESET 
      ADB .-6         SYNTAX STACK
      STB SSTAK         POINTER 
      INB           RESTORE 
      LDA 1,I         'MULTIPLE STORE'
      STA MSFLG         FLAG
      INB           RESTORE 
      LDA 1,I         'UNARY OPERATOR'
      STA UFLAG         FLAG
      INB           RESTORE 
      LDA 1,I         VAROP 
      STA VAROP         RETURN ADDRESS
      INB 
      DLD 1,I       RESTORE GETPF 
      STA GETPF       RETURN ADDRESS AND
      STB FSC           FSC RETURN ADDRESS
      ISZ SFLAG     RESTORE SFLAG VALUE 
      LDA TEMP+1    RESTORE (A) 
      JMP FPOP,I
      SPC 2 
**                                               ** 
***  SINGLE CHARACTER AND/OR FORMULA OPERATORS  *** 
**                                               ** 
* 
*  BITS 15-9 OF THE OCTAL WORD ARE THE OPERATOR CODE. 
*  BITS 3-0 ARE THE PRECEDENCE FOR FORMULA OPERATORS. 
*  THE ASCII WORD IS USED TO RECOGNIZE THE OPERATOR ON
*  INPUT AND TO PROVIDE THE PRINT NAME ON OUTPUT.  THE
*  ORDERING OF THE TABLE FACILITATES SEARCHING. 
* 
QUOTE OCT 1000      STRING DELIMITER
      ASC 1," 
COMMA OCT 2000      COMMA 
      ASC 1,, 
      OCT 3000      SEMICOLON 
      ASC 1,; 
HATCH OCT 4000      HATCH SIGN
      ASC 1,# 
      BSS 6         UNUSED
RPARN OCT 10001     RIGHT PARENTHESIS 
      ASC 1,) 
      OCT 11001     RIGHT BRACKET 
      OCT 56440         ] 
LBRAC OCT 12013     LEFT BRACKET
      OCT 55440         [ 
      OCT 13013     LEFT PARENTHESIS
      ASC 1,( 
      OCT 14011     UNARY PLUS
      ASC 1,+ 
      OCT 15011     UNARY MINUS 
      ASC 1,- 
SCMMA OCT 16002     SUBSCRIPT SEPARATOR 
      ASC 1,, 
ASSOP OCT 17002     ASSIGNMENT OPERATOR 
      ASC 1,= 
PLUS  OCT 20007     ADDITION
      ASC 1,+ +
      OCT 21007     SUBTRACTION 
      ASC 1,- 
TIMES OCT 22010     MULTIPLICATION
      ASC 1,* 
      OCT 23010     DIVISION
      ASC 1,/ 
      OCT 24012     EXPONENTIATION
      ASC 1,^ 
RELOS OCT 25005     GREATER THAN
      ASC 1,> 
      OCT 26005     LESS THAN 
      ASC 1,< 
      OCT 27005     UNEQUAL 
      ASC 1,# 
      OCT 30005     EQUAL 
      ASC 1,= 
DCLNU DEF CLNUP Pf
DCOM0 DEF COMS0 
      BSS 2         UNUSED
      OCT 33004     AND 
DFLAG NOP 
      OCT 34003     OR
MSFLG NOP 
      OCT 35006     MINIMUM 
PFLAG NOP 
      OCT 36006     MAXIMUM 
SFLAG NOP 
      OCT 37005     UNEQUAL 
UFLAG NOP P
      OCT 40005     GREATER THAN OR EQUAL 
ARYAD NOP 
      OCT 41005     LESS THAN OR EQUAL
      NOP 
      OCT 42011     NOT 
      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  *** 
**                             ** 
* qq
*  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. 
* *q
#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 COSTANT.  EXIT  
*  TO ERROR IF NEITHER IS FOUND, ELSE EXIT WITH THE NEXT
*  CHARACTER IN (A).
* qq
#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. tt
* 
#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 
**                             ** 
***  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.
* qq
#VROP JSB LTR       LETTER? 
      JMP VAROP,I   NO, EXIT VIA (P+1)
      ISZ VAROP     YES 
      CPA .+50B     '(' ? 
      JMP VARO4     YES 
      CPA B133      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        NEXTX)
      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 
*                              *
**  CLEAN UP FOR NEW PROGRAM  **
*                              *
CLNUP LDA CMSK      SET PROGRAM MODE
      AND CFLAG       TO 'UNCOMPILED' 
      STA CFLAG 
      LDB PBUFF     INSURE CORRECT
      STB SPROG       START-OF--PROGRAM SETTING 
      CLB           INITIALIZE
      STB SYMTB       ERROR FLAG
      JMP SYNT1 
