-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.py
69 lines (47 loc) · 1.34 KB
/
presentation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# Pure Python Regular Expression Matching
#
# Regular Expression Automatons in Python
#
# Karl Ramm
#
# github.com/kcr/reap
#
# 2015-04-11 (not given)
#!/usr/bin/python3
import re
class foo:
"""Kinda sort not really string-y object"""
def __init__(self, val):
self.val = val
def __iter__(self):
for x in self.val:
yield x
print(re.compile('foo').match(foo('foo')))
#!/usr/bin/python3
class bar(foo):
"""slightly stringier but not object"""
def __getitem__(self, n):
return x[n]
print(re.compile('bar').match(foo('bar')))
# Really this might be, saaay, a buffer-gap backed writable string
#!/usr/bin/python3
import reap
print(reap.compile('foo').match(foo('foo')))
#!/usr/bin/python3
print(reap.compile('A?' * 33 + 'A' * 33).match('A' * 33))
#!/usr/bin/python3
print('This may take a while')
print(re.compile('A?' * 33 + 'A' * 33).match('A' * 33))
#
#
# 871 lines (right now)
# Only supports the most of subset of regular expresions that I use
# (so far)
# (I got distracted from the thing that I needed it for)
# I hope to pass eventually the tests for the re module
# Could be faster (DFAs, etc.)
# should have better error reporting (parsley instead of rply?)
# "what is a regular expression anyway"
# could fall back to a recursive matcher for backreferences
# github.com/kcr/reap