/** Print out the grammar without actions */ public String toString() { StringBuffer buf = new StringBuffer(20000); Enumeration ids = rules.elements(); while (ids.hasMoreElements()) { RuleSymbol rs = (RuleSymbol) ids.nextElement(); if (!rs.id.equals("mnextToken")) { buf.append(rs.getBlock().toString()); buf.append("\n\n"); } } return buf.toString(); }
/** * Generate code for a named rule block * * @param s The RuleSymbol describing the rule to generate */ public void genRule(RuleSymbol s) { if (s == null || !s.isDefined()) return; // undefined rule println(""); if (s.comment != null) { _println(HTMLEncode(s.comment)); } if (s.access.length() != 0) { if (!s.access.equals("public")) { _print(s.access + " "); } } _print("<a name=\"" + s.getId() + "\">"); _print(s.getId()); _print("</a>"); // Get rule return type and arguments RuleBlock rblk = s.getBlock(); // RK: for HTML output not of much value... // Gen method return value(s) // if (rblk.returnAction != null) { // _print("["+rblk.returnAction+"]"); // } // Gen arguments // if (rblk.argAction != null) // { // _print(" returns [" + rblk.argAction+"]"); // } _println(""); tabs++; print(":\t"); // Dump any init-action // genBlockPreamble(rblk); // Dump the alternates of the rule genCommonBlock(rblk); _println(""); println(";"); tabs--; }