[Python-checkins] r52920 - sandbox/trunk/2to3/pytree.py sandbox/trunk/2to3/tests.py
guido.van.rossum
python-checkins at python.org
Tue Dec 5 19:11:33 CET 2006
Author: guido.van.rossum
Date: Tue Dec 5 19:11:33 2006
New Revision: 52920
Modified:
sandbox/trunk/2to3/pytree.py
sandbox/trunk/2to3/tests.py
Log:
Minor tweaks to a docstring and a test.
Modified: sandbox/trunk/2to3/pytree.py
==============================================================================
--- sandbox/trunk/2to3/pytree.py (original)
+++ sandbox/trunk/2to3/pytree.py Tue Dec 5 19:11:33 2006
@@ -399,7 +399,16 @@
class WildcardPattern(BasePattern):
- """A wildcard pattern can match zero or more nodes."""
+ """A wildcard pattern can match zero or more nodes.
+
+ This has all the flexibility needed to implement patterns like:
+
+ .* .+ .? .{m,n}
+ (a b c | d e | f)
+ (...)* (...)+ (...)? (...){m,n}
+
+ except it always uses non-greedy matching.
+ """
def __init__(self, content=None, min=0, max=sys.maxint, name=None):
"""Initializer.
Modified: sandbox/trunk/2to3/tests.py
==============================================================================
--- sandbox/trunk/2to3/tests.py (original)
+++ sandbox/trunk/2to3/tests.py Tue Dec 5 19:11:33 2006
@@ -207,7 +207,7 @@
min=1, max=4, name="pw")
self.assertEqual([x[0] for x in pw.generate_matches(leaves)], [3, 5, 2, 4, 6])
pr = pytree.NodePattern(type=1000, content=[pw], name="pr")
- matches = list(pr.generate_matches([root]))
+ matches = list(pytree.generate_matches([pr], [root]))
self.assertEqual(len(matches), 1)
c, r = matches[0]
self.assertEqual(c, 1)
More information about the Python-checkins
mailing list