@Override protected EBNF clone() { /* * protected Map<NonTerminal, List<? extends EBNFBranch>> nonTerminals; * protected NonTerminal startSymbol; */ Map<NonTerminal, List<? extends EBNFBranch>> m = new HashMap<NonTerminal, List<? extends EBNFBranch>>(); Iterator<NonTerminal> nts = nonTerminals.keySet().iterator(); while (nts.hasNext()) { NonTerminal nt = nts.next().clone(); // travel through all registered non terminals List<EBNFBranch> l = new ArrayList<EBNFBranch>(); Iterator<? extends EBNFBranch> j = nonTerminals.get(nt).iterator(); while (j.hasNext()) { l.add(j.next().clone()); } m.put(nt, l); } return new EBNF(startSymbol.clone(), m); }
public String getNonTerminalDef(NonTerminal nt) { if (nonTerminals.containsKey(nt)) { String s = nt.toString() + " ::= "; List<? extends EBNFBranch> branches = nonTerminals.get(nt); for (int i = 0; i < branches.size(); i++) { s += branches.get(i); if (i != branches.size() - 1) { s += " | "; } } return s; } return null; }