User Tools

Site Tools


cdc:nos2.source:nam5871:ssrgnt

SSRGNT

Table Of Contents

  • [00002] PROC SSRGNT(CSTRING, POS, (LEN), TOKEN, EC)
  • [00003] SSRGNT - GET NEXT TOKEN
  • [00007] GET NEXT TOKEN.
  • [00061] PROC SSBEBF
  • [00062] PROC SSBSBF
  • [00083] CSTRING - COMMAND STRING TERMINATED BY AN END OF LINE TERMINATOR,

Source Code

SSRGNT.txt
  1. *DECK SSRGNT
  2. PROC SSRGNT(CSTRING, POS, (LEN), TOKEN, EC);
  3. # TITLE SSRGNT - GET NEXT TOKEN #
  4.  
  5. BEGIN # SSRGNT #
  6. #
  7. ** SSRGNT - GET NEXT TOKEN.
  8. * A TOKEN IS A SINGLE SPECIAL CHARACTER, OR
  9. * A 7 OR LESS ALPHA-NUMERIC STRING.
  10. *
  11. * A. LIM. 82/02/10.
  12. *
  13. * THIS PROCEDURE-S MAIN FUNCTION IS TO GET A TOKEN FROM A
  14. * COMMAND STRING STARTING AT CHARACTER POSITION (POS) WITHIN
  15. * THE STRING. ON RETURNING TO THE CALLER (TOKEN) CONTAINS THE
  16. * JUST TOKENIZED TOKEN, AND (POS) POINTING AT THE NEXT CHARACTER
  17. * IN THE STRING OR AT END OF STRING. IF THERE IS ANY ERRORS,
  18. * AN ERROR CODE WILL RETURN TO THE CALLER, OR WITH (TOKEN)
  19. * CONTAINING THE ERROR TOKEN.
  20. * IT IS CALLED INTO EXECUTION BY: *SSRRCS*
  21. *
  22. * PROC SSRGNT(CSTRING, POS, (LEN), TOKEN, EC)
  23. *
  24. * ENTRY CSTRING = COMMAND STRING WHERE A TOKEN IS TO BE TOKENIZED
  25. * POS = STARTING CHARACTER POSITION WITHIN STRING FOR
  26. * THIS TOKEN.
  27. * LEN = TOTAL LENGTH IN CHARACTERS OF THE STRING.
  28. * 0 FOR STRING TERMINATED BY A SPECIAL CHAR.
  29. * EXIT CSTRING = UNCHANGED.
  30. * POS = NEXT CHAR POSITION WITHIN THE STRING FOR
  31. * THE NEXT TOKEN.
  32. * LEN = UNCHANGED.
  33. * TOKEN = TOKEN STORED.
  34. * EC = ERROR CODE.
  35. * 0 = NO ERROR.
  36. * 1 = PARAMETER TOO LONG.
  37. *
  38. * NOTE THIS PROCEDURE ASSUMES *POS* IS ALWAYS POINTING AT A
  39. * CHARACTER WITHIN THE RANGE OF COMMAND STRING, I. E.
  40. * IN THE CASE OF COMMAND SYNTAX, IT WILL NOT BE POINTING
  41. * AT ANY CHARACTER AFTER THE END-OF-LINE TERMINATOR.
  42. * AND IN THE CASE OF INPUT STRING, IT WILL NOT BE
  43. * POINTING AT ANY CHARACTER OUTSIDE THE RANGE OF *LEN*.
  44. *
  45. * METHOD *SSBEBF* IS CALLED TO EXTRACT A CHARACTER AT A TIME FROM
  46. * THE STRING. THEN *SSBSBF* IS CALLED TO STORE/CONCATENATE
  47. * THE EXTRACTED CHARACTER INTO THE RESULTING TOKEN.
  48. * TOKENIZATION CONTINUES UNTIL A VALID TOKEN, I. E. A SINGL
  49. * SPECIAL CHARACTER OR A 7 OR LESS ALPHA-NUMERIC STRING, IS
  50. * IS TOKENIZED. IN CASE OF ERROR, *EC* WILL BE SET, AND
  51. * *TOKEN* CONTAINS 7 + 1 (+1 FOR THE NEXT TOO CHARACTER)
  52. * CHARACTERS.
  53. #
  54.  
  55.  
  56. #
  57. **** PROC SSRGNT XREF LIST
  58. #
  59. XREF
  60. BEGIN
  61. PROC SSBEBF; # EXTRACT BITFIELD FROM A TABLE #
  62. PROC SSBSBF; # STORE BITFIELD INTO A TABLE #
  63. END
  64. #
  65. ****
  66. #
  67.  
  68.  
  69. # DEFS #
  70.  
  71. DEF CHARLEN$ # 6 #; # CHAR LENGTH IN BITS FOR OCT DISP-CODE #
  72. DEF CHARWD$ # 10 #; # NO OF 6-BIT CHAR PER CM WORD #
  73. DEF CSSIZ$ # 14 #; # MAX NO OF CHARACTERS/COMMAND STRING #
  74. DEF A$ # O"01"#; # OCT DISP-CODE FOR "A" #
  75. DEF NINE$ # O"44"#; # OCT DISP-CODE FOR "9" #
  76. DEF ASTERISK # O"47"#; # OCT DISP-CODE FOR "*" #
  77. DEF TKNSIZ$ # 7 #; # TOKEN SIZE #
  78.  
  79.  
  80. # FORMAL PARAMETERS #
  81.  
  82. #
  83. ** CSTRING - COMMAND STRING TERMINATED BY AN END OF LINE TERMINATOR,
  84. * OR *LEN* NUMBER OF CHARACTERS.
  85. #
  86.  
  87. ARRAY CSTRING[00:00] S(CSSIZ$);
  88. BEGIN
  89. ITEM CST$LINE C(00,00,140);
  90. END
  91.  
  92. ITEM POS I; # CHARACTER POSITION WITHIN STRING #
  93. ITEM LEN I; # LENGTH IN CHARACTERS OF CSTRING #
  94. ITEM TOKEN U; # RESULTING TOKEN #
  95. ITEM EC I; # ERROR CODE #
  96.  
  97.  
  98. # ACTUAL PARAMETERS FOR PROC *SSBEBF*, AND *SSBSBF* #
  99.  
  100. ITEM ORD I; # WORD/ORDINAL WITHIN TABLE #
  101. ITEM BIT I; # STARTING BIT POSITION WITHIN WORD #
  102. ITEM RESULT U; # WORD THAT RECEIVES BIT FIELD #
  103. ITEM SORD I; # WORD WITHIN TOKEN TO STORE #
  104. ITEM SBIT I; # BIT WITHIN TOKEN TO STORE #
  105.  
  106.  
  107. # GENERAL ITEMS #
  108.  
  109. ITEM I I; # LOOP INDUCTION VARIABLE #
  110. ITEM DONE B; # LOOP EXIT VARIABLE #
  111. ITEM NPOS I; # NPOS = POS #
  112.  
  113.  
  114. CONTROL EJECT;
  115.  
  116. # INITIALIZES VARIABLES #
  117.  
  118. TOKEN = O"55555555555555555555"; # CLEAR TOKEN AREA #
  119. EC = 0; # PRESET TO NO ERROR #
  120. SORD = 0; # PRESET TOKEN ORDINAL #
  121. SBIT = 0; # PRESET TOKEN BIT #
  122. DONE = FALSE; # PRESET FLAG TO FALSE #
  123.  
  124. #
  125. * CONVERT CHARACTER POSITION(POS) INTO TABLE ORDINAL(ORD) AND
  126. * STARTING BIT POSITION(BIT) WITHIN ORDINAL.
  127. #
  128.  
  129. NPOS = POS;
  130. ORD = 0;
  131. BIT = NPOS * CHARLEN$;
  132. FOR I = 0 WHILE (NPOS - CHARWD$) GQ 0
  133. DO
  134. BEGIN
  135. NPOS = NPOS - CHARWD$;
  136. ORD = ORD + 1;
  137. BIT = NPOS * CHARLEN$;
  138. END
  139.  
  140.  
  141. #
  142. * GET FIRST CHARACTER FROM COMMAND STRING *CSTRING* STARTING FROM
  143. * CURRENT CHARACTER POSITION *POS*, AND STORE IT INTO *TOKEN*.
  144. * IF THIS IS A SPECIAL CHARACTER, WE ARE DONE, AND RETURN THE TOKEN.
  145. * ELSE, IT MUST BE AN ALPHA-NUMERIC STRING.
  146. * CONTINUE THE TOKENIZATION PROCESS UNTIL A 7 CHARACTERS HAS REACHED
  147. * OR A SPECIAL CHARACTER IS HIT, OR *LEN* IS REACHED. IF LONGER THA
  148. * 7 CHARACTERS, EXIT WITH ERROR CODE, AND *TOKEN* CONTAINS 8
  149. * CHARACTERS.
  150. #
  151.  
  152.  
  153. SSBEBF(CSTRING, ORD, BIT, CHARLEN$, RESULT); # GET FIRST CHAR #
  154. SSBSBF(TOKEN, SORD, SBIT, CHARLEN$, RESULT); # STORE THE CHAR #
  155. POS = POS + 1; # INCREMENT POS #
  156. IF ( (RESULT LS A$) OR (RESULT GR NINE$) )
  157. AND ( RESULT NQ ASTERISK )
  158. THEN GOTO EXIT; # SPECIAL CHAR, DONE #
  159.  
  160. FOR I = 1 STEP 1 WHILE ((NOT DONE)
  161. AND (POS NQ LEN)
  162. AND (I LS TKNSIZ$))
  163. DO # LOOP TIL DONE OR LEN REACHED OR 7 CHAR #
  164. BEGIN
  165. SSBEBF(CSTRING, ORD, BIT, CHARLEN$, RESULT); # EXTRACT A CHAR #
  166. IF ( (RESULT LS A$) OR (RESULT GR NINE$) )
  167. AND ( RESULT NQ ASTERISK )
  168. THEN
  169. BEGIN
  170. DONE = TRUE; # SPECIAL CHAR HIT, DONE #
  171. END
  172. ELSE
  173. BEGIN
  174. SSBSBF(TOKEN, SORD, SBIT, CHARLEN$, RESULT); #CONCATENATE CHR#
  175. POS = POS + 1; # INCREMENT CHAR POS #
  176. END
  177. END
  178.  
  179. IF ((NOT DONE)
  180. AND (POS NQ LEN))
  181. THEN
  182. BEGIN # 7 ALPHA-NUM CHARS ALREADY #
  183. SSBEBF(CSTRING, ORD, BIT, CHARLEN$, RESULT); # LOOK AHEAD #
  184. IF ((RESULT GQ A$) AND (RESULT LQ NINE$))
  185. OR ( RESULT EQ ASTERISK )
  186. THEN
  187. BEGIN # NEXT CHAR NOT SPECIAL CHAR #
  188. SSBSBF(TOKEN, SORD, SBIT, CHARLEN$, RESULT); # STORE CHAR #
  189. EC = 1; # PARAMETER TOO LONG #
  190. END
  191. END
  192.  
  193. EXIT:
  194. END # SSRGNT #
  195.  
  196. TERM
cdc/nos2.source/nam5871/ssrgnt.txt ยท Last modified: 2023/08/05 17:23 by Site Administrator