@@ -350,6 +350,7 @@ def __init__(self, syntax):
350350 self .syntax = syntax
351351 Instruction .__init__ (self , chr (20 ), 2 )
352352 def assemble (self , postition , labels ):
353+ # XXX
353354 return self .opcode + chr (self .syntax )
354355
355356class NotSyntaxSpec (Instruction ):
@@ -358,6 +359,7 @@ def __init__(self, syntax):
358359 self .syntax = syntax
359360 Instruction .__init__ (self , chr (21 ), 2 )
360361 def assemble (self , postition , labels ):
362+ # XXX
361363 return self .opcode + chr (self .syntax )
362364
363365class Label (Instruction ):
@@ -373,11 +375,15 @@ class OpenParen(Instruction):
373375 def __init__ (self , register ):
374376 self .register = register
375377 Instruction .__init__ (self , '' , 0 )
378+ def assemble (self , position , labels ):
379+ raise error , 'unmatched open parenthesis'
376380
377381class Alternation (Instruction ):
378382 name = '|'
379383 def __init__ (self ):
380384 Instruction .__init__ (self , '' , 0 )
385+ def assemble (self , position , labels ):
386+ raise error , 'an alternation was not taken care of'
381387
382388#
383389#
@@ -924,7 +930,9 @@ def compile(pattern, flags=0):
924930 elif char == '*' :
925931 # Kleene closure
926932 if len (stack ) == 0 :
927- raise error , 'the Kleene closure needs something to repeat'
933+ raise error , '* needs something to repeat'
934+ if (stack [- 1 ][0 ].name == '(' ) or (stack [- 1 ][0 ].name == '|' ):
935+ raise error , '* needs something to repeat'
928936 registers = registers_used (stack [- 1 ])
929937 if (index < len (pattern )) and (pattern [index ] == '?' ):
930938 # non-greedy matching
@@ -948,7 +956,9 @@ def compile(pattern, flags=0):
948956 elif char == '+' :
949957 # positive closure
950958 if len (stack ) == 0 :
951- raise error , 'the positive closure needs something to repeat'
959+ raise error , '+ needs something to repeat'
960+ if (stack [- 1 ][0 ].name == '(' ) or (stack [- 1 ][0 ].name == '|' ):
961+ raise error , '+ needs something to repeat'
952962 registers = registers_used (stack [- 1 ])
953963 if (index < len (pattern )) and (pattern [index ] == '?' ):
954964 # non-greedy
0 commit comments