      HED CHECK SYNTAX AND TRANSLITERATE
*
* *******************************
****                           ***
***  CHECK SYNTAX OF STATEMENT  ***
****                           ***
* *******************************
*
**
***  DETERMINE SEQUENCE NUMBER  **
**
SYNTX JSB INCHK,I   RECORD
      DEF MAXSN       SEQUENCE NUMBER
      ISZ SBPTR     SAVE SPACE FOR LENGTH WORD
      STB .LNUM     SAVE LINE NUMBER
      LDB SBUFA     SET
      INB             TEMP TO
      STB TEMP          (SBUFF)+1
**
***  DETERMINE STATEMENT TYPE  **
**
      CPA .10       NULL STATEMENT?
      JMP DELST,I   YES, DELETE IT
      STA SBPTR,I   NO, RECORD NEXT CHARACTER
      LDA STTYP     PRINT-TABLE ADDRESS
      LDB M21       -(NUMBER OF ENTRIES)
      JSB TSRCH,I   FIND STATEMENT TYPE
      JSB ERROR     NOT FOUND
SYNE1 LDB M9        SET MULTIPLE STORE
      STB MSFLG       TO FALSE
      LDB PBPTR     NULL
      CPB PBUFF       PROGRAM?
      RSS           YES
      JMP SYNT1     NO
      LDB FWAM      INSURE NO
      STB PBUFF       SPURIOUS COMMON
      STB PBPTR         EXISTS
SYNT1 STB TEMPS     SET S-STACK POINTER
      CLB           SET DEFINE FLAG
      STB DFLAG       TO FALSE
      STB PFLAG     SET PARAMETER FLAG TO FALSE
      ALF,ALF       COMPUTE
      RAR             ADDRESS OF
      ADA STBAS         SYNTAX ROUTINE AND
      JMP 0,I               BRANCH TO IT
**
***  SINGLE CHARACTER AND/OR FORMULA OPERATORS  **
**
QUOTE OCT 1000      BITS 15-9 OF THE LABELLED WORD
      ASC 1,"
COMMA OCT 2000      ARE THE BASIC CODE OPERATOR
      ASC 1,,
SMCLN OCT 3000      NUMBERS.  BITS 3-0 ARE THE
      ASC 1,;
RPARN OCT 4001      OPERATOR'S HIERARCHICAL
      ASC 1,)
RBRAC OCT 5001      PRECEDENCE FOR THOSE OPERATORS
      ASC 1,]
SCMMA OCT 6002      BELONGING TO FORMULAS.  THE
      ASC 1,,
ASSOP OCT 7002      UNLABELLED WORD GIVES THE
      ASC 1,=
PLUS  OCT 10007     ASCII REPRESENTATION OF THE
      ASC 1,+
MINUS OCT 11007     SINGLE CHARACTER OPERATORS.
      ASC 1,-
TIMES OCT 12010
      ASC 1,*
DIV   OCT 13010
      ASC 1,/
EXPS  OCT 14012
      ASC 1,^
GTR   OCT 15005
      ASC 1,>
LSS   OCT 16005
      ASC 1,<
UNEQL OCT 17005
      ASC 1,#
EQUAL OCT 20005
      ASC 1,=
UNMIN OCT 21011
      ASC 1,-
