+ let env = Parse.parse_goalfile filename in
+
+ (* Now we've read the input, change directory. *)
+ Sys.chdir directory;
+
+ (* Parse the command line anon args. Each parameter has the
+ * form "name=<expr>" to assign a value to a variable, or
+ * "<expr>" to indicate a target to build.
+ *)
+ let targets = ref [] in
+ let env = ref env in
+ List.iter (
+ 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 (Ast.noloc, "all", [])] in
+
+ Ast.print_env stdout env;