summaryrefslogtreecommitdiff
path: root/sievelib/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'sievelib/parser.py')
-rw-r--r--sievelib/parser.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/sievelib/parser.py b/sievelib/parser.py
index fefa3e0..b8b4758 100644
--- a/sievelib/parser.py
+++ b/sievelib/parser.py
@@ -307,16 +307,29 @@ class Parser(object):
if ttype != "identifier":
return False
+
command = get_command_instance(tvalue, self.__curcommand)
+
if command.get_type() == "test":
raise ParseError("%s may not appear as a first command" % command.name)
+
if command.get_type() == "control" and command.accept_children \
and command.has_arguments():
self.__set_expected("identifier")
+
if self.__curcommand is not None:
- if not self.__curcommand.addchild(command):
- raise ParseError("%s unexpected after a %s" % \
+ this_is_parent = self.__curcommand.addchild(command)
+
+ if not this_is_parent:
+ next_parent = self.__curcommand.parent.addchild(command)
+
+ if not next_parent:
+ raise ParseError("%s unexpected after a %s" % \
(tvalue, self.__curcommand.name))
+
+ else:
+ print "self.__curcommand == None"
+
self.__curcommand = command
self.__cstate = self.__arguments