LBRAC OCT 22020
      ASC 1,[
LPARN OCT 23020
      ASC 1,(
UPLUS OCT 24011
      ASC 1,+
OROP  OCT 25003
MSFLG NOP
ANDOP OCT 26004
DFLAG NOP
NOTOP OCT 27011
PFLAG NOP
GTREQ OCT 30005
UFLAG NOP
LSSEQ OCT 31005
*
***                      ***
**  LET STATEMENT SYNTAX  **
***                      ***
*
LETS  STB SFLAG     SET 'NO STORE' FLAG ( (B) = 0 )
      LDA M8        SET MULTIPLE STORE FLAG
      STA MSFLG       TO TRUE
      JSB FSC       FETCH FORMULA
      CPB SFLAG     DID STORE OCCUR? ( (B)=0 )
      JSB ERROR     NO
SYNE2 EQU *
**
***    CHECK FOR END OF STATEMENT  **
**
EOST  CPA .10       END-OF-STATEMENT?
      JMP ACCST,I   YES, ACCEPT STATEMENT
      JMP NOEOF     NO, ILLEGAL CHARACTER
      SKP
*
***                      ***
**  DIM STATEMENT SYNTAX  **
***                      ***
*
DIMS  ISZ DFLAG     SET DFLAG TO TRUE
      JSB ARRYS     CHECK AN ARRAY
      JMP ACCST,I   DONE
      JMP DIMS+1    WAS A COMMA, CONTINUE
*
***                      ***
**  COM STATEMENT SYNTAX  **
***                      ***
*
COMS  LDB PBPTR     HAS PROGRAM BUFFER
      CPB FWAM        BEEN MOVED?
      RSS           NO
      JSB ERROR     YES, ILLEGAL COM
SYNE3 STB TEMPS+7   SET ARRAY POINTER
      ISZ DFLAG     SET DEFINE FLAG TO TRUE
COMS1 CCA           SET COMMON FLAG
      STA PFLAG       TO TRUE
      JSB ARRYS     CHECK AN ARRAY
      RSS           DONE
      JMP COMS1     MORE ARRAYS
      LDB TEMPS+7   FETCH UPDATED POINTER
      STB PBUFF     SET PROGRAM BUFFER ADDRESS
      STB PBPTR     SET PROGRAM BUFFER POINTER
      JMP ACCST,I   EXIT
*
***                      ***
**  DEF STATEMENT SYNTAX  **
***                      ***
*
DEFS  JSB LTR
      JMP SYNE4     FIRST
      LDA TEMP1
      ALF,ALF        TWO CHARACTERS
      IOR TEMP2
      CPA FN           'FN'?
      RSS           YES
      JMP SYNE4     NO
      JSB LTR       LETTER FOLLOWS?
SYNE4 JSB ERROR     NO
      LDA TEMP1     YES, RECORD A
      LDB .58         FUNCTION
      JSB STROP        NAME
      LDA TEMP2     RETRIEVE CHARACTER
      JSB LPCK      LEFT PARENTHESIS?
      IOR FLGBT     YES, SET FORMAL
      STA SBPTR,I     PARAMETER BIT
      JSB VAROP     FETCH SIMPLE VARIABLE
      NOP           NONE FOUND
      JSB ERROR     SUBSCRIPTED VARIABLE FOUND
SYNE5 JSB RPCK      RECORD A RIGHT PARENTHESIS
      CCB           ASSIGNMENT
      JSB SYMCK
      DEF ASSOP-1     OPERATOR?
SYNE6 JSB ERROR     NO
      LDA M2        YES,
      ADA SBPTR       RETRIEVE
      LDA 0,I           PARAMETER
      AND MSK1            AND
      STA PFLAG             SAVE IT
      JSB FSC       FETCH DEFINING FORMULA
      JMP EOST      END-OF-STATEMENT TEST
*
***                      ***
**  REM STATEMENT SYNTAX  **
***                      ***
*
REMS  LDA .10       DUMMY STRING TERMINATOR
      JSB CHRSA,I   FETCH CHARACTER STRING
      JMP ACCST,I
*
***                     ***
**  IF STATEMENT SYNTAX  **
***                     ***
*
IFS   JSB FSC       GET DECISION FORMULA
      STA SBPTR,I   TABLE
      LDA ATHEN       SEARCH
      CCB               FOR
      JSB TSRCH,I         'THEN'
      JSB ERROR     NOT FOUND
SYNE7 EQU *         GET STATEMENT LABEL NUMBER
*
***                                  ***
**  GO TO AND GOSUB STATEMENT SYNTAX  **
***                                  ***
GOTOS JSB PGINT,I   FETCH AND RECORD
      DEF MAXSN       SEQUENCE NUMBER
      JMP EOST      END-OF-STATEMENT TEST
*
*
***                      ***
**  FOR STATEMENT SYNTAX  **
***                      ***
*
FORS  JSB VAROP     FETCH SIMPLE VARIABLE
      NOP           NONE FOUND
SYNE8 JSB ERROR     SUBSCRIPTED VARIABLE FOUND
      CCB
      JSB SYMCK     ASSIGNMENT
      DEF ASSOP-1     OPERATOR?
      JMP SYNE6     NO
      JSB FSC       YES, FETCH INITIAL VALUE FORMULA
      STA SBPTR,I   LOOK
      LDA ATO         FOR
      CCB               THE
      JSB TSRCH,I         'TO'
      JSB ERROR     MISSING
SYNE9 JSB FSC       GET LIMIT FORMULA
      CPA .10       END-OF-STATEMENT?
      JMP ACCST,I   YES
      CCB           NO, ERASE
      ADB SBPTR       ZERO
      STB SBPTR         WORD
      STA SBPTR,I   NOW
      LDA ASTEP       LOOK
      CCB               FOR
      JSB TSRCH,I         THE 'STEP'
      JSB ERROR     MISSING
SYE10 JSB FSC       GET STEP SIZE FORMULA
      JMP EOST      END-OF-STATEMENT TEST
*
***                       ***
**  NEXT STATEMENT SYNTAX  **
***                       ***
*
NXTS  JSB VAROP     FETCH SIMPLE VARIABLE
      NOP           NONE FOUND
      JMP SYNE8     SUBSCRIPTED VARIABLE FOUND
      JMP EOST      END-OF-STATEMENT TEST
*
***                                             ***
**  END, STOP, RESTORE, RETURN STATEMENT SYNTAX  **
***                                             ***
*
ENDS  ISZ SBPTR
      JSB GETCR     END-OF-STATEMENT?
      JMP ACCST,I   YES
      JMP NOEOF     NO
*
***                       ***
**  WAIT STATEMENT SYNTAX  **
***                       ***
*
WAITS JSB GETPF
      JMP EOST      END-OF-STATEMENT TEST
*
***                       ***
**  CALL STATEMENT SYNTAX  **
***                       ***
*
CALLS JSB GETCR     FETCH AND
      JMP EOF         RECORD
      ISZ SBPTR         LEFT
      JSB LPCK            PARENTHESIS
      JSB PGINT,I   FETCH AND RECORD
      DEF D100        SUBROUTINE NUMBER
      STA TEMP1     SAVE NEXT CHARACTER
      JSB FNDSB     FIND
      LDA 1,I         NUMBER
      ALF,ALF           OF
      AND .31             PARAMETERS
      CMA           RECORD
      STA TEMPS+7     COMPLEMENT - 1
      LDA TEMP1     RETRIEVE CHARACTER
CALL2 CCB
      JSB SYMCK     COMMA?
      DEF COMMA-1
      JMP CALL3     NO
      ISZ TEMPS+7   YES, MORE
      RSS             PARAMETERS PERMITTED?
SYE11 JSB ERROR     NO
      JSB FSC       YES, FETCH
      JMP CALL2       PARAMETER FORMULA
CALL3 ISZ TEMPS+7   ALL PARAMETERS PRESENT?
      JMP SYE11     NO
      JSB RPCK      YES, FETCH RIGHT PARENTHESIS
      JMP EOST      END-OF-STATEMENT TEST
*
***                       ***
**  DATA STATEMENT SYNTAX  **
***                       ***
*
DATAS JSB CONST     FETCH A CONSTANT
      JMP SYE12-1   NONE FOUND
      JSB NUMOP     FIX UP PRECEDING OPERATOR
      CCB           CHECK
      JSB SYMCK       FOR A
      DEF COMMA-1       COMMA
      JMP EOST      END-OF-STATEMENT TEST
      JMP DATAS     FETCH ANOTHER NUMBER
*
***                                 ***
**  READ AND INPUT STATEMENT SYNTAX  **
***                                 ***
*
READS JSB VAROP     RECORD VARIABLE OPERAND
      JSB ERROR     MISSING
SYE13 NOP
      CCB           CHECK
      JSB SYMCK       FOR A
      DEF COMMA-1       COMMA
      RSS
      JMP READS     IS, FETCH NEXT ITEM
      CLB           APPEND
      STB SBPTR,I     END-OF-FORMULA
      ISZ SBPTR         OPERATOR
      JMP EOST      END OF STATEMENT TEST
*
***                        ***
**  PRINT STATEMENT SYNTAX  **
***                        ***
*
PRIN1 LDB M2        NO,
      JSB SYMCK       COMMA OR
      DEF COMMA-1       SEMICOLON?
      JMP PRIN2     NO
PRINS CCA           YES, ENABLE
      STA TEMP,I      FORMULA
      ISZ SBPTR
      JSB GETCR     END-OF-STATEMENT?
      JMP ACCST,I   YES
PRIN2 CCB
      JSB SYMCK     QUOTE?
      DEF QUOTE-1
      JMP PRIN3     NO
      LDA .34       YES, SET QUOTE AS TERMINATOR
      JSB CHRSA,I     CHARACTER AND FETCH STRING
      JSB ERROR     MISSING QUOTE
SYE14 LDA QUOTE     RECORD
      STA SBPTR,I     QUOTE
      ISZ SBPTR
      JSB GETCR     END-OP-STATEMENT?
      JMP ACCST,I   YES
      CCB           ENABLE
      STB TEMP,I      FORMULA
      JMP PRIN1     NO
PRIN3 ISZ TEMP,I    TAB OR FORMULA PERMITTED?
      JSB ERROR     NO
SYE15 STA SBPTR,I   SEARCH
      LDA ATAB        FOR
      CCB               'TAB'
      JSB TSRCH,I
      CLA,RSS       NOT FOUND
      LDA TABCN
      CCB           BACKUP
      ADB SBPTR       TO WORD WITH
      STB SBPTR         PREVIOUS OPERATOR
      SZA,RSS       'TAB' ?
      JMP PRIN4     NO
      IOR SBPTR,I
      STA SBPTR,I   YES, RECORD IT
      JSB GETPF     FETCH PARAMETER
      CLB           FOLLOW
      STB SBPTR,I     WITH A
      ISZ SBPTR         ZERO
      JMP PRIN5
PRIN4 JSB BCKSP     BACKSPACE OVER LAST CHARACTER
      JSB FSC       FETCH FORMULA
PRIN5 CPA .10       END-OF-STATEMENT?
      JMP ACCST,I   YES
      JMP PRIN1     NO
*
***                      ***
**  MAT STATEMENT SYNTAX  **
***                      ***
*
MATS  JSB LTR       FIRST
      JSB ERROR       TWO CHARACTERS
SYE16 JSB LETCK         LETTERS?
      JMP MATS2     NO
      ISZ SBPTR     YES, MOVE TO FRESH S-BUFFER WORD
      LDB TEMP1     RETRIEVE FIRST LETTER AND
      BLF,BLF         PUT IT IN THE
      IOR 1             UPPER CHARACTER OF (A)
      STA SBPTR,I   SEARCH
      LDA MATIO       FOR
      LDB M2            'READ' OR
      JSB TSRCH,I         'PRINT'
      JSB ERROR     NOT FOUND
SYE17 CPA RDOP      READ?
      JMP MATS1     YES
MATS0 JSB ARRID     RECORD ARRAY
      CPA .10       END-OF-STATEMENT?
      JMP ACCST,I   YES
      LDB M2        NO,
      JSB SYMCK       COMMA OR
      DEF COMMA-1       SEMICOLON?
      JSB ERROR     NO
SYE18 JSB GETCR     END-OF-STATEMENT?
      JMP *+3       YES
      JSB BCKSP     NO
      JMP MATS0
      ISZ SBPTR     INCLUDE
      JMP ACCST,I     PARAMETER
MATS1 JSB ARRID     RECORD ARRAY
      JSB MATSB     IF SUBSCRIPT,
      NOP             RECORD IT
      CPA .10       END-OF-STATEMENT?
      JMP ACCST,I   YES
      CCB           NO
      JSB SYMCK
      DEF COMMA-1   COMMA?
      JMP SYE18-1   NO
      JMP MATS1     YES
MATS2 STA TEMP2
      LDA SBPTR     SAVE
      STA ARYAD       OPERAND ADDRESS
      LDA TEMP1     RETRIEVE FIRST LETTER
      LDB .46       RECORD AN
      JSB STROP       ARRAY
      LDA TEMP2     RETRIEVE CHARACTER
      CCB           ASSIGNMENT
      JSB SYMCK
      DEF ASSOP-1     OPERATOR?
      JMP SYNE6     NO
      LDA ARYAD,I   YES, RETRIEVE
      AND MSK1        AND SAVE
      STA TEMP,I        PREVIOUS ARRAY IDENTIFIER
      JSB LTR       LETTER NEXT?
      JMP MATS4     NO
      JSB LETCK     YES, SECOND LETTER?
      JMP MATS5     NC
      ISZ SBPTR     YES,
      LDB TEMP1       CONCATENATE
      BLF,BLF           LETTERS
      IOR 1               AND
      STA SBPTR,I           SEARCH
      LDA MATFN               FOR
      LDB M5                    ARRAY
      JSB TSRCH,I                 FUNCTION
      JSB ERROR     NOT FOUND
SYE19 ALF,ALF       FOUND
      ALF,RAR       POSITION IT,
      ADA .15         COMPLETE OPERAND,
      CCB               COMBINE
      ADB SBPTR           WITH
      IOR 1,I               OPERATOR,
      IOR FLGBT               ADD FLAG BIT,
      STA 1,I                   AND STORE
      AND MSK1      'INV'
      ADA M256        OR
      SSA,RSS           'TRN?
      JMP MATS3     YES
      JSB GETCR     NO, FND-OF-STATEMENT?
      JMP ACCST,I   YES
      JSB MATSB     NO, SUBSCRIPT?
      JSB ERROR     NO
SYE20 JMP NOEOF
MATS3 JSB GETCR
      JMP EOF
      JSB LPCK      GET LEFT PARENTHESIS
      JSB ARRID     FETCH AND RECORD AN ARRAY
      JSB RPCK      RECORD A RIGHT PARENTHESIS
      LDA ARYAD,I   RETRIEVE
      AND MSK1        PREVIOUS ARRAY IDENTIFIER
      CPA TEMP,I    MATCH LEFT-HAND SIDE ARRAY?
      JSB ERROR     YES
SYE21 JMP ACCST,I   NO
MATS4 ISZ SBPTR
      JSB LPCK      FETCH LEFT PARENTHESIS
      JSB FSC       FETCH FORMULA
      JSB RPCK      FETCH RIGHT PARENTHESIS
      CCB           MULTIPLICATION
      JSB SYMCK       OPERATOR?
      DEF TIMES-1
      JSB ERROR     NO
SYE22 JSB ARRID     YES, FETCH AND RECORD ARRAY
      CPA .10       END-OF-STATEMENT?
      JMP ACCST,I   YES
      JMP NOEOF     NO
MATS5 STA TEMP2
      LDA SBPTR     SAVE
      STA ARYAD       OPERAND ADDRESS
      LDA TEMP1     RETRIEVE
      LDB .46         AND RECORD
      JSB STROP         ARRAY
      LDA TEMP2     END-OF-
      CPA .10         STATEMENT?
      JMP ACCST,I   YES
      LDB M3        NO, MUST BE
      JSB SYMCK       A '+',
      DEF PLUS-1        '-', OR '*'
      JSB ERROR     ISN'T
SYE23 CLB           IS, SET FOR FALSE
      ADA .8
      CPA TIMES     '*'?
      JMP MATS7     YES
MATS6 STB PFLAG     NO, SET PFLAG
      JSB ARRID     GET SECOND ARRAY
      CPA .10       END-OF-STATEMENT?
      RSS           YES
      JMP NOEOF     NO
      ISZ PFLAG     WAS OPERATOR A '*'?
      JMP ACCST,I   NO
      LDA ARYAD,I   YES, RETRIEVE
      AND MSK1        SECOND ARRAY
      CPA TEMP,I    MATCH LEFT-HAND SIDE ARRAY?
SYE24 JSB ERROR     YES
      JMP ACCST,I   NO
MATS7 LDA ARYAD,I   RETRIEVE
      AND MSK1        ARRAY
      CCB           SET FOR TRUE
      CPA TEMP,I    MATCH LEFT-HAND SIDE ARRAY?
      JMP SYE24     YES
      JMP MATS6     NO
**
***  JUMP TABLE FOR STATEMENT SYNTAX  **
**
SYNTB DEF LETS     LET
      DEF DIMS     DIM
      DEF COMS     COM
      DEF DEFS     DEF
      DEF REMS     REM
      DEF GOTOS    GO TO
      DEF IFS      IF
      DEF FORS     FOR
      DEF NXTS      NEXT
      DEF GOTOS    GOSUB
      DEF ENDS     RETURN
      DEF ENDS     END
      DEF ENDS     STOP
      DEF WAITS    WAIT
      DEF CALLS    CALL
      DEF DATAS    DATA
      DEF READS    READ
      DEF PRINS    PRINT
      DEF READS    INPUT
      DEF ENDS     RESTORE
      DEF MATS     MAT
*
***                        ***
**  FORMULA SYNTAX CHECKER  **
***                        ***
*
FSC   NOP
      CLA          SET LEFT PARENTHESIS
      STA TEMPS,I    COUNT TO ZERO
FSC1  CCA          SET UNARY FLAG
      STA UFLAG      TO TRUE
FSC2  JSB VAROP    LOOK FOR VARIABLE OPERAND
      JMP FSC9     NOT FOUND
      JMP FSC6     SUBSCRIPTED VARIABLE FOUND
      JSB LETCK    FOLLOWED BY LETTER?
      JMP FSC6     NO
      LDB M2       YES, LOOK FOR
      JSB MCBCK      'AND' OR 'OR'
      LDA TEMP1    NOT FOUND, FETCH PREVIOUS
      ALF,ALF        CHARACTER AND LEFT-JUSTIFY IT
      IOR TEMP2    ADD LATEST CHARACTER
      CPA FN       'FN'?
      JMP FSC4     YES
      STA SBPTR,I  NO,
      LDA PDFNS      SEARCH FOR
      LDB M11           PREDEFINED
      JSB TSRCH,I        FUNCTION
      JMP FSC3     NOT FOUND
      ALF,ALF      ASSEMBLE
      ALF,RAR        OPERAND
      IOR FLGBT     ADD FLAG BIT
      JMP FSC5
FSC3  ISZ UFLAG    'NOT' PERMITTED?
      JMP FSC8-1   NO
      LDA ANOT     YES,
      CCB            SEARCH FOR
      JSB TSRCH,I      'NOT'
      JMP FSC8-1   'NOT' NOT FOUND
      CCB          RETRIEVE
      ADB SBPTR      PREVIOUS WORD
      LDA 1,I          WORD
      AND OPMSK    SET TO
      STA 1,I        NULL OPERAND
      JMP FSC14
FSC4  JSB GETCR     IDENTIFYING
      JMP SYNE4       FUNCTION
      JSB LETCK         LETTER?
      JMP SYNE4     NO
      ADA D100      YES,
      ALF             ASSEMBLE AND
FSC5  ADA .15           SAVE
      STA TEMP1           FUNCTION IDENTIFIER
      CCB           RETRIEVE
      ADB SBPTR       PREVIOUS
      LDA 1,I           PROGRAM WORD
      AND OPMSK     EXTRACT OPERATOR,
      IOR TEMP1       APPEND OPERAND,
      STA 1,I            AND RECORD
      JSB GETCR     LEFT PARENTHESIS
FSCE1 JSB ERROR       OR
      JSB LPCK          LEFT BRACKET?
      JSB FRCUR     YES, SAVE LOCAL VARIABLES OF FSC
      JSB FSC       FETCH ACTUAL PARAMETER
      JSB FPOP      RESTORE LOCAL VARIABLES OF FSC
      JSB RPCK      FETCH RIGHT PARENTHESIS
      JMP FSC10+1
FSC7  LDB M2       CHECK FOR
      JSB SYMCK      RIGHT PARENTHESIS
      DEF RPARN-1      OR RIGHT BRACKET
      JMP FSC8     NOT FOUND
      LDA B4000     RECORD A
      STA SBPTR,I     RIGHT PARENTHESIS
      LDA .41       RESTORE RIGHT PARENTHESIS
      CCB          MATCHING
      ADB TEMPS,I    LEFT
      SSB              PARENTHESIS?
      JMP FSC8     NO
      STB TEMPS,I  YES
      ISZ SBPTR
      JSB GETCR    FETCH
      LDA .10         CHARACTER
FSC6  CPA .10       END OF FORMULA?
      JMP FSC8     YES
      STA UFLAG    NO, SET UNARY FLAG TO FALSE
      LDB M5        SEARCH FOR A MULTICHARACTER
      JSB MCBCK      BINARY OPERATOR
      LDA SBPTR,I  NOT FOUND,
      ALF,ALF        RESTORE
      AND B177         CHARACTER
      LDB MSFLG    SEARCH
      JSB SYMCK      FOR A
      DEF PLUS-1       BINARY OPERATOR
      RSS           NOT FOUND
      JMP FSC12     FOUND
      CCB          ASSIGNMENT
      JSB SYMCK
      DEF ASSOP-1     OPERATOR?
      JMP FSC7     NO
      STA SFLAG     YES, SET
      JMP FSC1        'STORE OCCURRED' FLAG
      LDA TEMP2    RETRIEVE LETTER
FSC8  LDB TEMPS,I  ALL LEFT PARENTHESES
      SZB            MATCHED?
FSCE2 JSB ERROR     NO
      STB SBPTR,I  YES, RECORD AN
      ISZ SBPTR      END-OF-FORMULA AND
      JMP FSC,I        EXIT WITH CHARACTER IN (A)
*
FSC9  CPA .40       LEFT
      JMP FSC11       PARENTHESIS
      CPA B133          OR LEFT BRACKET?
      JMP FSC11     YES
      CLB           NO, SET SIGN
      STB SIGN        POSITIVE
      JSB NUMCK     NUMBER?
      JMP FSC13     NO
FSC10 JSB NUMOP     YES, FIX UP PRECEDING OPERATOR
      LDB M9        UPDATE
      STB MSFLG       MULTIPLE STORE
      JMP FSC6        FLAG
FSC11 ISZ SBPTR     YES
      LDA B2300     RECORD
      STA SBPTR,I     IT AND
      ISZ TEMPS,I       COUNT IT
FSC12 LDB M9        UPDATE
      STB MSFLG       MULTIPLE STORE FLAG
      JMP FSC1          FLAG
FSC13 ISZ UFLAG     UNARY OPERATORS PERMITTED?
FSCE3 JSB ERROR     NO
      LDB UNMNC
      CPA .43       '+'?
      JMP *+4       YES
      CPA .45       NO, '-'?
      JMP *+3       YES
      JMP FSCE3     NO
      ADB B3000     STORE
      ISZ SBPTR       UNARY
      STB SBPTR,I       OPERATOR
FSC14 LDB M9        UPDATE
      STB MSFLG       MULTIPLE STORE FLAG
      JMP FSC2        FLAG
**
***  CHECK FOR A MULTICHARACTER BINARY OPERATOR  **
**
MCBCK NOP
      STA SBPTR,I   SEARCH
      LDA MCBOP      FOR 'AND'
      JSB TSRCH,I      OR 'OR'
      JMP MCBCK,I  NOT FOUND
      JMP FSC12     FOUND
