         PCC      1
         SYSTEM   SIG7
         TITLE    'LEMUR0 -- TABLES, CONSTANTS, ETC.'
         SPACE
*M* LEMUR0        CONSTANT DATA FOR LEMUR.
         SPACE    2
*P*************************************************************
*P*
*P* NAME:   LEMUR0%
*P*      CONTAINS SCANNER CONTROL TABLES FOR LEMUR
*P*
*P*
*P* DESCRIPTION:
*P*      THIS MODULES CONTAINS THE DEFINITIONS FOR LEMUR'S
*P*      SCANNER. IT INCLUDES THE FOLLOWING TABLES--
*P*
*P*      COMTBL,CMDNDX,CDFOPT,CAOPT,CVECT:  COMMAND TABLES.
*P*      OPTBL,OPFLGS,SAOPT,OPTMAX:  OPTION TABLES.
*P*
*P*      IT ALSO CONTAINS THE DEFINITIONS FOR THE OPTION
*P*      MASKS (O%XXX), THE DEFINITIONS FOR THE TABLE SIZES,
*P*      AND OTHER MISCELLANEOUS CONSTANT DATA.
*P*
*P*************************************************************
         TITLE    'LEMUR0 -- DEFS'
         SPACE
*************************************************************
*
*  SYMBOLS DEFINED IN THIS MODULE --
*
* (1) OPTION TABLES
         DEF      OPTBL             OPTION NAMES IN EBCDIC
         DEF      OPFLGS            OPTION VALUES AND MASKS
         DEF      SAOPT             TABLE OF ROUTINES FOR SPECIAL CASES
         DEF      OPTMAX            CONSTANT:  SIZE OF OPTION TABLES.
         PAGE
         SPACE
*
* (2) OPTION MASKS --
         DEF      O%SL              SEVERITY LEVEL
         DEF      O%ROM             MODULE IS ROM/LMN
         DEF      O%C1              FORCE (C1) FOR LYNX
         DEF      O%MAP             MAP CONTROL FOR LYNX
         DEF      O%SS              (SS) OPTIONFFOR LYNX
         DEF      O%DREF            (DREF) OPTION FOR LYNX
         DEF      O%X               ABORT ON DE TECTING AN ERROR
         DEF      O%DUPS            CONTROLS ACTION FOR DUP. SYMS.
         DEF      O%DUPM            CONTROLS ACTION FOR DUP. MODS.
         DEF      O%A               LIST WITH ATTRIBUTES
         DEF      O%DEFS            LIST WITH DEFS
         DEF      O%SORT            SORT DEFS BY NAME FOR LIST
         DEF      O%DIC             CONTROL SOURCE OF DEF'S
         DEF      O%DUPG            CONTROLS ACTION FOR DUP. GROUPS
         DEF      O%ERR             CONTROLS 'END' CMD'S ACTION IF
*,*                                 ERRORS WERE DETECTED THIS SESSION.
         PAGE
         SPACE
*
* (3) COMMAND TABLES
         DEF      COMTBL            DESCRIPTORS OF KNOWN COMMANDS.
         DEF      CMDNDX            FOR EACH ENTRY IN COMTBL, AN
*,*                                 INDEX TO VALUES IN CDFOPT, CAOPT
*,*                                 AND CVECT.
         DEF      CDFOPT            DEFAULT OPTIONS FOR EACH COMMAND.
         DEF      CAOPT             ALLOWED OPTIONS FOR EACH COMMAND.
         DEF      CVECT             HANDLING ROUTINE FOR EACH COMMAND.
         DEF      COMTBLS           CONSTANT:  SIZE OF COMTBL.
         SPACE    2
*
*  3.    PATCH AREA
*
         SPACE
         DEF      PATCH             32-WORD PURE PROC PATCH.
         TITLE    'LEMUR0 -- EXTERNAL REFERENCES'
         SPACE
****************************************************************
*
* SYMBOLS DEFINED IN OTHER MODULES --
*
* (1)  COMMAND HANDLERS --
         REF      ADD%              RTN:  HANDLER FOR 'BUILD'
         REF      COPY%             RTN:  HANDLER FOR 'COPY'
         REF      CARRY%            RTN:  HANDLER FOR 'CARRY'
         REF      DELETE%           RTN:  HANDLER FOR 'DELETE'
         REF      END%              RTN:  HANDLER FOR 'END'
         REF      LIB%              RTN:  HANDLER FOR 'LIBRARY'
         PAGE
         SPACE
