summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-12-01 21:20:02 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-12-01 21:20:02 (GMT)
commit0e782b7a9082b7977fd908de00e64f4958acea96 (patch)
tree6b5305b1e1882d28eecb4c9ce6b8fe4e08f7d302
parentbacf53ecdb895c76ed1440e068203b2d0f1c3240 (diff)
downloadpython-sievelib-0e782b7a9082b7977fd908de00e64f4958acea96.tar.gz
Correct the parser to allow a single line if (control) header (test) { (action-list) } by superseeding the parent to the parent of __curcommand
-rw-r--r--sievelib/commands.py8
-rw-r--r--sievelib/parser.py17
2 files changed, 20 insertions, 5 deletions
diff --git a/sievelib/commands.py b/sievelib/commands.py
index 95a424f..7e82f6f 100644
--- a/sievelib/commands.py
+++ b/sievelib/commands.py
@@ -468,9 +468,11 @@ class IfCommand(ControlCommand):
accept_children = True
args_definition = [
- {"name": "test",
- "type": [ "test" ],
- "required": True}
+ {
+ "name": "test",
+ "type": [ "test" ],
+ "required": True
+ }
]
def get_expected_first(self):
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