summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sievelib/parser.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/sievelib/parser.py b/sievelib/parser.py
index 4379654..95cee47 100644
--- a/sievelib/parser.py
+++ b/sievelib/parser.py
@@ -318,14 +318,13 @@ class Parser(object):
self.__set_expected("identifier")
if self.__curcommand is not None:
- this_is_parent = self.__curcommand.addchild(command)
-
- if not this_is_parent:
- next_parent = self.__curcommand.parent.addchild(command)
-
- if not next_parent:
+ cur_parent = self.__curcommand
+ while not cur_parent.addchild(command):
+ if hasattr(cur_parent, 'parent'):
+ cur_parent = cur_parent.parent
+ else:
raise ParseError("%s unexpected after a %s" % \
- (tvalue, self.__curcommand.name))
+ (tvalue, self.__curcommand.name))
self.__curcommand = command
self.__cstate = self.__arguments