*
* (2)  OPTION SPECIAL-ACTION ROUTINES --
         REF      DOSL              RTN:  HANDLES SPECIAL SCANNING FOR
*,*                                       '(SL,X)' OPTION.
         TITLE    'LEMUR0 -- CONTROL SECTION DEFINITIONS'
         SPACE
*************************************************************
*
* CONTROL SECTIONS --
*
         SPACE
OPTDATA  CSECT    1                 TABLE OF OPTION CONSTANTS; O%XXX
*                                   IS THE WORD ADDRESS OF A CELL IN THIS
*                                   TABLE.
         SPACE
OPTBL    CSECT    1                 OPTION NAME TABLE
         SPACE
OPFLGS   CSECT    1                 OPTION VALUE TABLE
         SPACE
SAOPT    CSECT    1                 OPTION SPECIAL ACTION TABLE
         SPACE
COMTBL   CSECT    1                 TABLE OF DESCRIPTORS OF KNOWN COMMANDS
         SPACE
CMDNDX   CSECT    1                 BYTE TABLE OF INDICES TO ENTRIES
*                                   IN CDFOPT, CAOPT AND CVECT
         SPACE
CDFOPT   CSECT    1                 DOUBLEWORD TABLE OF INITIAL VALUES FOR
*                                   C%OPTS
         SPACE
CAOPT    CSECT    1                 WORD TABLE OF ALLOWABLE OPTIONS
         SPACE
CVECT    CSECT    1                 TRANSFER VECTOR FOR RECOGNIZED COMMMANDS
         SPACE
STRINGS  CSECT    1                 CONTROL SECTION TO RECEIVE LITERAL STRINGS
         SPACE
PATCH    CSECT    0                 PATCH SPACE
         TITLE    'LEMUR0 -- MISCELLANEOUS MACROS'
         SPACE
*
*  D(STRING)
*        RETURNS AS ITS VALUE THE DESCRIPTOR OF ITS ARGUMENT
D        FNAME
         PROC
         LOCAL    HERE,I
HERE     EQU      %
         USECT    STRINGS
I        TEXT     AF
         USECT    HERE
         PEND     (S:NUMC(AF)**24)+BA(I)
         SPACE
*
*  E(ERROR NUMBER)
*        RETURNS AS ITS VALUE THE ADDRESS TO BRANCH TO FOR
*        THAT ERROR CODE.
*
E        FNAME
         PROC
         PEND     AF
*
         TITLE    'LEMUR0 -- OPTION MASK DEFINITIONS'
         SPACE
*P*************************************************************
*P*
*P* OPTION CONSTANTS:
*P*      WITHIN LEMUR, ALL OPTIONS ARE REFERRED TO VIA SYMBOLIC
*P*      NAMES OF THE FORM O%XXX, WHERE XXX IDENTIFIES THE PARTICULAR
*P*      OPTION IN QUESTION.  THESE NAMES ARE EQUATED TO CELLS
*P*      WHICH CONTAIN MASKS WHICH WILL SELECT THE APPROPRIATE BIT
*P*      FIELDS OUT OF THE OPTION WORD.  FOLLOWING THE MASK WORD, THERE
*P*      IS ANOTHER WORD (UNLABELED) WHICH CONTAINS THE SHIFT COUNT
*P*      REQUIRED TO RIGHT-JUSTIFY THE EXTRACTED BIT VALUE.
*P*
*P*      WITHIN THE MACROS IN THIS MODULE A METASYMBOL LIST IS
*P*      USED TO REMEMBER THE ATTRIBUTES OF EACH OPTION, SIMPLIFYING
*P*      THE GENERATION OF OPTION MASKS & C.  THIS LIST, O#LST, IS
*P*      CREATED BY THE 'OPT' MACRO AND USED BY 'OPTION' AND 'CMD'.
*P*
*P*      THE LIST CONSISTS OF N SUBLISTS, ONE SUBLIST FOR EACH
*P*      OPTION DEFINED WITH THE 'OPT' COMMAND.  THE FIRST ELEMENT
*P*      OF EACH SUBLIST IS THE BITMASK FOR THIS OPTION, AND THE
*P*      SECOND ELEMENT IS THE SHIFT COUNT (AS DEFINED ABOVE).
*P*      THUS, THERE IS A ONE-TO-ONE CORRESPONDENCE BETWEEN O#LST
*P*      AND THE OPTION LIST IN MEMORY.
*P*
*P*      O#LST IS STRUCTURED SUCH THAT THE SUBLIST FOR ANY O%XXX
*P*      MAY BE OBTAINED BY COMPUTING THE DOUBLEWORD ONE-ORIGIN
*P*      DISPLACEMENT OF O%XXX IN THE MEMORY OPTION VECTOR.  THE
*P*      RESULT IS THE INDEX INTO O#LST FOR THAT OPTION.
*P*
*P*************************************************************
         PAGE
         SPACE
         OPEN     I,J,K
