summaryrefslogtreecommitdiff
path: root/Lib/re.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-11 21:10:17 +0000
committerGuido van Rossum <guido@python.org>1997-07-11 21:10:17 +0000
commit5d6de256d5bd27263cbe1477acfbc8776bee51d4 (patch)
tree8d04bd7bb051440f7f48cdb9a2f41e022fb3dd70 /Lib/re.py
parent8a9a4a2336c6b2254b9eeaf1d282d2a69bb8de53 (diff)
downloadcpython-git-5d6de256d5bd27263cbe1477acfbc8776bee51d4.tar.gz
New from Jeffrey; small nits.
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/re.py b/Lib/re.py
index e2732b8460..2d24da5855 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -350,6 +350,7 @@ class SyntaxSpec(Instruction):
self.syntax = syntax
Instruction.__init__(self, chr(20), 2)
def assemble(self, postition, labels):
+ # XXX
return self.opcode + chr(self.syntax)
class NotSyntaxSpec(Instruction):
@@ -358,6 +359,7 @@ class NotSyntaxSpec(Instruction):
self.syntax = syntax
Instruction.__init__(self, chr(21), 2)
def assemble(self, postition, labels):
+ # XXX
return self.opcode + chr(self.syntax)
class Label(Instruction):
@@ -373,11 +375,15 @@ class OpenParen(Instruction):
def __init__(self, register):
self.register = register
Instruction.__init__(self, '', 0)
+ def assemble(self, position, labels):
+ raise error, 'unmatched open parenthesis'
class Alternation(Instruction):
name = '|'
def __init__(self):
Instruction.__init__(self, '', 0)
+ def assemble(self, position, labels):
+ raise error, 'an alternation was not taken care of'
#
#
@@ -924,7 +930,9 @@ def compile(pattern, flags=0):
elif char == '*':
# Kleene closure
if len(stack) == 0:
- raise error, 'the Kleene closure needs something to repeat'
+ raise error, '* needs something to repeat'
+ if (stack[-1][0].name == '(') or (stack[-1][0].name == '|'):
+ raise error, '* needs something to repeat'
registers = registers_used(stack[-1])
if (index < len(pattern)) and (pattern[index] == '?'):
# non-greedy matching
@@ -948,7 +956,9 @@ def compile(pattern, flags=0):
elif char == '+':
# positive closure
if len(stack) == 0:
- raise error, 'the positive closure needs something to repeat'
+ raise error, '+ needs something to repeat'
+ if (stack[-1][0].name == '(') or (stack[-1][0].name == '|'):
+ raise error, '+ needs something to repeat'
registers = registers_used(stack[-1])
if (index < len(pattern)) and (pattern[index] == '?'):
# non-greedy