private static void parseBalanced(ASTNode node, SubNodeFactory snf, int lToken, int rToken) { if (node is ASTNodeAbstractExpr) { ASTNodeAbstractExpr absNode = (ASTNodeAbstractExpr)node; int i = 0; while (i < absNode.content.Count) { int type = absNode.getTokenType(i); if (type == rToken) { throw new XPathSyntaxException(); //unbalanced } else if (type == lToken) { int j = absNode.indexOfBalanced(i, rToken, lToken, rToken); if (j == -1) { throw new XPathSyntaxException(); //mismatched } absNode.condense(snf.newNode(absNode.extract(i + 1, j)), i, j + 1); } i++; } } for (IEnumerator e = node.getChildren().GetEnumerator(); e.MoveNext();) { parseBalanced((ASTNode)e.Current, snf, lToken, rToken); } }
private static void parseBalanced(ASTNode node, SubNodeFactory snf, int lToken, int rToken) { if (node is ASTNodeAbstractExpr) { ASTNodeAbstractExpr absNode = (ASTNodeAbstractExpr)node; int i = 0; while (i < absNode.content.Count) { int type = absNode.getTokenType(i); if (type == rToken) { throw new XPathSyntaxException("Unbalanced brackets or parentheses!"); //unbalanced } else if (type == lToken) { int j = absNode.indexOfBalanced(i, rToken, lToken, rToken); if (j == -1) { throw new XPathSyntaxException("mismatched brackets or parentheses!"); //mismatched } absNode.condense(snf.newNode(absNode.extract(i + 1, j)), i, j + 1); } i++; } } //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" for (System.Collections.IEnumerator e = node.Children.GetEnumerator(); e.MoveNext();) { //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" parseBalanced((ASTNode)e.Current, snf, lToken, rToken); } }