home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_06_07 / v6n7065b.txt < prev    next >
Text File  |  1989-09-28  |  2KB  |  59 lines

  1. /****************************  Listing 2  ****************************/
  2. /*******                                                       *******/
  3. /*******   Delete all of the current actions in the grammar    *******/
  4. /*******   rules section of yref2.y. All have the general      *******/
  5. /*******   form: { printf(......) }. Then add the actions      *******/
  6. /*******   as shown below (from { to }, inclusive). Note       *******/
  7. /*******   that there are no changes to the grammar rules,     *******/
  8. /*******   which are only repeated for setting the context.    *******/
  9. /*******                                                       *******/
  10. /*********************************************************************/
  11.  
  12. direct_declarator:
  13.            IDENTIFIER
  14.                 {  yn_decl = 1; root = addtree(root, $1); }
  15.          | '(' declarator ')'
  16.          | direct_declarator '[' ']'  %prec '*'
  17.          | direct_declarator '[' constant ']' %prec '*' /* Variant */
  18.          | direct_declarator '(' parameter_type_list ')' %prec '*'
  19.          | direct_declarator '(' ')' %prec '*'
  20.          | direct_declarator '(' identifier_list ')' %prec '*'
  21.          ;
  22.  
  23. identifier_list:
  24.            IDENTIFIER
  25.                 {  yn_decl = 0; root = addtree(root, $1); }
  26.          | identifier_list ',' IDENTIFIER
  27.                 {  yn_decl = 0; root = addtree(root, $3); }
  28.          ;
  29.  
  30. statement:
  31.            compound_statement
  32.          | expression ';'
  33.          | KEYWORD '(' expression ')' statement
  34.          | KEYWORD for_construct statement
  35.          | KEYWORD statement
  36.          | KEYWORD constant ':' statement
  37.          | KEYWORD ':' statement
  38.          | KEYWORD IDENTIFIER ';'
  39.                 {  yn_decl = 0; root = addtree(root, $2);  }
  40.          | IDENTIFIER ':' statement
  41.                 {  yn_decl = 0; root = addtree(root, $1);  }
  42.          | ';'
  43.          ;
  44.  
  45. primary_expression:
  46.            IDENTIFIER
  47.                 {  yn_decl = 0; root = addtree(root, $1); }
  48.          | constant
  49.          | STRING
  50.          | '(' expression ')'
  51.          | primary_expression '(' ')'
  52.          | primary_expression '(' expression ')'
  53.          | primary_expression '[' expression ']'
  54.          | primary_expression '.' IDENTIFIER 
  55.                 {  yn_decl = 0; root = addtree(root, $3); }
  56.          ;
  57.  
  58.  
  59.