public void updateVarsAndTerminals(){
  if (rules == null) {
    vars=new ArrayList<String>();
    terminals=new ArrayList<String>();
    return;
  }
  for (int i=0; i < rules.size(); i++) {
    Rule r=rules.get(i);
    updateVarsAndTerminals(r);
  }
}

public void updateVarsAndTerminals ( ) { if ( rules == null ) { vars = new ArrayList < String > ( ) ; terminals = new ArrayList < String > ( ) ; return ; } for ( int i = 0 ; i < rules . size ( ) ; i ++ ) { Rule r = rules . get ( i ) ; updateVarsAndTerminals ( r ) ; } }
whenever a new rule is added to the grammar , we want to update the list of variables and terminals with any new grammar symbols
