code: protected void getSAXRules() {
  
      arrRuleRecords.clear();
  
      Vector<SAXRule> rules = new Vector<SAXRule>(numRules.intValue());
      rules.addElement(this);
  
      SAXRule currentRule;
  
      int processedRules = 0;
  
      StringBuilder sbCurrentRule = new StringBuilder();
  
      while (processedRules < rules.size()) {
  
        currentRule = rules.elementAt(processedRules);
  
        for (SAXSymbol sym = currentRule.first(); (!sym.isGuard()); sym = sym.n) {
          if (sym.isNonTerminal()) {
            SAXRule referedTo = ((SAXNonTerminal) sym).r;
            if ((rules.size() > referedTo.index) && (rules.elementAt(referedTo.index) == referedTo)) {
              index = referedTo.index;
            }
            else {
              index = rules.size();
              referedTo.index = index;
              rules.addElement(referedTo);
            }
            sbCurrentRule.append('R');
            sbCurrentRule.append(index);
          }
          else {
            sbCurrentRule.append(sym.value);
          }
          sbCurrentRule.append(' ');
        }
  
        GrammarRuleRecord ruleConteiner = new GrammarRuleRecord();
  
        ruleConteiner.setRuleNumber(processedRules);
        ruleConteiner.setRuleString(sbCurrentRule.toString());
  
        ruleConteiner.setRuleLevel(currentRule.getLevel());
  
        ruleConteiner.setRuleUseFrequency(currentRule.count);
        ruleConteiner.setOccurrences(currentRule.getIndexes());
  
        arrRuleRecords.add(ruleConteiner);
  
        sbCurrentRule = new StringBuilder();
        processedRules++;
      }
  
    }
docs: Add-on to the original code by manfred and seninp. This one similar to the original getRules()
  but populates and returns the array list of SAXRuleRecords.