home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / d / mt2ker.sr < prev    next >
Text File  |  2020-01-01  |  13KB  |  275 lines

  1.  
  2. /title "KERMIT Grammar"
  3.  
  4. -- Author : Bruce Jolliffe
  5.  
  6. -- This is the grammar for the KERMIT program
  7.  
  8. procedure main_semantics for
  9.      ks_exit_command,     ks_finish_command,
  10.      ks_server_command,    ks_status_command,
  11.      ks_get_simple_filename, ks_get_remote_filename,
  12.      ks_get_local_filename, ks_error_bad_get_parm,
  13.      ks_receive,           ks_error_bad_receive_parm,
  14.      ks_receive_local_filename, ks_save_filename,
  15.      ks_send_simple_filename,
  16.      ks_send_remote_filename, ks_send_local_filename,
  17.      ks_error_bad_send_parm,     ks_set_debug_on,
  18.      ks_set_debug_off, ks_mcmd,
  19.      ks_set_filetype_text, ks_set_filetype_binary,
  20.      ks_set_filetype_mts_binary,
  21.      ks_set_binary_blocksize, ks_set_text_blocksize,
  22.      ks_set_delay, ks_bye_command, ks_set_failure,
  23.      ks_set_line, ks_invalid_command,
  24.      ks_error_on_off;
  25.  
  26. procedure set_semantics for
  27.    ks_my_end_of_line, ks_my_packet_length, ks_my_padding,
  28.    ks_my_padchar, ks_my_quote, ks_my_start_of_packet,
  29.    ks_my_timeout,
  30.    ks_your_end_of_line, ks_your_packet_length, ks_your_padding,
  31.    ks_your_padchar, ks_your_quote, ks_your_start_of_packet,
  32.    ks_your_timeout, ks_set_packet_count_interval,
  33.    ks_set_packet_count_interval_off, ks_set_escape;
  34.  
  35. procedure show_semantics for
  36.    kssh_my_end_of_line, kssh_my_packet_length, kssh_my_padding,
  37.    kssh_my_padchar, kssh_my_quote, kssh_my_start_of_packet,
  38.    kssh_my_timeout,
  39.    kssh_your_end_of_line, kssh_your_packet_length, kssh_your_padding,
  40.    kssh_your_padchar, kssh_your_quote, kssh_your_start_of_packet,
  41.    kssh_your_timeout,
  42.    kssh_binary_blocksize,
  43.    kssh_notify, kssh_filetype, kssh_delay, kssh_debug;
  44.  
  45. goal <Kermit_Command> is *blanks* <kermit_command_text>;
  46.  
  47. <kermit_command_text> is "BYE"  *blanks* *end_of_line*        #ks_bye_command
  48.                       or "EXIT" *blanks* *end_of_line*        #ks_exit_command
  49.                       or "FINISH" *blanks* *end_of_line*      #ks_finish_command
  50.                       or <get_command>
  51.                       or <help_command>
  52.                       or "LOGOFF" *blanks* *end_of_line*      #ks_bye_command
  53.                       or "QUIT"   *blanks* *end_of_line*      #ks_exit_command
  54.                       or "STOP"   *blanks* *end_of_line*      #ks_exit_command
  55.                       or <receive_command>
  56.                       or <send_command>
  57.                       or "SERVER" *blanks* *end_of_line*      #ks_server_command
  58.                       or <set_command>
  59.                       or <show_command>
  60.                       or "STATUS" *blanks* *end_of_line*      #ks_status_command
  61.                       or <mcmd_command>
  62.                       or <anything> *blanks* *end_of_line*    #ks_invalid_comman
  63.  
  64. <help_command> is "?" or
  65.                    "HELP"   *help_command*;
  66.  
  67. <get_command>    is "GET" <blanks> <get_parameter>;
  68. <get_parameter>  is <get_remote_filename> <blanks> <get_local_filename>
  69.                  or <remote_filename> #ks_save_filename
  70.                    *blanks* *end_of_line*       #ks_get_simple_filename
  71.                  or <anything> *end_of_line*                       #ks_error_bad
  72.  
  73. <get_remote_filename> is <remote_filename>                         #ks_get_remot
  74. <get_local_filename>  is <mts_filename> #ks_save_filename
  75.                         *blanks* *end_of_line*     #ks_get_local_filename;
  76.  
  77. <receive_command>   is "REC"!"EIVE"! <receive_parameter>;
  78. <receive_parameter> is <blanks> <receive_local_filename>
  79.                     or *blanks* *end_of_line*                      #ks_receive
  80.                     or <anything> *end_of_line*                    #ks_error_bad
  81.  
  82. <receive_local_filename> is <mts_filename> #ks_save_filename
  83.                            *blanks* *end_of_line*  #ks_receive_local_filename;
  84.  
  85. <send_command>   is "SEND" <blanks> <send_parameter>;
  86. <send_parameter> is <send_local_filename> <blanks> <send_remote_filename>
  87.                  or <mts_filename> #ks_save_filename
  88.                    *blanks* *end_of_line*     #ks_send_simple_filename
  89.                  or <anything> *end_of_line*                  #ks_error_bad_send
  90.  
  91. <send_local_filename>  is <mts_filename>    #ks_send_local_filename;
  92. <send_remote_filename> is <remote_filename> #ks_save_filename
  93.                          *blanks* *end_of_line* #ks_send_remote_filename;
  94.  
  95. <set_command> is "SET" <blanks> <set_parameter>;
  96.  
  97. <set_parameter> is <set_debug>
  98.                 or <set_filetype>
  99.                 or <set_delay>
  100.                 or <set_receive_parameters>
  101.                 or <set_send_parameters>
  102.                 or <set_line>
  103.                 or <set_packet_count_interval>
  104.                 or <set_binary_blocksize>
  105.                 or <set_text_blocksize>
  106.                 or <set_escape>
  107.                 or <set_failure>;
  108.  
  109. <set_debug>    is "DEBUG" <debug_option>;
  110. <debug_option> is *blanks*  *end_of_line*                #ks_set_debug_on
  111.                or <blanks> "ON" *blanks* *end_of_line*   #ks_set_debug_on
  112.                or <blanks> "OFF" *blanks* *end_of_line*  #ks_set_debug_off
  113.                or <anything>  *end_of_line*              #ks_error_on_off;
  114.  
  115. <set_filetype> is "FILETYPE" <blanks> <filetype_option>;
  116.  
  117. <filetype_option> is "TEXT" *blanks* *end_of_line*          #ks_set_filetype_tex
  118.                   or "BIN"!"ARY"! *blanks* *end_of_line*    #ks_set_filetype_bin
  119.                   or "MTS-BIN"!"ARY"! *blanks* *end_of_line* #ks_set_filetype_mt
  120.  
  121. <set_delay> is "DELAY" *blanks* *integer* *blanks* *end_of_line* #ks_set_delay;
  122.  
  123. <set_receive_parameters> is "RECEIVE" <blanks> <receive_parameters>;
  124.  
  125. <receive_parameters> is "END-OF-LINE"     *blanks* <my_end_of_line>
  126.                      or "PACKET-LENGTH"   *blanks* <my_packet_length>
  127.                      or "PADDING"         *blanks* <my_padding>
  128.                      or "PADCHAR"         *blanks* <my_padchar>
  129.                      or "QUOTE"           *blanks* <my_quote>
  130.                      or "START-OF-PACKET" *blanks* <my_start_of_packet>
  131.                      or "TIMEOUT"         *blanks* <my_timeout>;
  132.  
  133. <my_end_of_line>     is *integer* *blanks* *end_of_line* #ks_my_end_of_line;
  134.  
  135. <my_packet_length>   is *integer* *blanks* *end_of_line* #ks_my_packet_length;
  136.  
  137. <my_padding>         is *integer* *blanks* *end_of_line* #ks_my_padding;
  138.  
  139. <my_padchar>         is *integer* *blanks* *end_of_line* #ks_my_padchar;
  140.  
  141. <my_quote>           is *integer* *blanks* *end_of_line* #ks_my_quote;
  142.  
  143. <my_start_of_packet> is *integer* *blanks* *end_of_line* #ks_my_start_of_packet;
  144.  
  145. <my_timeout>         is *integer* *blanks* *end_of_line* #ks_my_timeout;
  146.  
  147. <set_send_parameters> is "SEND" <blanks> <send_parameters>;
  148.  
  149. <send_parameters>    is "END-OF-LINE"      *blanks* <your_end_of_line>
  150.                      or "PACKET-LENGTH"    *blanks* <your_packet_length>
  151.                      or "PADDING"          *blanks* <your_padding>
  152.                      or "PADCHAR"          *blanks* <your_padchar>
  153.                      or "QUOTE"            *blanks* <your_quote>
  154.                      or "START-OF-PACKET"  *blanks* <your_start_of_packet>
  155.                      or "TIMEOUT"          *blanks* <your_timeout>;
  156.  
  157. <your_end_of_line>     is *integer* *blanks* *end_of_line* #ks_your_end_of_line;
  158.  
  159. <your_packet_length>   is *integer* *blanks* *end_of_line* #ks_your_packet_lengt
  160.  
  161. <your_padding>         is *integer* *blanks* *end_of_line* #ks_your_padding;
  162.  
  163. <your_padchar>         is *integer* *blanks* *end_of_line* #ks_your_padchar;
  164.  
  165. <your_quote>           is *integer* *blanks* *end_of_line* #ks_your_quote;
  166.  
  167. <your_start_of_packet> is *integer* *blanks* *end_of_line* #ks_your_start_of_pac
  168.  
  169. <your_timeout>         is *integer* *blanks* *end_of_line* #ks_your_timeout;
  170.  
  171. <show_command> is "SHOW" <blanks> <show_parameter>;
  172.  
  173. <show_parameter> is "BINARY-BLOCKSIZE" *blanks* *end_of_line* #kssh_binary_block
  174.                  or "DEBUG" *blanks* *end_of_line*            #kssh_debug
  175.                  or "DELAY" *blanks* *end_of_line*            #kssh_delay
  176.                  or "FILETYPE" *blanks* *end_of_line*         #kssh_filetype
  177.                  or "NOTIFY" *blanks* *end_of_line*           #kssh_notify
  178.                  or "RECEIVE" <blanks> <show_receive_parameters>
  179.                  or "SEND"    <blanks> <show_send_parameters>;
  180.  
  181. <show_receive_parameters> is "END-OF_LINE" *blanks* *end_of_line*    #kssh_my_en
  182.                           or "PACKET-LENGTH" *blanks* *end_of_line*  #kssh_my_pa
  183.                           or "PADDING" *blanks* *end_of_line*        #kssh_my_pa
  184.                           or "PADCHAR" *blanks* *end_of_line*        #kssh_my_pa
  185.                           or "QUOTE" *blanks* *end_of_line*          #kssh_my_qu
  186.                           or "START-OF-PACKET" *blanks* *end_of_line* #kssh_my_s
  187.                           or "TIMEOUT" *blanks* *end_of_line*        #kssh_my_ti
  188.  
  189. <show_send_parameters>    is "END-OF-LINE" *blanks* *end_of_line*    #kssh_your_
  190.                           or "PACKET-LENGTH" *blanks* *end_of_line*  #kssh_your_
  191.                           or "PADDING" *blanks* *end_of_line*        #kssh_your_
  192.                           or "PADCHAR" *blanks* *end_of_line*        #kssh_your_
  193.                           or "QUOTE" *blanks* *end_of_line*          #kssh_your_
  194.                           or "START-OF-PACKET" *blanks* *end_of_line* #kssh_your
  195.                           or "TIMEOUT" *blanks* *end_of_line*        #kssh_your_
  196.  
  197. <set_line>     is *blanks* "LINE" *blanks*  <pseudo_unit>;
  198. <pseudo_unit>  is "*" <pseudo_unit_terminal> "*" *blanks* *end_of_line* #ks_set_
  199. terminal <pseudo_unit_terminal> is 1 or more of
  200. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
  201.  
  202. <set_binary_blocksize> is "BINARY-BLOCKSIZE" *blanks*
  203.                            *integer* *blanks* *end_of_line* #ks_set_binary_block
  204.  
  205. <set_text_blocksize>   is "TEXT-BLOCKSIZE" *blanks*
  206.                            *integer* *blanks* *end_of_line* #ks_set_text_blocksi
  207.  
  208. <set_packet_count_interval> is "NOTIFY" *blanks* <set_notify_value>;
  209.  
  210. <set_notify_value> is *integer* *blanks* *end_of_line* #ks_set_packet_count_inte
  211.                    or "OFF" *blanks* *end_of_line*     #ks_set_packet_count_inte
  212.  
  213. <set_escape> is *blanks* "ESCAPE" *blanks* <escape_char>;
  214. <escape_char> is <escape_char_terminal> *blanks* *end_of_line* #ks_set_escape;
  215. terminal <escape_char_terminal> is 1 character;
  216.  
  217. <set_failure> is <anything> *end_of_line*    #ks_set_failure;
  218.  
  219. <mcmd_command> is "$" <mcmd_text> *blanks* *end_of_line* #ks_mcmd;
  220. terminal <mcmd_text> is 0 or more characters;
  221.  
  222. terminal <mts_filename> is 1 or more of
  223. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.<]$*-/%_>#:";
  224.  
  225. terminal <remote_filename> is 1 or more excluding " ,";
  226.  
  227. terminal <anything> is 0 or more characters;
  228.  
  229. terminal <blanks> is 1 or more of " ";
  230.  
  231. -- This section of the grammer is used to parse the PAR string when
  232. -- Kermit is called as a main program
  233.  
  234. procedure par_string_semantics for
  235.    ps_set_mode_user, ps_set_mode_server,
  236.    ps_set_filetype_binary, ps_set_filetype_mts_binary, ps_set_filetype_text,
  237.    ps_remote_mts, ps_set_debug;
  238.  
  239. goal <Par_string_list> is *blanks* <par_string_item> *blanks*
  240.                           <par_string_delimiter> *blanks*
  241.                           <par_string_item> *blanks* ... *end_of_line*;
  242.  
  243. <par_string_item> is
  244.                      "D"!"EBUG"!          #ps_set_debug
  245.                   or "F"!"ILE"!"T"!"YPE"! <blanks> "B"!"INARY"!
  246.                                           #ps_set_filetype_binary
  247.                   or "F"!"ILE"!"T"!"YPE"! <blanks> "MTS-B"!"INARY"!
  248.                                           #ps_set_filetype_mts_binary
  249.                   or "F"!"ILE"!"T"!"YPE"! <blanks> "T"!"EXT"!
  250.                                           #ps_set_filetype_text
  251.                   or "RM"                 #ps_remote_mts
  252.                   or "S"!"ERVER"!         #ps_set_mode_server
  253.                   or "U"!"SER"!           #ps_set_mode_user;
  254.  
  255. terminal <par_string_delimiter> is 1 of ", ";
  256.  
  257. ----------------------------------------------------------------------------
  258.  
  259. --  Semantics for breaking an mts filename into its component parts
  260.  
  261.   procedure filename_semantics for
  262.      ks_mts_simple_filename;
  263.  
  264.   goal <check_mts_filename> is <ccid> <mts_simple_filename1>
  265.                             or <mts_simple_filename1>;
  266.  
  267.   <mts_simple_filename1> is <mts_simple_filename> *End_Of_Line* #ks_mts_simple_f
  268.  
  269.   <ccid> is *ccid* ":";
  270.  
  271. -- do a simple parse on filename. Use semantics to check the validity of
  272. -- the filename characters, viz. Fnametrt
  273.   terminal <mts_simple_filename> is 1 to 12 excluding ": ";
  274.  
  275.