home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / JRCPP.ZIP / REFGRAM.Y < prev    next >
Text File  |  1990-03-27  |  9KB  |  321 lines

  1. %{
  2.  
  3. /* REFERENCE GRAMMAR FOR JRCPP (3/20/90)
  4.  
  5.  
  6.  
  7.     Copyright (C) 1990 James Roskind, All rights reserved. Permission 
  8.     is  granted  to copy and distribute this file as part any machine 
  9.     readable archive containing the entire, unmodified, JRCPP  PUBLIC 
  10.     DISTRIBUTION PACKAGE (henceforth call the "Package").  The set of 
  11.     files that form the Package are described in the README file that 
  12.     is  a  part  of the Package.  Permission is granted to individual 
  13.     users of the Package to copy individual portions of  the  Package 
  14.     (i.e.,  component  files) in any form (e.g.: printed, electronic, 
  15.     electro-optical, etc.) desired  for  the  purpose  of  supporting 
  16.     users   of  the  Package  (i.e.,  providing  online,  or  onshelf 
  17.     documentation access; executing the  binary  JRCPP  code,  etc.).  
  18.     Permission  is  not  granted  to  distribute copies of individual 
  19.     portions of the Package, unless a machine readable version of the 
  20.     complete  Package  is also made available with such distribution. 
  21.     Abstracting with credit is permitted.   There  is  no  charge  or 
  22.     royalty  fee  required  for  copies  made in compliance with this 
  23.     notice.  To otherwise copy  elements  of  this  package  requires 
  24.     prior permission in writing from James Roskind.
  25.  
  26.     James Roskind
  27.     516 Latania Palm Drive
  28.     Indialantic FL 32903
  29.  
  30.     End of copyright notice
  31.  
  32.  
  33. What  the  above  copyright  means  is  that  you are free to use and 
  34. distribute (or even sell) the entire set of files  in  this  Package, 
  35. but  you  can't split them up, and distribute them as separate files.  
  36. The notice also says that you  cannot  modify  the  copies  that  you 
  37. distribute, and this ESPECIALLY includes NOT REMOVING the any part of 
  38. the copyright notice in any file.  JRCPP  currently  implements  a  C 
  39. Preprocessor,  but  the  users  of  this Package do NOT surrender any 
  40. right of ownership or copyright to any source text that is  processed 
  41. by JRCPP, either before or after processing.  Similarly, there are no 
  42. royalty or fee requirements for using the post-preprocessed output of 
  43. JRCPP.  
  44.  
  45. This  Package is expected to be distributed by shareware and freeware 
  46. channels (including BBS sites), but the fees paid for  "distribution" 
  47. costs  are  strictly  exchanged  between  the  distributor,  and  the 
  48. recipient, and James Roskind makes no express or  implied  warranties 
  49. about  the  quality  or integrity of such indirectly acquired copies.  
  50. Distributors  and  users  may  obtain   the   Package   (the   Public 
  51. distribution form) directly from the author by following the ordering 
  52. procedures in the REGISTRATION file.
  53.  
  54.  
  55. DISCLAIMER:
  56.  
  57. JAMES ROSKIND PROVIDES THIS FILE "AS  IS"  WITHOUT  WARRANTY  OF  ANY 
  58. KIND,  EITHER  EXPRESS  OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE 
  59. IMPLIED WARRANTIES OF MERCHANTABILITY OR  FITNESS  FOR  A  PARTICULAR 
  60. PURPOSE.   THE  ENTIRE  RISK AS TO THE QUALITY AND PERFORMANCE OF THE 
  61. PROGRAM AND DOCUMENTATION IS WITH YOU.   Some  states  do  not  allow 
  62. disclaimer  of express or implied warranties in certain transactions, 
  63. therefore, this statement may not apply to you.
  64.  
  65.  
  66. UNIX is a registered trademark of AT&T Bell Laboratories.
  67.  
  68.  
  69. _____________________________________________________________________
  70.  
  71.  
  72.  
  73.  
  74. The file may be processed by YACC.  The only  conflict  left  in  the 
  75. grammar  involves  the  distinction between function like macros, and 
  76. manifest macros that begin with a left  parenthesis.   Removing  this 
  77. last conflict would unnecessarily complicate the grammar.  */
  78.  
  79.  
  80.  
  81.  
  82. /*******************************************************************/
  83.  
  84. /*  The  following defines the terminals of the grammar. Terminal are 
  85. identified lexically  as  groups  of  characters  (either  tokens  or 
  86. whitespace). */
  87.  
  88. %token  IDENTIFIER   OTHER_TOKENS
  89. %token  HORIZONTAL_WHITE      VERTICAL_WHITE
  90. %token  '#'     '('     ')'     ','      '\n'
  91. %token  DEFINE       POUND_POUND   UNDEF
  92. %token  IF           IFDEF        IFNDEF
  93. %token  ELIF         ELSE         ENDIF
  94. %token  DEFINEDoperator
  95. %token  INCLUDE      LINE         ERROR        PRAGMA
  96.  
  97.  
  98. /*************************************************************************/
  99.  
  100.  
  101.  
  102. %%
  103.  
  104. preprocessing_file:
  105.     /* empty file */
  106.     | preprocessed_group
  107.         ;
  108.  
  109. preprocessed_group:
  110.     directive_group
  111.         | non_directive_line 
  112.         | preprocessed_group directive_group
  113.         | preprocessed_group non_directive_line 
  114.         ;
  115.  
  116. directive_group:
  117.     directive_start if_section
  118.     | directive_start opt_white_space define_directive
  119.     | directive_start opt_white_space INCLUDE line
  120.     | directive_start opt_white_space LINE line
  121.     | directive_start opt_white_space ERROR line
  122.     | directive_start opt_white_space PRAGMA line
  123.     | directive_start new_line  /* null directive */
  124.     ;
  125.         
  126. directive_start:
  127.     opt_white_space '#'
  128.         ;
  129.  
  130.  
  131. non_directive_line:
  132.     new_line
  133.     | opt_white_space non_pound_non_white_non_new_line line
  134.         ;
  135.  
  136. line:
  137.     new_line
  138.     | line_interior new_line
  139.         ;
  140.  
  141. line_interior:
  142.     opt_white_space non_white_non_new_line
  143.     | line_interior opt_white_space non_white_non_new_line
  144.         ;
  145.  
  146.  
  147. new_line:
  148.     opt_white_space '\n'
  149.         ;
  150.  
  151. opt_white_space:
  152.     /* nothing */
  153.     | white_space
  154.         ;
  155.         
  156.  
  157. white_space:
  158.         a_white_space
  159.     | white_space a_white_space
  160.         ;
  161.         
  162.         
  163. a_white_space:
  164.     HORIZONTAL_WHITE
  165.     | VERTICAL_WHITE
  166.         ;
  167.  
  168. non_white_non_new_line:
  169.     '#'
  170.         | non_pound_non_white_non_new_line 
  171.         ;
  172.         
  173. non_pound_non_white_non_new_line 
  174.     non_pound_non_white_non_new_line_non_opdefined
  175.     | DEFINEDoperator
  176.         ;
  177.         
  178. non_pound_non_white_non_new_line_non_opdefined:
  179.     IDENTIFIER
  180.     | OTHER_TOKENS
  181.         | '('     
  182.         | ')'     
  183.         | ','     
  184.     | DEFINE
  185.     | UNDEF
  186.     | IF
  187.     | IFDEF
  188.     | IFNDEF
  189.     | ELIF
  190.     | ELSE
  191.     | ENDIF
  192.     | INCLUDE
  193.     | LINE
  194.     | ERROR
  195.     | PRAGMA
  196.     | POUND_POUND
  197.         ;                
  198.         
  199. if_section:
  200.     if_line elif_groups else_group endif_group
  201.     | if_line             else_group endif_group
  202.     | if_line elif_groups            endif_group
  203.     | if_line                        endif_group
  204.     ;
  205.  
  206. if_line:
  207.     opt_white_space IF opdefined_processed_line
  208.     | opt_white_space IFDEF opt_white_space any_identifier new_line
  209.     | opt_white_space IFNDEF opt_white_space any_identifier new_line
  210.         ;
  211.  
  212. elif_groups:
  213.     elif_group
  214.         | elif_groups elif_group
  215.         ;
  216.  
  217. elif_group:
  218.     elif_line
  219.         | preprocessed_group elif_line
  220.         ;
  221.  
  222. elif_line:
  223.     directive_start opt_white_space ELIF opdefined_processed_line
  224.     ;
  225.  
  226.  
  227. else_group:
  228.     else_line
  229.         | preprocessed_group else_line
  230.         ;
  231.  
  232. else_line:
  233.     directive_start opt_white_space ELSE new_line
  234.     ;
  235.  
  236. endif_group:
  237.     endif_line
  238.     | preprocessed_group endif_line
  239.         ;
  240.         
  241. endif_line:
  242.     directive_start opt_white_space ENDIF new_line
  243.         ;
  244.  
  245. opdefined_processed_line:
  246.     opdefined_processed_tokens new_line
  247.         ;
  248.         
  249. opdefined_processed_tokens:
  250.     opdefined_processed_token
  251.     | opdefined_processed_tokens opdefined_processed_token
  252.     ;
  253.  
  254. opdefined_processed_token:
  255.     opt_white_space   DEFINEDoperator opt_white_space
  256.                     any_identifier
  257.     | opt_white_space DEFINEDoperator opt_white_space
  258.         '(' opt_white_space any_identifier opt_white_space ')'
  259.     | opt_white_space non_opdefined_non_white_non_new_line
  260.     ;
  261.  
  262. non_opdefined_non_white_non_new_line:
  263.         non_pound_non_white_non_new_line_non_opdefined
  264.         | '#'
  265.         ;
  266.         
  267.  
  268.  
  269.  
  270. define_directive:
  271.     DEFINE opt_white_space any_identifier  '(' opt_dummy_arg_list ')'
  272.         replacement_line
  273.     | DEFINE opt_white_space any_identifier replacement_line
  274.     | UNDEF opt_white_space any_identifier new_line
  275.         ;
  276.  
  277. opt_dummy_arg_list:
  278.     opt_white_space
  279.         | dummy_arg_list 
  280.         ;
  281.  
  282. dummy_arg_list:
  283.     dummy_arg
  284.         | dummy_arg_list  ',' dummy_arg
  285.         ;
  286.  
  287. dummy_arg:
  288.     opt_white_space any_identifier opt_white_space
  289.         ;
  290.  
  291. replacement_line:
  292.         new_line
  293.     | opt_white_space replacement_list new_line
  294.     ;
  295.  
  296. replacement_list:
  297.     non_white_non_new_line
  298.     | replacement_list opt_white_space non_white_non_new_line
  299.         ;
  300.         
  301. any_identifier:
  302.     DEFINEDoperator
  303.     | IDENTIFIER
  304.     | DEFINE
  305.     | UNDEF
  306.     | IF
  307.     | IFDEF
  308.     | IFNDEF
  309.     | ELIF
  310.     | ELSE
  311.     | ENDIF
  312.     | INCLUDE
  313.     | LINE
  314.     | ERROR
  315.     | PRAGMA
  316.     ;
  317.  
  318.  
  319.  
  320. %%
  321.