- function
- | Ast.Goal (name, [], _, _, _) ->
- if !initial_targets = [] then
- initial_targets := Ast.ECall (name, []) :: !initial_targets
- | Ast.Goal (name, _, _, _, _) ->
- if !initial_targets = [] then
- failwithf "%s: first target ā%sā has parameters and so cannot be used as the default target"
- filename name
- | _ -> ()
- ) file;
-
- let initial_targets = List.rev !initial_targets in
- ignore initial_targets
+ fun arg ->
+ if Str.string_match var_regexp arg 0 then (
+ (* assignment *)
+ let name = Str.matched_group 1 arg in
+ let expr = Parse.parse_cli_expr (Str.matched_group 2 arg) in
+ env := Ast.StringMap.add name expr !env
+ )
+ else (
+ (* target *)
+ let expr = Parse.parse_cli_expr arg in
+ targets := expr :: !targets
+ )
+ ) args;
+ let targets = List.rev !targets and env = !env in
+
+ (* If no target was set on the command line, use "all ()". *)
+ let targets =
+ if targets <> [] then targets
+ else [Ast.ECall ("all", [])] in
+
+ (*Ast.print_env stdout env;*)
+
+ (* Evaluate the target expressions in turn. *)
+ Eval.evaluate env targets