/** * Returns the minimum number of elements needed to satisfy this alternative. The value returned * is the sum of all the elements minimum count. * * @return the minimum number of elements */ public int getMinElementCount() { ProductionPatternElement elem; int min = 0; for (int i = 0; i < elements.size(); i++) { elem = (ProductionPatternElement) elements.get(i); min += elem.getMinCount(); } return min; }
/** * Checks if this alternative is recursive on the right-hand side. This method checks all the * possible right side elements and returns true if the pattern itself is among them. * * @return true if the alternative is right side recursive, or false otherwise */ public boolean isRightRecursive() { ProductionPatternElement elem; for (int i = elements.size() - 1; i >= 0; i--) { elem = (ProductionPatternElement) elements.get(i); if (elem.getId() == pattern.getId()) { return true; } else if (elem.getMinCount() > 0) { break; } } return false; }