From ab96c3a475b04779c314a30125780c48aad86a9d Mon Sep 17 00:00:00 2001 From: Mike Lin Date: Sat, 11 May 2019 17:57:11 -0700 Subject: [PATCH] parser: permit input/output sections anywhere in task (#126) --- WDL/_parser.py | 6 ++++-- tests/test_1doc.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/WDL/_parser.py b/WDL/_parser.py index 6df7bdb1..c22f646d 100644 --- a/WDL/_parser.py +++ b/WDL/_parser.py @@ -60,12 +60,14 @@ // WDL tasks input_decls: "input" "{" any_decl* "}" +output_decls: "output" "{" bound_decl* "}" ?task_sections1: input_decls + | output_decls | meta_section | runtime_section | any_decl+ -> noninput_decls -output_decls: "output" "{" bound_decl* "}" -?task_sections2: output_decls +?task_sections2: input_decls + | output_decls | meta_section | runtime_section task: "task" CNAME "{" task_sections1* command task_sections2* "}" diff --git a/tests/test_1doc.py b/tests/test_1doc.py index b1aa6137..90872370 100644 --- a/tests/test_1doc.py +++ b/tests/test_1doc.py @@ -232,6 +232,39 @@ def test_placeholders(self): self.assertEqual(task.command.parts[1].eval(WDL.Env.bind([], [], 'b', WDL.Value.Boolean(False))).value, 'false') self.assertEqual(task.command.parts[1].eval(WDL.Env.bind([], [], 'b', WDL.Value.Null())).value, 'foo') + task = WDL.parse_tasks(""" + task wc { + input { + Boolean? b + } + output { + String ans = stdout() + } + command { + echo "${default='foo' b}" + } + } + """)[0] + task.typecheck() + + with self.assertRaises(WDL.Error.MultipleDefinitions): + WDL.parse_tasks(""" + task wc { + input { + Boolean? b + } + output { + String ans = stdout() + } + command { + echo "${default='foo' b}" + } + output { + String ans2 = stdout() + } + } + """)[0] + def test_meta(self): task = WDL.parse_tasks(""" task wc {