I        SET      0                 BIT POSITION REMEMBERER
OPT      CNAME
         PROC
J        SET      AF                BIT-WIDTH OF FIELD
         DO1      J=0               IF J IS ZERO, THEN...
J        SET      1                 FORCE IT TO ONE.
K        SET      ((1**J)-1)**I     MAKE THE MASK.
         USECT    OPTDATA           GENERATE THE MASK, SHIFT CT.
LF       EQU      %                 LABEL POINTS HERE...
O#LST(ABSVAL(DA(%))+1)  SET  K,I
         DATA     K,I
I        SET      I+J               MOVE BIT POINTER.
         PEND
         CLOSE    I,J,K
         PAGE
*F*************************************************************
*F*
*F* NAME:  OPT
*F*      MACRO TO DEFINE OPTION VARIABLES
*
* OPTION DEFINITIONS--
*
         SPACE
O%SL     OPT      4                 SEVERITY LEVEL
O%ROM    OPT      1                 MODULE IS TO BE A ROM
O%C1     OPT      1                 FORCE CSECT 1 FOR LYNX
O%MAP    OPT      2                 MAP CONTROL FOR LYNX
O%SS     OPT      1                 (SS) OPTION
O%DREF   OPT      1                 (DREF) OPTION FOR LYNX
O%X      OPT      1                 ABORT ON DETECTED ERROR
O%DUPS   OPT      2                 CONTROL ACTION FOR DUPL. SYMS.
O%DUPM   OPT      2                 CONTROL ACTION FOR DUPL. MODULES.
O%A      OPT      1                 LIST ATTRIBUTES
O%DEFS   OPT      1                 LIST DEF'S
O%SORT   OPT      1                 SORT BY NAME
O%DIC    OPT      1                 CONTROL SOURCE OF DEF'S
O%DUPG   OPT      1                 CONTROL ACTION FOR DUP. GROUPS
O%ERR    OPT      1                 CONTROL END'S ACTION IF ERR'S WERE
*                                   ENCOUNTERED IN THIS SESSION.
         PAGE
         SPACE
         DISP     O#LST             THIS IS THE LIST OF OPTIONS...
         TITLE    'LEMUR0 -- OPTION TABLE DEFINITIONS'
         SPACE
         OPEN     I,J,K
OPTION   CNAME
         PROC
K        DO       NUM(AF(1))
         USECT    OPTBL
I        SET      %
         TEXT     AF(1,K)
         DO1      I=(%-1)
         TEXT     ' '               MAKE SURE IT'S 2 WORDS;
         ORG      I+2
         USECT    OPFLGS
I        SET      O#LST(ABSVAL(DA(AF(2)))+1)    GET OPTION
         DATA     I(1)              DEPOSIT MASK
J        SET      AF(3)             GET VALUE TO PUT IN FIELD
         DO1      NUM(AF(3))=0      FORCE A DEFAULT VALUE OF 1
J        SET      1
         DATA     J**I(2)           OUTPUT VALUE
         USECT    SAOPT             GENERATE SPECIAL ACTION TABLE
         DATA     AF(4)
         FIN
         PEND
         CLOSE    I,J,K
         SPACE
OPTIONEND ;
         CNAME
         PROC
         USECT    OPFLGS
