(* Handle a top level statement. *)
let rec call_stmt name (_loc, stmt, sh) =
- let name = if name <> "" then name else unique_job_name () in
- let name = <:expr< $str:name$ >> in
+ let name =
+ match name with
+ | None -> let name = unique_job_name () in <:expr< $str:name$ >>
+ | Some name -> name in
match stmt with
| `When e -> when_stmt _loc name e sh
| `Every p -> every_stmt _loc name p sh
(* "str_item" is a top level statement in an OCaml program. *)
str_item: LEVEL "top" [
- [ s = statement -> call_stmt "" s ]
- | [ "job"; name = STRING; s = statement -> call_stmt name s ]
+ [ s = statement -> call_stmt None s ]
+ | [ "job"; name = expr; s = statement -> call_stmt (Some name) s ]
];
END