home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / modcomp / parser. < prev    next >
Text File  |  2020-01-01  |  9KB  |  297 lines

  1.       SUBROUTINE PARSER
  2. C
  3. C     ****************************************************************
  4. C
  5. C              KERMIT for the MODCOMP MAXIV operating system
  6. C
  7. C        Compliments of:
  8. C
  9. C                         SETPOINT, Inc.
  10. C                      10245 Brecksville Rd.
  11. C                      Brecksville, Ohio 44141
  12. C
  13. C
  14. C      KERMIT is a copyrighted protocol of Columbia Univ. The authors
  15. C      of this version hereby grant permission to copy this software
  16. C      provided that it is not used for an explicitly commercial
  17. C      purpose and that proper credit be given. SETPOINT, Inc. makes
  18. C      no warranty whatsoever regarding the accuracy of this package
  19. C      and will assume no liability resulting from it's use.
  20. C
  21. C     ****************************************************************
  22. C
  23. C     Abstract:  Main Command Parser
  24. C
  25. C     MODIFICATION HISTORY
  26. C
  27. C     BY            DATE     REASON            PROGRAMS AFFECTED
  28. C
  29. C     ****************************************************************
  30. C
  31. C     Author:  Rick Burke           Version: A.0    Date:  Aug-86
  32. C
  33. C     Calling Parameters:  None
  34. C
  35. C     ****************************************************************
  36. C
  37. C     Messages generated by this module :  None
  38. C
  39. C     ****************************************************************
  40. C
  41. C     Subroutines called directly :  IAND, ISHFT, READ4, SCONNE,
  42. C                                    SHELP, SKIPBL, SQUIT, SRECEI,
  43. C                                    SSEND, SSET, SSTATU, UPPER
  44. C
  45. C     ****************************************************************
  46. C
  47. C     Files referenced :  None
  48. C
  49. C     ****************************************************************
  50. C
  51. C     Local variable definitions :
  52. C
  53. C     ACOUNT       - Index variable into ALIN
  54. C     CCOUNT       - Index variable into CLIN
  55. C     CMDLEN       - Max length of each command in CMDTBL
  56. C     FOUND        - Number of matches - 1 found in CMDTBL
  57. C     I            - Index variable
  58. C     IEND         - Number of chars in CLIN to search for the
  59. C                    the end of the user-entered word
  60. C     J            - Index variable
  61. C     NDX          - Index variable
  62. C     NUMCMD       - Number of commands in CMDTBL
  63. C     TV1          - Temporary variable
  64. C     WCHCMD       - Index into CMDTBL to command requested by the
  65. C                    the user
  66. C     ALIN(132)    - Command line entered by user
  67. C     CLIN(132)    - Upper case command line entered by user
  68. C     CMDTBL(8,8)  - Table of commands allowed by Kermit
  69. C
  70. C     ****************************************************************
  71. C
  72. C     Commons referenced : KER, KERPAR, and UFTTBL local commons
  73. C
  74. C     ****************************************************************
  75. C
  76. C     (*$END.DOCUMENT*)
  77. C
  78. C     ****************************************************************
  79. C     *                                                              *
  80. C     *         D I M E N S I O N   S T A T E M E N T S              *
  81. C     *                                                              *
  82. C     ****************************************************************
  83. C
  84.       IMPLICIT INTEGER (A-Z)
  85.       INTEGER*2   CMDTBL(8,8)
  86.       INTEGER*2   ALIN(132),   CLIN(132)
  87. C
  88. C     ****************************************************************
  89. C     *                                                              *
  90. C     *         T Y P E   S T A T E M E N T S                        *
  91. C     *                                                              *
  92. C     ****************************************************************
  93. C
  94. C
  95. C     ****************************************************************
  96. C     *                                                              *
  97. C     *         C O M M O N   S T A T E M E N T S                    *
  98. C     *                                                              *
  99. C     ****************************************************************
  100. C
  101.       INCLUDE USL/KERCOM
  102.       INCLUDE USL/KERPMC
  103.       INCLUDE USL/UFTTBC
  104. C
  105. C     ****************************************************************
  106. C     *                                                              *
  107. C     *         E Q U I V A L E N C E   S T A T E M E N T S          *
  108. C     *                                                              *
  109. C     ****************************************************************
  110. C
  111. C
  112. C     ****************************************************************
  113. C     *                                                              *
  114. C     *         D A T A   S T A T E M E N T S                        *
  115. C     *                                                              *
  116. C     ****************************************************************
  117. C
  118. C----->  Implemented commands are:
  119. C
  120. C                 1) CONNECT - hooks to a dummy routine provided
  121. C                 2) EXIT
  122. C                 3) HELP
  123. C                 4) QUIT
  124. C                 5) RECEIVE
  125. C                 6) SET
  126. C                 7) SEND
  127. C                 8) STATUS
  128. C
  129.       DATA        CMDTBL   /67,79,78,78,69,67,84,10002,
  130.      >                      69,88,73,84,10002,0,0,0,
  131.      >                      72,69,76,80,10002,0,0,0,
  132.      >                      81,85,73,84,10002,0,0,0,
  133.      >                      82,69,67,69,73,86,69,10002,
  134.      >                      83,69,84,10002,0,0,0,0,
  135.      >                      83,69,78,68,10002,0,0,0,
  136.      >                      83,84,65,84,85,83,10002,0/
  137.       DATA        NUMCMD /8/,  CMDLEN /8/
  138. C
  139. C     ****************************************************************
  140. C
  141. C     Code starts here :
  142. C
  143.    10 CONTINUE
  144.       WRITE (LOCALO,1000)
  145.  1000 FORMAT (' KERMIT MAXIV> ')
  146. C
  147. C----->  Read a line from the keyboard and convert it to
  148. C----->  uppercase.
  149. C
  150.       DO 11 I=1,32
  151.       ALIN(I) = 0
  152.       CLIN(I) = 0
  153.    11 CONTINUE
  154.       CALL READ4 (IUFT(1,2),CLIN,132,.TRUE.)
  155.       IF (IAND (IUFT(1,2),4Z0020) .NE. 0) CALL SQUIT
  156. C
  157. C----->  Unpack the line so the other character manipulation
  158. C----->  routines will work.
  159. C
  160.       ACOUNT = 1
  161.       CCOUNT = 1
  162.    12 CONTINUE
  163.       TV1 = ISHFT (CLIN(CCOUNT),-8)
  164.       IF (TV1 .EQ. 0) GO TO 13
  165.       ALIN(ACOUNT) = TV1
  166.       ACOUNT = ACOUNT + 1
  167.       TV1 = IAND (CLIN(CCOUNT),4Z00FF)
  168.       IF (TV1 .EQ. 0) GO TO 13
  169.       ALIN(ACOUNT) = TV1
  170.       ACOUNT = ACOUNT + 1
  171.       CCOUNT = CCOUNT + 1
  172.       GO TO 12
  173.    13 CONTINUE
  174.       IF (ALIN(ACOUNT-1) .EQ. BLANK) ACOUNT = ACOUNT - 1
  175.       ALIN(ACOUNT) = LF
  176.       ALIN(ACOUNT+1) = EOS
  177. C
  178.       CALL UPPER (ALIN,CLIN)
  179. C
  180. C----->  Extract the first word in the command line and remove
  181. C----->  any leading blanks.
  182. C
  183.       TV1 = 1
  184.       CALL SKIPBL (CLIN,TV1)
  185.       DO 20 I=1,132
  186.       ALIN(I) = 0
  187.    20 CONTINUE
  188.       IEND = 81 - TV1
  189.       DO 30 NDX=1,IEND
  190.       ALIN(NDX) = CLIN(NDX+TV1-1)
  191.       IF (ALIN(NDX) .EQ.   LF .OR.
  192.      >    ALIN(NDX) .EQ. BLANK     ) GO TO 40
  193.    30 CONTINUE
  194.       NDX = IEND + 1
  195.    40 CONTINUE
  196.       ALIN(NDX) = LF
  197.       ALIN(NDX+1) = EOS
  198. C
  199. C----->  Loop to compare word from command line to all commands.
  200. C
  201.       FOUND = -1
  202.       WCHCMD = 0
  203.       DO 70 J=1,NUMCMD
  204.       DO 50 I=1,CMDLEN
  205. C
  206. C----->  Check for end of word. If end of word then we have a match.
  207. C
  208.       IF (ALIN(I) .EQ. LF) GO TO 60
  209. C
  210. C----->  Check for end of key word. If end of key word found then
  211. C----->  we don't have a match.
  212. C
  213.       IF (CMDTBL(I,J) .EQ. EOS) GO TO 70
  214. C
  215. C----->  Compare the characters.
  216. C
  217.       IF (ALIN(I) .NE. CMDTBL(I,J)) GO TO 70
  218.    50 CONTINUE
  219.       GO TO 70
  220.    60 CONTINUE
  221. C
  222. C----->  Here user's command matches a keyword, so remember which
  223. C----->  command was matched and bump the counter for number of
  224. C----->  matches found and loop back to check the next command.
  225. C
  226.       WCHCMD = J
  227.       FOUND = FOUND + 1
  228.    70 CONTINUE
  229. C
  230. C----->  Branch based on the number of matches found between the
  231. C----->  user's command and the command table.
  232. C
  233.       IF (FOUND) 200,100,300
  234.   100 CONTINUE
  235. C
  236. C----->  User's command matched only one keyword, so process it.
  237. C
  238.       GOTO (110,120,130,120,150,160,170,180),WCHCMD
  239.   110 CONTINUE
  240. C
  241. C----->  CONNECT keyword.
  242. C
  243.       CALL SCONNE
  244.       GO TO 10
  245.   120 CONTINUE
  246. C
  247. C----->  EXIT keyword.
  248. C
  249.       CALL SQUIT
  250.   130 CONTINUE
  251. C
  252. C----->  HELP keyword.
  253. C
  254.       CALL SHELP
  255.       GO TO 10
  256.   150 CONTINUE
  257. C
  258. C----->  RECEIVE keyword.
  259. C
  260.       CALL SRECEI
  261.       GO TO 10
  262.   160 CONTINUE
  263. C
  264. C----->  SET keyword.
  265. C
  266.       CALL SSET (CLIN(TV1+NDX-1))
  267.       GO TO 10
  268.   170 CONTINUE
  269. C
  270. C----->  SEND keyword.
  271. C
  272.       CALL SSEND (CLIN(TV1+NDX-1))
  273.       GO TO 10
  274.   180 CONTINUE
  275. C
  276. C----->  STATUS keyword.
  277. C
  278.       CALL SSTATU
  279.       GO TO 10
  280.   200 CONTINUE
  281. C
  282. C----->  User's command does not match any valid key word.
  283. C
  284.       WRITE (LOCALO,1010)
  285.  1010 FORMAT (' UNRECOGNIZED COMMAND - TYPE "HELP"')
  286.       GO TO 10
  287.   300 CONTINUE
  288. C
  289. C----->  User's command word matches more than 1 valid keyword.
  290. C
  291.       WRITE (LOCALO,1020)
  292.  1020 FORMAT (' AMBIGUOUS COMMAND - TYPE "HELP"')
  293.       GO TO 10
  294.   400 CONTINUE
  295.       RETURN
  296.       END
  297.