OPTMAX   EQU      ABSVAL(%)
         PEND
         PAGE
***************************************************************
*
* OPTION TABLES:
*
         OPTION   ('rom','ROM'),O%ROM
         OPTION   ('C1','c1'),O%C1
         OPTION   ('NOMAP','nomap'),O%MAP,0
         OPTION   ('MN','mn','M','m'),O%MAP,1
         OPTION   ('MV','mv'),O%MAP,2
         OPTION   ('MNV','mnv'),O%MAP,3
         OPTION   ('SS','ss'),O%SS
         OPTION   ('SL','sl'),O%SL,,DOSL
         OPTION   ('DREF','dref'),O%DREF
         OPTION   ('X','x'),O%X
         OPTION   ('REDEF','redef'),O%DUPS,0
         OPTION   ('FIRST','first'),O%DUPS,1
         OPTION   ('APND','apnd'),O%DUPS,2
         OPTION   ('DIE','die'),O%DUPS,3
         OPTION   ('DEL','del'),O%DUPM,0
         OPTION   ('NREPL','nrepl'),O%DUPM,2
         OPTION   ('PROT','prot'),O%DUPM,3
         OPTION   ('A','a'),O%A
         OPTION   ('NA','na'),O%A,0
         OPTION   ('DEFS','defs'),O%DEFS
         OPTION   ('LEX','lex'),O%SORT
         OPTION   ('NAME','name'),O%SORT,0
         OPTION   ('DIC','dic'),O%DIC
         OPTION   ('LIB','lib'),O%DIC,0
         OPTION   ('GDEL','gdel'),O%DUPG
         OPTION   ('GREP','grep'),O%DUPG,0
         OPTION   ('ERR','err'),O%ERR
         OPTIONEND                   THAT'S ALL, FOLKS...
         TITLE    'LEMUR0 -- COMMAND TABLE DEFINITIONS'
         SPACE
*F******************************************************************
*F*
*F* FORMAT OF COMMAND TABLES:
*F*      THE COMAND TABLES CONSIST OF THREE PARALLEL VECTORS:
*F*
*F*      COMTBL IS A VECTOR OF STRING DESCRIPTORS OF THE KNOWN
*F*             COMMANDS.
*F*
*F*      CMDNDX IS A BYTE VECTOR OF THE COMMAND NUMBERS FOR EACH
*F*             STRING DESCRIPTOR.  THUS, THERE CAN BE SYNONYMS
*F*             FOR EACH COMMAND (E.G., UPPER AND LOWER CASE VARIANTS)
*F*             WITHOUT COSTING TOO MUCH EXTRA IN SPACE.
*F*
*F*         THREE TABLES, SORTED BY COMMAND #, CONTROL LEMUR'S
*F*      ACTION WHEN IT HAS RECOGNIZED A COMMAND.
*F*
*F*      CDFOPT IS A DOUBLEWORD VECTOR WHICH SPECIFIES THE INITIAL
*F*             VALUE OF C%OPTS (SEE 'OPTIONS').
*F*
*F*      CAOPT  IS A WORD VECTOR OF ALLOWED OPTION WORDS; AOPTS IS
*F*             SET TO THIS VALUE.
*F*
*F*      CVECT  IS A DISPATCH TABLE CONSISTING OF BRANCHES TO THE
*F*             ROUTINE WHICH HANDLES THE SCANNING AND PROCESSING FOR
*F*             EACH COMMAND.  AFTER INITIALIZING C%OPTS AND AOPTS,
*F*             THE COMMAND SCANNER WILL RELINQUISH CONTROL TO THE
*F*             APPROPRIATE ROUTINE.
*F*
*F******************************************************************
         PAGE
         SPACE
         OPEN     DEF#,OPT#,AOPT,DEFOPT1,DEFOPT2,MASK,VAL,I,FLAGS
         SPACE
CMD      CNAME
         PROC
         DO       AFA(1)            IS THIS A SYNONYM FOR EARLIER COMND?
VAL      SET      AF(1)             YES:  GET INDEX, AND SKIP...
         ELSE                       ...THE COMMAND TABLE GENERATION.
