Skip to content

Commit

Permalink
parser: permit input/output sections anywhere in task (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed May 12, 2019
1 parent 52b9954 commit ab96c3a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
6 changes: 4 additions & 2 deletions WDL/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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* "}"
Expand Down
33 changes: 33 additions & 0 deletions tests/test_1doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ab96c3a

Please sign in to comment.