title: nonterminals useless in grammar [-Wother]
body: <p>When i compile my program with yacc it gives me error.
  I'am not able to understand if i'hv used indirect recursion or something else.
  I'am not very familier with yacc.
  My code's rules section is:</p>
  
  <pre><code> stmtfor    :   exprfor OPENB CLOSEB    {   printf("\nValid For statement!\n"); }           |
          exprfor OPENB stmtfor CLOSEB    {   printf("\nValid For statement!\n"); }   |
          exprfor     {   printf("\nValid For statement!\n"); }
          ;
  
   exprfor    :   FOR '(' ID '=' DIGIT DELIMITER ID COND DIGIT DELIMITER ID INC ')'   |
          FOR '(' ID '=' ID DELIMITER ID COND DIGIT DELIMITER ID INC ')'      |
          FOR '(' ID '=' DIGIT DELIMITER ID COND ID DELIMITER ID INC ')'      |
          FOR '(' ID '=' ID DELIMITER ID COND ID DELIMITER ID INC ')'         |
          FOR '(' DELIMITER DELIMITER ')'                                     |
          FOR '(' DELIMITER ID COND DELIMITER INC')'                          |
          FOR '(' DELIMITER DELIMITER INC ')'
          ;
  
  stmtif  :   exprif OPENB CLOSEB ELSE OPENB CLOSEB   {   printf("\nValid if statement!\n");  }   |
          exprif OPENB CLOSEB {   printf("\nValid if statement!\n");  }   |
          exprif OPENB stmtif CLOSEB {    printf("\nValid if statement!\n");  }   |
          exprif OPENB stmtif CLOSEB ELSE OPENB stmtif CLOSEB {   printf("\nValid if statement!\n");  }
          ;
  
  exprif  :   IF '(' ID COND DIGIT ')'    |
          IF '(' ID COND ID ')'       |
          IF '(' DIGIT COND DIGIT ')' |
          IF '(' ID ')'               |
          IF '(' DIGIT COND ID ')'
          ;
  
   stmtwh :   exprwh OPENB CLOSEB     {   printf("\nValid while statement");  }       |
          exprwh OPENB stmtwh CLOSEB  {   printf("\nValid while statement");  }   |
          exprwh  {   printf("\nValid while statement");  }
          ;
  
  exprwh  :   WHILE '(' ID COND DIGIT ')' |
          WHILE '(' ID COND ID ')'    |
          WHILE '(' DIGIT COND DIGIT ')'  |
          WHILE '(' DIGIT COND ID ')' |
          WHILE '(' ID ')'            |
          WHILE '(' DIGIT ')'
          ;
  %%
  </code></pre>
  
  <p>Error which i got is:</p>
  
  <pre><code>    ond_rec.y: warning: 2 nonterminals useless in grammar [-Wother]
      cond_rec.y: warning: 9 rules useless in grammar [-Wother]
      cond_rec.y:21.1-6: warning: nonterminal useless in grammar: stmtwh       [-Wother]
      stmtwh  :   exprwh OPENB CLOSEB     {   printf("\nValid while            statement");   }       |
      ^^^^^^
      cond_rec.y:21.17-22: warning: nonterminal useless in grammar: exprwh     [-Wother]
      stmtwh  :   exprwh OPENB CLOSEB     {   printf("\nValid while       statement");    }       |
               ^^^^^^
      cond_rec.y:21.17-97: warning: rule useless in grammar [-Wother]
      stmtwh  :   exprwh OPENB CLOSEB     {   printf("\nValid while statement");  }       |
               ^^^^^^^^^^
      cond_rec.y:22.25-105: warning: rule useless in grammar [-Wother]
          exprwh OPENB stmtwh CLOSEB  {   printf("\nValid while statement");  }   |
                       ^^^
      cond_rec.y:23.25-81: warning: rule useless in grammar [-Wother]
          exprwh  {   printf("\nValid while statement");  }
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      cond_rec.y:26.17-43: warning: rule useless in grammar [-Wother]
      exprwh  :   WHILE '(' ID COND DIGIT ')' |
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      cond_rec.y:27.25-48: warning: rule useless in grammar [-Wother]
          WHILE '(' ID COND ID ')'    |
                       ^^^^^^^^^^^^^^^^^^^^^^^^
      cond_rec.y:28.25-54: warning: rule useless in grammar [-Wother]
          WHILE '(' DIGIT COND DIGIT ')'  |
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      cond_rec.y:29.25-51: warning: rule useless in grammar [-Wother]
          WHILE '(' DIGIT COND ID ')' |
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      cond_rec.y:30.25-40: warning: rule useless in grammar [-Wother]
          WHILE '(' ID ')'            |
                       ^^^^^^^^^^^^^^^^
      cond_rec.y:31.25-43: warning: rule useless in grammar [-Wother]
          WHILE '(' DIGIT ')'
                       ^^^^^^^^^^^^^^^^^^^
  </code></pre>
  
  <p>I've seen previous post regarding this topic but none of them seem to work for me n i'am not able to understand what is wrong in this.</p>