/** * Return the Xml representation of this property according to the definition of the * 'supported-query-grammer-set'. * * @return Xml representation * @see SearchConstants#QUERY_GRAMMER_SET * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document) * @param document */ @Override public Element toXml(Document document) { Element elem = getName().toXml(document); for (Grammer qGrammer : queryGrammers) { elem.appendChild(qGrammer.toXml(document)); } return elem; }
public void match(ArrayList<Token> rhs) { outer: for (Token i : rhs) { // System.out.println("i:" + i); if (i.getClass().getName().equals("compiler.Terminal")) { matchTerminal((Terminal) i); } else if (i.getClass().getName().equals("compiler.NonTerminal")) { NonTerminal iNonTerminal = (NonTerminal) i; ArrayList<Integer> lhses = getIndexOfRulesWithLeftHandSide(gr.rules, iNonTerminal); for (Integer j : lhses) { if (gr.getFirsts(gr.rules.get(j).getRightSide()) .contains(Terminal.getTerminalbyString(lookAhead))) { // System.out.println("using rule:" + // gr.rules.get(j).getRightSide()); match(gr.rules.get(j).getRightSide()); continue outer; } } /// no rule with input in first if (iNonTerminal.getFirsts().contains(Terminal.getTerminal("Epsilon"))) { if (iNonTerminal.getFollows().contains(Terminal.getTerminalbyString(lookAhead))) { ArrayList<Integer> indexOfRulesWithLeftHandSide = getIndexOfRulesWithLeftHandSide(gr.rules, iNonTerminal); for (Integer j : indexOfRulesWithLeftHandSide) { if (gr.getFirsts(gr.rules.get(j).getRightSide()) .contains(Terminal.getTerminal("Epsilon"))) { match(gr.rules.get(j).getRightSide()); continue outer; } } } } if (iNonTerminal.getFollows().contains(Terminal.getTerminalbyString(lookAhead))) { System.err.println("missing " + iNonTerminal.getDesc() + " ,insert it"); } else { System.err.println("misplaced " + lookAhead + " I'm Skipping it!"); lookAhead = getNextToken(); } } else if (i.getClass().getName().equals("compiler.Procedure")) { runProcedure(i.getName()); } } }