FLAGS    SET      S:KEYS(2,*0,DEFAULTS,*OPTIONS)
DEF#     SET      FLAGS(3)          GET INDEX TO DEFAULT
OPT#     SET      FLAGS(4)          ...AND INDEX TO 'OPTIONS'
* CONSTRUCT DEFAULT OPTION DOUBLE WORD
DEFOPT1         SET 0               INITIAL VALUES...
DEFOPT2  SET      0
I        DO       NUM(AF(DEF#))-1
MASK     SET      O#LST(ABSVAL(DA(AF(DEF#,I+1,1)))+1) GET OPTION MASK & C;
VAL      SET      AF(DEF#,I+1,2)    GET OPTION VALUE
* ADJUST VALUE TO APPROPRIATE BIT
VAL      SET      VAL**MASK(2)
* MAKE NEW VALUE WORD
DEFOPT1   SET     DEFOPT1|VAL
* GET NEW MASK VALUE IF DESIRED BY USER;
         DO1      AFA(DEF#,I+1)
DEFOPT2  SET      DEFOPT2|MASK(1)
*
         FIN
* CONSTRUCT ALLOWED OPTION MASK
AOPT     SET      0
I        DO       NUM(AF(OPT#))-1
MASK     SET      O#LST(ABSVAL(DA(AF(OPT#,I+1)))+1)
AOPT     SET      AOPT|MASK(1)
         ELSE
         ERROR,3  'OPTION KEYWORD MISSING'
         FIN
*GENERATE DEFAULT, ALLOWED OPTION, BRANCH VECTOR.
         USECT    CDFOPT
         DATA     DEFOPT1,DEFOPT2
         USECT    CAOPT
VAL      SET      ABSVAL(%)
         DATA     AOPT
         USECT    CVECT
         B        CF(2)
CF(3)    EQU      VAL
         FIN
*GENERATE DESCRIPTOR FOR EACH COMMAND, CORRESPONDING INDEX.
         USECT    COMTBL
I        DO       NUM(LF)
         DATA     D(LF(I))
         FIN
         USECT    CMDNDX
         DO1      I
         DATA,1   VAL
         PEND
         CLOSE    DEF#,OPT#,AOPT,DEFOPT1,DEFOPT2,MASK,VAL,;
                  I,FLAGS
         SPACE
CMDEND   CNAME
         PROC
         USECT    COMTBL
COMTBLS  EQU      ABSVAL(%)
         PEND
         PAGE
*
* COMMAND TABLE:
*
'ADD','add'  ;                      upper and lower case...
         CMD,ADD% (DEFAULTS,(O%ROM,0),(O%SL,7),*(O%DUPS,3),;
                             *(O%DUPM,2)),;
                  (OPTIONS,O%ROM,O%C1,O%MAP,O%SS,O%SL,O%DREF,;
                           O%X,O%DUPS)
         PAGE
*
'BUILD','build'   ;
         CMD,ADD% (DEFAULTS,(O%ROM,0),(O%SL,7),(O%DUPS,0),;
                            (O%DUPM,0)),;
                  (OPTIONS,O%ROM,O%C1,O%MAP,O%SS,O%SL,O%DREF,;
                           O%X,O%DUPS,O%DUPM)
         PAGE
*
'END','end','X','x'  ;
         CMD,END%      ;
                  (OPTIONS,O%ERR)
         PAGE
'COPY','copy'     ;
         CMD,COPY% (DEFAULTS,(O%DUPM,0)),;
                   (OPTIONS,O%DUPM)
         PAGE
'CARRY','carry'    ;
         CMD,CARRY% (DEFAULTS,(O%DUPM,0),(O%DUPS,0)),;
                    (OPTIONS,O%DUPM,O%DUPS)
         PAGE
'DELETE','delete'    ;
         CMD,DELETE%     ;
                  (OPTIONS,O%X)
         PAGE
*
'LIBRARY','library'   ;
         CMD,LIB%       ;
                  (OPTIONS,O%X)
         PAGE
         CMDEND
         TITLE    'LEMUR0 -- PATCH SPACE...'
         SPACE
         USECT    PATCH
         DO1      100
         DATA     X'BAD'
         TITLE    'LEMUR0 -- LITERAL POOL, SUMMARIES'
         SPACE
         END                        LITERALS FOLLOW....

