[pypy-svn] r8636 - pypy/dist/pypy/appspace
sanxiyn at codespeak.net
sanxiyn at codespeak.net
Thu Jan 27 14:16:28 CET 2005
Author: sanxiyn
Date: Thu Jan 27 14:16:28 2005
New Revision: 8636
Added:
pypy/dist/pypy/appspace/dumbre.py
pypy/dist/pypy/appspace/plexre.py
Modified:
pypy/dist/pypy/appspace/re.py
Log:
plexre, Plex-based regex implementation.
"gloriously dying" implementation moved to dumbre.
Now, you can edit re.py to enable plexre. And it let
pickle import and run, unmodified!
Added: pypy/dist/pypy/appspace/dumbre.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/appspace/dumbre.py Thu Jan 27 14:16:28 2005
@@ -0,0 +1,5 @@
+class Pattern:
+ def __init__(self, pattern, flags):
+ print 'regex', pattern
+ print 'killed'
+ raise SystemExit
Added: pypy/dist/pypy/appspace/plexre.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/appspace/plexre.py Thu Jan 27 14:16:28 2005
@@ -0,0 +1,15 @@
+from StringIO import StringIO
+from Pyrex.Plex import Scanner, Lexicon, Traditional, Errors
+class Pattern:
+ def __init__(self, pattern, flags):
+ compiled = Traditional.re(pattern)
+ lexicon = Lexicon([(compiled, None)])
+ self.lexicon = lexicon
+ def match(self, string):
+ stream = StringIO(string)
+ scanner = Scanner(self.lexicon, stream)
+ try:
+ scanner.read()
+ return 1
+ except Errors.UnrecognizedInput:
+ return 0
Modified: pypy/dist/pypy/appspace/re.py
==============================================================================
--- pypy/dist/pypy/appspace/re.py (original)
+++ pypy/dist/pypy/appspace/re.py Thu Jan 27 14:16:28 2005
@@ -1,3 +1,7 @@
+from dumbre import Pattern
+# from plexre import Pattern
+
+
# From CPython
def escape(pattern):
"Escape all non-alphanumeric characters in pattern."
@@ -11,11 +15,6 @@
s[i] = "\\" + c
return ''.join(s)
-class Pattern:
- def __init__(self, pattern, flags):
- print 'regex', pattern
- print 'killed'
- raise SystemExit
_cache = {}
More information about the Pypy-commit
mailing list