From f48985d70ac34237284e69a5016c94d03ad80219 Mon Sep 17 00:00:00 2001 From: Lukasz Stafiniak Date: Sun, 29 Dec 2024 22:14:50 +0100 Subject: [PATCH] Fix ocannl_config parsing --- CHANGES.md | 12 +++++++++++- arrayjit/lib/utils.ml | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 87c5a5df..01490129 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,14 @@ -## [0.5.0] -- current +## [0.5.1] -- current + +## Added + +- Automatic transfers to host from the context that most recently updated a node. + +## Fixed + +- Added `#` as alternative to `~~` for comment lines in `ocannl_config` files, and a bug in parsing. + +## [0.5.0] -- 2024-12-18 ### Added diff --git a/arrayjit/lib/utils.ml b/arrayjit/lib/utils.ml index 081987fd..c0d12d24 100644 --- a/arrayjit/lib/utils.ml +++ b/arrayjit/lib/utils.ml @@ -120,10 +120,12 @@ let config_file_args = in Stdio.printf "\nWelcome to OCANNL! Reading configuration defaults from %s.\n%!" fname; config_lines - |> List.filter ~f:(Fn.non @@ String.is_prefix ~prefix:"~~") + |> List.filter ~f:(fun l -> + not (String.is_prefix ~prefix:"~~" l || String.is_prefix ~prefix:"#" l)) |> List.map ~f:(String.split ~on:'=') |> List.filter_map ~f:(function | [] -> None + | [ s ] when String.is_empty s -> None | key :: [ v ] -> let key = String.( @@ -133,9 +135,9 @@ let config_file_args = if String.is_prefix key ~prefix:"ocannl" then String.drop_prefix key 6 else key in Some (String.strip ~drop:(equal_char '_') key, v) - | _ -> + | l -> failwith @@ "OCANNL: invalid syntax in the config file " ^ fname - ^ ", should have a single '=' on each non-empty line") + ^ ", should have a single '=' on each non-empty line, found: " ^ String.concat l) |> Hashtbl.of_alist_exn (module String) | Some _ -> Stdio.printf "\nWelcome to OCANNL! Configuration defaults file is disabled.\n%!";