* @return Return a list of violations, if this
* object isn't valid.
*/
public Violations validate()
{
Violations violations = new Violations();
if (startsymbol==null)
violations.addViolation("Start symbol is not defined", location);
else if ( !contains(startsymbol))
violations.addViolation("Start symbol \""+startsymbol+"\""+
"is not defined through a production", location);
if (getProductionCount()<=0)
violations.addViolation("No productions are defined", location);
for (Enumeration e = productions.elements(); e.hasMoreElements(); )
violations.addViolations(((Production) e.nextElement()).validate());
SymbolSet ntsymbols = getSymbols().getNonterminals();
for (int i = 0; i<ntsymbols.getSymbolCount(); i++)
if ( !contains(ntsymbols.getSymbol(i)))
violations.addViolation("Nonterminal symbol \""+
ntsymbols.getSymbol(i)+"\""+
"is not defined through a production", location);
return violations;
}