protected static NamespaceCacheElement[] enumerateAncestors(NamespaceCacheElement ncElem, bool includeSelf) { Generic.List <NamespaceCacheElement> ncAncestors = new Generic.List <NamespaceCacheElement>(); if (includeSelf) { ncAncestors.Insert(0, ncElem); } while (ncElem.Parent != null) { ncElem = ncElem.Parent; ncAncestors.Insert(0, ncElem); } return(ncAncestors.ToArray()); }
private void ResolveTokens(string s) { int index = -1; int startIndex = 0; Generic.List <string> tokenParts = new Generic.List <string>(); //index = s.IndexOfAny(separators, startIndex); while ((index = s.IndexOfAny(separators, startIndex)) > 0) { int offset = index - startIndex; if (offset > 0) { tokenParts.Add(s.Substring(startIndex, index - startIndex)); } tokenParts.Add(s.Substring(index, 1)); startIndex = index + 1; } tokenParts.Add(s.Substring(startIndex)); tokenParts.Add(string.Empty); // TODO: Simulate EOL tokens = tokenParts.ToArray(); }
internal static ComprehensionIterator[] RevertComprehensions(PythonList comprehensions) { Generic.List<ComprehensionIterator> comprehensionIterators = new Generic.List<ComprehensionIterator>(); foreach (comprehension comp in comprehensions) { ComprehensionFor cf = new ComprehensionFor(expr.Revert(comp.target), expr.Revert(comp.iter)); comprehensionIterators.Add(cf); foreach (expr ifs in comp.ifs) { comprehensionIterators.Add(new ComprehensionIf(expr.Revert(ifs))); } } return comprehensionIterators.ToArray(); }