*DECK SSRGNT PROC SSRGNT(CSTRING, POS, (LEN), TOKEN, EC); # TITLE SSRGNT - GET NEXT TOKEN # BEGIN # SSRGNT # # ** SSRGNT - GET NEXT TOKEN. * A TOKEN IS A SINGLE SPECIAL CHARACTER, OR * A 7 OR LESS ALPHA-NUMERIC STRING. * * A. LIM. 82/02/10. * * THIS PROCEDURE-S MAIN FUNCTION IS TO GET A TOKEN FROM A * COMMAND STRING STARTING AT CHARACTER POSITION (POS) WITHIN * THE STRING. ON RETURNING TO THE CALLER (TOKEN) CONTAINS THE * JUST TOKENIZED TOKEN, AND (POS) POINTING AT THE NEXT CHARACTER * IN THE STRING OR AT END OF STRING. IF THERE IS ANY ERRORS, * AN ERROR CODE WILL RETURN TO THE CALLER, OR WITH (TOKEN) * CONTAINING THE ERROR TOKEN. * IT IS CALLED INTO EXECUTION BY: *SSRRCS* * * PROC SSRGNT(CSTRING, POS, (LEN), TOKEN, EC) * * ENTRY CSTRING = COMMAND STRING WHERE A TOKEN IS TO BE TOKENIZED * POS = STARTING CHARACTER POSITION WITHIN STRING FOR * THIS TOKEN. * LEN = TOTAL LENGTH IN CHARACTERS OF THE STRING. * 0 FOR STRING TERMINATED BY A SPECIAL CHAR. * EXIT CSTRING = UNCHANGED. * POS = NEXT CHAR POSITION WITHIN THE STRING FOR * THE NEXT TOKEN. * LEN = UNCHANGED. * TOKEN = TOKEN STORED. * EC = ERROR CODE. * 0 = NO ERROR. * 1 = PARAMETER TOO LONG. * * NOTE THIS PROCEDURE ASSUMES *POS* IS ALWAYS POINTING AT A * CHARACTER WITHIN THE RANGE OF COMMAND STRING, I. E. * IN THE CASE OF COMMAND SYNTAX, IT WILL NOT BE POINTING * AT ANY CHARACTER AFTER THE END-OF-LINE TERMINATOR. * AND IN THE CASE OF INPUT STRING, IT WILL NOT BE * POINTING AT ANY CHARACTER OUTSIDE THE RANGE OF *LEN*. * * METHOD *SSBEBF* IS CALLED TO EXTRACT A CHARACTER AT A TIME FROM * THE STRING. THEN *SSBSBF* IS CALLED TO STORE/CONCATENATE * THE EXTRACTED CHARACTER INTO THE RESULTING TOKEN. * TOKENIZATION CONTINUES UNTIL A VALID TOKEN, I. E. A SINGL * SPECIAL CHARACTER OR A 7 OR LESS ALPHA-NUMERIC STRING, IS * IS TOKENIZED. IN CASE OF ERROR, *EC* WILL BE SET, AND * *TOKEN* CONTAINS 7 + 1 (+1 FOR THE NEXT TOO CHARACTER) * CHARACTERS. # # **** PROC SSRGNT XREF LIST # XREF BEGIN PROC SSBEBF; # EXTRACT BITFIELD FROM A TABLE # PROC SSBSBF; # STORE BITFIELD INTO A TABLE # END # **** # # DEFS # DEF CHARLEN$ # 6 #; # CHAR LENGTH IN BITS FOR OCT DISP-CODE # DEF CHARWD$ # 10 #; # NO OF 6-BIT CHAR PER CM WORD # DEF CSSIZ$ # 14 #; # MAX NO OF CHARACTERS/COMMAND STRING # DEF A$ # O"01"#; # OCT DISP-CODE FOR "A" # DEF NINE$ # O"44"#; # OCT DISP-CODE FOR "9" # DEF ASTERISK # O"47"#; # OCT DISP-CODE FOR "*" # DEF TKNSIZ$ # 7 #; # TOKEN SIZE # # FORMAL PARAMETERS # # ** CSTRING - COMMAND STRING TERMINATED BY AN END OF LINE TERMINATOR, * OR *LEN* NUMBER OF CHARACTERS. # ARRAY CSTRING[00:00] S(CSSIZ$); BEGIN ITEM CST$LINE C(00,00,140); END ITEM POS I; # CHARACTER POSITION WITHIN STRING # ITEM LEN I; # LENGTH IN CHARACTERS OF CSTRING # ITEM TOKEN U; # RESULTING TOKEN # ITEM EC I; # ERROR CODE # # ACTUAL PARAMETERS FOR PROC *SSBEBF*, AND *SSBSBF* # ITEM ORD I; # WORD/ORDINAL WITHIN TABLE # ITEM BIT I; # STARTING BIT POSITION WITHIN WORD # ITEM RESULT U; # WORD THAT RECEIVES BIT FIELD # ITEM SORD I; # WORD WITHIN TOKEN TO STORE # ITEM SBIT I; # BIT WITHIN TOKEN TO STORE # # GENERAL ITEMS # ITEM I I; # LOOP INDUCTION VARIABLE # ITEM DONE B; # LOOP EXIT VARIABLE # ITEM NPOS I; # NPOS = POS # CONTROL EJECT; # INITIALIZES VARIABLES # TOKEN = O"55555555555555555555"; # CLEAR TOKEN AREA # EC = 0; # PRESET TO NO ERROR # SORD = 0; # PRESET TOKEN ORDINAL # SBIT = 0; # PRESET TOKEN BIT # DONE = FALSE; # PRESET FLAG TO FALSE # # * CONVERT CHARACTER POSITION(POS) INTO TABLE ORDINAL(ORD) AND * STARTING BIT POSITION(BIT) WITHIN ORDINAL. # NPOS = POS; ORD = 0; BIT = NPOS * CHARLEN$; FOR I = 0 WHILE (NPOS - CHARWD$) GQ 0 DO BEGIN NPOS = NPOS - CHARWD$; ORD = ORD + 1; BIT = NPOS * CHARLEN$; END # * GET FIRST CHARACTER FROM COMMAND STRING *CSTRING* STARTING FROM * CURRENT CHARACTER POSITION *POS*, AND STORE IT INTO *TOKEN*. * IF THIS IS A SPECIAL CHARACTER, WE ARE DONE, AND RETURN THE TOKEN. * ELSE, IT MUST BE AN ALPHA-NUMERIC STRING. * CONTINUE THE TOKENIZATION PROCESS UNTIL A 7 CHARACTERS HAS REACHED * OR A SPECIAL CHARACTER IS HIT, OR *LEN* IS REACHED. IF LONGER THA * 7 CHARACTERS, EXIT WITH ERROR CODE, AND *TOKEN* CONTAINS 8 * CHARACTERS. # SSBEBF(CSTRING, ORD, BIT, CHARLEN$, RESULT); # GET FIRST CHAR # SSBSBF(TOKEN, SORD, SBIT, CHARLEN$, RESULT); # STORE THE CHAR # POS = POS + 1; # INCREMENT POS # IF ( (RESULT LS A$) OR (RESULT GR NINE$) ) AND ( RESULT NQ ASTERISK ) THEN GOTO EXIT; # SPECIAL CHAR, DONE # FOR I = 1 STEP 1 WHILE ((NOT DONE) AND (POS NQ LEN) AND (I LS TKNSIZ$)) DO # LOOP TIL DONE OR LEN REACHED OR 7 CHAR # BEGIN SSBEBF(CSTRING, ORD, BIT, CHARLEN$, RESULT); # EXTRACT A CHAR # IF ( (RESULT LS A$) OR (RESULT GR NINE$) ) AND ( RESULT NQ ASTERISK ) THEN BEGIN DONE = TRUE; # SPECIAL CHAR HIT, DONE # END ELSE BEGIN SSBSBF(TOKEN, SORD, SBIT, CHARLEN$, RESULT); #CONCATENATE CHR# POS = POS + 1; # INCREMENT CHAR POS # END END IF ((NOT DONE) AND (POS NQ LEN)) THEN BEGIN # 7 ALPHA-NUM CHARS ALREADY # SSBEBF(CSTRING, ORD, BIT, CHARLEN$, RESULT); # LOOK AHEAD # IF ((RESULT GQ A$) AND (RESULT LQ NINE$)) OR ( RESULT EQ ASTERISK ) THEN BEGIN # NEXT CHAR NOT SPECIAL CHAR # SSBSBF(TOKEN, SORD, SBIT, CHARLEN$, RESULT); # STORE CHAR # EC = 1; # PARAMETER TOO LONG # END END EXIT: END # SSRGNT # TERM